Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v4] New translations root #6216

Closed
wants to merge 4 commits into from

Conversation

afbora
Copy link
Member

@afbora afbora commented Jan 27, 2024

This PR …

This is K4 version of #6212. Doesn't include a breaking change.

Fixes

Features

  • New translations root
$kirby = new Kirby([
    'roots' => [
        'translations' => __DIR__ . '/site/translations',
    ],
]);

Breaking changes

None

Ready?

  • Unit tests for fixed bug/feature
  • In-code documentation (wherever needed)
  • Tests and checks all pass

For review team

@afbora afbora added type: feature 🎉 Adds a feature (requests → feedback.getkirby.com) needs: tests 🧪 Requires missing tests labels Jan 27, 2024
@afbora afbora requested review from lukasbestle and a team January 27, 2024 17:20
@afbora afbora self-assigned this Jan 27, 2024
@afbora afbora mentioned this pull request Jan 27, 2024
5 tasks
@afbora afbora force-pushed the lab/afbora/new-translations-root-4x branch 2 times, most recently from e3a4ad8 to 984ee0f Compare January 30, 2024 16:54
@afbora afbora added this to the 4.2.0 milestone Feb 1, 2024
@afbora afbora marked this pull request as ready for review February 1, 2024 09:03
src/Cms/Language.php Outdated Show resolved Hide resolved
@distantnative distantnative added the needs: changes 🔁 Implement any requested changes to proceed label Feb 3, 2024
@afbora afbora force-pushed the lab/afbora/new-translations-root-4x branch from 5008f62 to a7df158 Compare February 3, 2024 20:48
@afbora afbora changed the title [v4 ]New translations root [v4] New translations root Feb 3, 2024
@afbora afbora removed the needs: changes 🔁 Implement any requested changes to proceed label Feb 5, 2024
@afbora afbora requested a review from a team February 5, 2024 09:49
@afbora afbora force-pushed the lab/afbora/new-translations-root-4x branch from a7df158 to 296ba48 Compare March 5, 2024 17:41
if ($this->translationsObject()->root() !== null) {
$this->translationsObject()
->save($data['translations'] ?? []);
$data['translations'] = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to even unset it here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems setting empty array is correct.

With set empty array:

<?php

return [
    'code' => 'en',
    'default' => true,
    'direction' => 'ltr',
    'locale' => [
        'LC_ALL' => 'en_US'
    ],
    'name' => 'EN',
    'translations' => [

    ],
    'url' => NULL
];

With unseting:

<?php

return [
    'code' => 'en',
    'default' => true,
    'direction' => 'ltr',
    'locale' => [
        'LC_ALL' => 'en_US'
    ],
    'name' => 'EN',
    'url' => NULL
];

src/Cms/LanguageTranslations.php Outdated Show resolved Hide resolved
@afbora afbora force-pushed the lab/afbora/new-translations-root-4x branch 2 times, most recently from af8afd6 to b713cd0 Compare March 21, 2024 09:02
@afbora
Copy link
Member Author

afbora commented Mar 21, 2024

I didn't understand the unit test coverage.

For ex: I added LanguageTranslations::get tests with @covers notation but shows still uncovered.

Changes:
https://github.com/getkirby/kirby/pull/6216/files#diff-4e3a14d5dc988b6b8165c6ab49bbe0a32cf21c4c141054da017fe0730e83bf5aR54-R82

Codecov:
https://app.codecov.io/gh/getkirby/kirby/pull/6216/blob/src/Cms/LanguageTranslations.php#L34

@bastianallgeier bastianallgeier modified the milestones: 4.2.0, 4.2.x Mar 27, 2024
@distantnative distantnative removed this from the 4.3.x milestone Jun 1, 2024
@distantnative distantnative added this to the 4.4.0 milestone Jun 1, 2024
@distantnative distantnative marked this pull request as draft June 1, 2024 10:50
@distantnative distantnative force-pushed the lab/afbora/new-translations-root-4x branch from b713cd0 to 5861b51 Compare July 22, 2024 15:28
@distantnative
Copy link
Member

@lukasbestle @afbora To be honest, I find the v4 version very confusing with the duality of the translation prop and translationObject etc. Since this is an area already hard to overlook and understand (even just with all the language, translation etc. names that are so similar), I would vote for letting go of a v4 version but really just focus on finishing the v5 version (which looks so much nicer already due to the cleaner syntax).

@distantnative distantnative modified the milestones: 4.4.0, 4.5.0 Aug 13, 2024
@afbora afbora closed this Sep 1, 2024
@afbora afbora deleted the lab/afbora/new-translations-root-4x branch September 1, 2024 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: tests 🧪 Requires missing tests type: feature 🎉 Adds a feature (requests → feedback.getkirby.com)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants