wintercms / winter

Free, open-source, self-hosted CMS platform based on the Laravel PHP Framework.
https://wintercms.com
MIT License
1.36k stars 192 forks source link

fallback_locale will be ignored #220

Closed Kuse-GmbH closed 3 years ago

Kuse-GmbH commented 3 years ago

Description:

'fallback_locale' => 'en' will be ignored in backend mainmenu

I use 'locale' => 'de' in my installation and a plugin gromit.sentmails (there is only one plugin without german translation installed) and in mainmenu there is the translation string:

Bildschirmfoto_2021-06-30_08-15-34

at the top there is a screenshot from winterCMS (booth testet, web installer and composer install), at the bottom an nearly identical oc-install (latest v1)

Steps To Reproduce:

in app.php: 'locale' => 'de', 'fallback_locale' => 'en',

Install gromit.sentmails

mjauvin commented 3 years ago

I can't reproduce this, fallback_locale works fine for me.

xitara commented 3 years ago

ok. I will test it on a clean new installation with only this plugin tomorrow and I'll give feedback thanks

ops. I posted with a different account before. sorry for this.

mjauvin commented 3 years ago

Just to clarify, I tried to reproduce with 'locale' => 'fr' and 'fallback_locale => 'en' with a plugin of mine with missing FR strings localizations and the EN version was used (as a fallback).

mjauvin commented 3 years ago

Just tried with gromit.sentmails and was able to reproduce... I'll report what I find in a few minutes.

mjauvin commented 3 years ago

Ok, I found the problem: the plugin is using RainLab.Translate instead of Laravel for its localization... i.e.

    public function registerNavigation(): array
    {   
        return [
            'sentmails' => [
                'label'       => __('gromit.sentmails::lang.menu_label'),
                'url'         => Backend::url('gromit/sentmails/mails'),
                'icon'        => 'icon-envelope-open',
                'permissions' => ['gromit.sentmails.*'],
                'order'       => 500,
            ],
        ];
    }
mjauvin commented 3 years ago

Note: the plugin should be using this instead:

    public function registerNavigation(): array
    {   
        return [
            'sentmails' => [
                'label'       => 'gromit.sentmails::lang.menu_label',
                'url'         => Backend::url('gromit/sentmails/mails'),
                'icon'        => 'icon-envelope-open',
                'permissions' => ['gromit.sentmails.*'],
                'order'       => 500,
            ],
        ];
    }

ALL INSTANCES should be replaced in Plugin.php for this to work (everywhere __() is used)

xitara commented 3 years ago

I want to migrate this plugin with some new features to winterCMS. Then I replace the translations, too

mjauvin commented 3 years ago

Is it one of your plugins?

mjauvin commented 3 years ago

I submitted a PR to address the issues:

https://github.com/gromitsoft/oc-sentmails-plugin/pull/2