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

[v5] New translations root #6212

Draft
wants to merge 2 commits into
base: v5/develop
Choose a base branch
from

Conversation

afbora
Copy link
Member

@afbora afbora commented Jan 26, 2024

This PR …

This was a more complex problem than I expected (always πŸ™ˆ). Because the system should be able to read, update and delete language variables both from the language file and from a custom root. It involves a breakage change, but I wanted to remove the code complexity by creating a separate LanguageTranslations object.

Fixes

Features

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

Breaking changes

Now $language->translations() returns LanguageTranslations object instead array. Use $language->translations()->toArray().

Ready?

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

For review team

@afbora afbora added needs: discussion πŸ—£ Requires further discussion to proceed type: enhancement ✨ Suggests an enhancement; improves Kirby type: feature πŸŽ‰ Adds a feature (requests β†’ feedback.getkirby.com) needs: tests πŸ§ͺ Requires missing tests labels Jan 26, 2024
@afbora afbora requested a review from a team January 26, 2024 14:07
@afbora afbora self-assigned this Jan 26, 2024
Copy link
Member

@lukasbestle lukasbestle left a comment

Choose a reason for hiding this comment

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

Great solution to move the logic to a separate class. πŸ‘
A few things I noticed while skimming through the changes:

src/Cms/Language.php Show resolved Hide resolved
src/Cms/LanguageTranslations.php Outdated Show resolved Hide resolved
src/Cms/LanguageTranslations.php Outdated Show resolved Hide resolved
src/Cms/LanguageTranslations.php Outdated Show resolved Hide resolved
@lukasbestle lukasbestle removed the needs: discussion πŸ—£ Requires further discussion to proceed label Jan 27, 2024
@afbora afbora mentioned this pull request Jan 27, 2024
5 tasks
@distantnative distantnative added the needs: changes πŸ” Implement any requested changes to proceed label Feb 3, 2024
@tobimori
Copy link
Contributor

tobimori commented Feb 6, 2024

Excited for this, thanks! Will this include the possibility to add translations (e.g. for the panel) even if the language does not have a content language assigned to it? Some of my pages are German only, but should still have English translations for the panel.

@afbora
Copy link
Member Author

afbora commented Feb 10, 2024

@tobimori In your case; multilingual is not enabled for the frontend, but you want to add translations (for example for blueprint labels) for users in different languages using the panel. Do I understand correctly?

@tobimori
Copy link
Contributor

tobimori commented Feb 10, 2024

@tobimori In your case; multilingual is not enabled for the frontend, but you want to add translations (for example for blueprint labels) for users in different languages using the panel. Do I understand correctly?

Multilingual is enabled, but the languages in the panel might differ from the languages in the frontend.
Let's say I have de and en in the frontend, but I want to add a french translation for my field labels etc. as well.

Currently, I have a translations directory and load yaml files from a plugin. (https://github.com/tobimori/kirby-baukasten/blob/main/site/plugins/project-extended/index.php#L20)

@afbora
Copy link
Member Author

afbora commented Feb 10, 2024

If there is no FR language (so fr.php language file), unfortunately it will not load custom FR translations. It will only load the translation files for existing languages from a custom root.

@tobimori
Copy link
Contributor

😦

@afbora afbora added this to the 5.0.0 milestone Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: changes πŸ” Implement any requested changes to proceed needs: tests πŸ§ͺ Requires missing tests type: enhancement ✨ Suggests an enhancement; improves Kirby type: feature πŸŽ‰ Adds a feature (requests β†’ feedback.getkirby.com)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants