Skip to content

Translation Extension via Plugin for default language EN does not work #7032

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

Open
bnomei opened this issue Feb 25, 2025 · 8 comments
Open

Translation Extension via Plugin for default language EN does not work #7032

bnomei opened this issue Feb 25, 2025 · 8 comments
Labels
needs: information ❓ Requires more information to proceed

Comments

@bnomei
Copy link

bnomei commented Feb 25, 2025

Description

When you add translations for the Kirby default language EN they do not get applied in the Panel. All other language definitions work as expected.

Expected behavior
Make it possible to add translation to the default language EN.

To reproduce

Using a multilang or single-language setup for Kirby makes no difference.

Then in a custom plugin register translations like this

'translations' => [
            'en' => require_once __DIR__.'/translations/en.php',
            'de' => require_once __DIR__.'/translations/de.php',
        ],

each leading to a file returning translated kv.

<?php

return [
    'bnomei.myplugin.customer' => 'Kunde',
    // ...
    'bnomei.myplugin.total' => 'Total',
];

try using them im a blueprint like this

fields:
   customer:
      label: bnomei.myplugin.customer # translated everywhere but not in EN
      type: text

switching the preferred language of the user updates the translations in all languages but EN which keep showing the keys.

Your setup

Kirby Version
K5.0.0.beta-3

Your system (please complete the following information)

  • OS: macos 15.3.1
  • Browser: Safari
  • Version: 18.3
@afbora
Copy link
Member

afbora commented Feb 25, 2025

I think duplicated of #7031 Could you test on v5/develop branch please? I think the issue fixed in it.

@plain-solutions-gmbh
Copy link
Contributor

No sorry. still no translation in v5/develop

@distantnative
Copy link
Member

@bnomei @plain-solutions-gmbh Is this a v5 regression for you or also not working in v4?

@distantnative distantnative added the needs: information ❓ Requires more information to proceed label Mar 29, 2025
@plain-solutions-gmbh
Copy link
Contributor

No regression for me. Everything works fine...

@distantnative
Copy link
Member

@plain-solutions-gmbh I am not sure I understand your response 😅: if everything works fine in v4, it would be a regression. If it also doesn't work in v4, it's a general bug.

@plain-solutions-gmbh
Copy link
Contributor

plain-solutions-gmbh commented Mar 30, 2025

It was working in V4 al the time. Since i'm testing in the v5/develop, the error disappeared on one day.

@bnomei
Copy link
Author

bnomei commented Apr 2, 2025

@distantnative i did some more digging through my code and spotted a single call of the t()-helper with my PHP based blueprints. that caused kirby to be initated again while loading the blueprints in the first instance thus messing up all following language resolutions for the default language (and only the default language).

maybe the t() helper could be smarter here? or the kirby app could have a way to know if it is fully loaded and only then allow helpers like t()/option() or page() that depend on the fully initated instance or throw an error?

@plain-solutions-gmbh
Copy link
Contributor

plain-solutions-gmbh commented Apr 2, 2025

I had the same problem, but i found it also in v4. So i replace the t() to an collection get.

This happens if a plugin is translating something before every other plugins is loaded. It will crash the translations for every following plugins.

t() will run Apps translation method. After its first call, $this->translations is an translation and is no longer able to take more translations from upcoming plugins loads. I suggest to check if all plugins loaded before call Translation::load().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: information ❓ Requires more information to proceed
Development

No branches or pull requests

4 participants