Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Can not set translation manually #136

Open
polgarz opened this issue Jan 17, 2018 · 1 comment
Open

Can not set translation manually #136

polgarz opened this issue Jan 17, 2018 · 1 comment

Comments

@polgarz
Copy link

polgarz commented Jan 17, 2018

If you need to setup translation manually for whatever reason, it's not working, because the widget overwrite the i18n settings in the config.

@mrblc
Copy link

mrblc commented Jul 12, 2018

Possible solution is to pass translation configuration to plugin:

FileUpload::widget([
    'model' => $model,
    'attribute' => 'upload[]',
    ...
    'i18n' => [
        'sourceLanguage' => 'en',
        'basePath' => '@fileupload/messages',
         'class' => 'yii\i18n\PhpMessageSource',
    ],
]);

Alternative, if you want to control it from central config:

FileUpload::widget([
    'model' => $model,
    'attribute' => 'upload[]',
    ...
    'i18n' => ArrayHelper::getValue(Yii::$app->i18n->translations, 'fileupload', null), 
]);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants