2amigos / yii2-file-upload-widget

BlueImp File Upload Widget for Yii2
Other
251 stars 140 forks source link

Can not set translation manually #136

Open polgarz opened 6 years ago

polgarz commented 6 years ago

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 commented 6 years ago

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), 
]);