kirby icon indicating copy to clipboard operation
kirby copied to clipboard

New `language:variables` root

Open afbora opened this issue 1 year ago • 6 comments

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 LanguageVariables object.

Fixes

  • External language variables setup no longer works since K4's language views #6176

Features

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

Breaking changes

  • Language::translations() deprecated, use Language::variables() instead
  • $language->translations() returns LanguageVariables object instead array. Use $language->translations()->toArray() or $language->variables()->toArray().

Ready?

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

For review team

afbora avatar Jan 26 '24 14:01 afbora

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.

tobimori avatar Feb 06 '24 17:02 tobimori

@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?

afbora avatar Feb 10 '24 12:02 afbora

@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)

tobimori avatar Feb 10 '24 12:02 tobimori

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.

afbora avatar Feb 10 '24 12:02 afbora

😦

tobimori avatar Feb 10 '24 13:02 tobimori