luyadev / luya

LUYA is a scalable web framework and content management system with the goal to please developers, clients and users alike.
https://luya.io
MIT License
812 stars 207 forks source link

Themes with translation? #1992

Closed boehsermoe closed 4 years ago

boehsermoe commented 4 years ago

Problem

Maybe some theme could have some translations in their views. Currently you can only use Yii::t('app', 'lorem ipsum'). In a theme inside the app this is no problem, but for theme packages.

Idea

On thememanager setup register translation form the theme messages directory like in onLoad function of modules. Those translations should have the prefix theme and call with Yii::t('theme<theme name>', 'lorem ipsum')

Theme translation have to be overridable from the app.

nadar commented 4 years ago

Each module can provided translations by its own:

    public static function onLoad()
    {
        Yii::setAlias('@luyathemes', static::staticBasePath());

        self::registerTranslation('luyathemes*', '@luyathemes/messages', [
            'luyathemes' => 'luyathemes.php',
        ]);

        parent::onLoad();
    }

    public static function t($message, array $params = [], $language = null)
    {
        return parent::baseT('luyathemes', $message, $params, $language);
    }

So i would say this works already?

nadar commented 4 years ago

I am going to close this issue because:

If you think this is still important or there are more/new informations. Please reopen the issue and let us know.

If this is a problem or a feature you like to discuss, join our slack team: slack.luya.io. We try to keep our issue tracker as clean as possible in order to focus on active issues.