yii2-file-upload-widget icon indicating copy to clipboard operation
yii2-file-upload-widget copied to clipboard

Can not set translation manually

Open polgarz opened this issue 7 years ago • 1 comments

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

polgarz avatar Jan 17 '18 18:01 polgarz

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

mrblc avatar Jul 12 '18 12:07 mrblc