Skip to content

Commit

Permalink
Add translations files. (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw authored Nov 21, 2023
1 parent 4c4997f commit 5ddcb85
Show file tree
Hide file tree
Showing 11 changed files with 264 additions and 2 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"dev-master": "1.0.x-dev"
},
"config-plugin": {
"params": "params.php",
"yii2-filepond": "extension.php"
},
"config-plugin-options": {
Expand Down
1 change: 1 addition & 0 deletions config/extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'translations' => [
'yii.filepond' => [
'class' => PhpMessageSource::class,
'basePath' => '@yii-filepond/resource/message',
],
],
],
Expand Down
66 changes: 66 additions & 0 deletions config/messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

declare(strict_types=1);

/**
* This is a configuration file for the [[\yii\console\controllers\MessageController]] console command.
*
* In order to update translations, run the following console command:
* php yii message messages/config.php
*
* @see yii\console\controllers\MessageController
*/

return [
// string, required, root directory of all source files
'sourcePath' => dirname(__DIR__) . '/src',
// array, required, list of language codes that the extracted messages
// should be translated to. For example, ['zh-CN', 'de'].
'languages' => ['de', 'es', 'fr', 'pt', 'ru', 'zh'],
// string, the name of the function for translating messages.
// Defaults to 'Yii::t'. This is used as a mark to find the messages to be
// translated. You may use a string for single function name or an array for
// multiple function names.
'translator' => ['Yii::t'],
// boolean, whether to sort messages by keys when merging new messages
// with the existing ones. Defaults to false, which means the new (untranslated)
// messages will be separated from the old (translated) ones.
'sort' => true,
// boolean, whether to remove messages that no longer appear in the source code.
// Defaults to false, which means each of these messages will be enclosed with a pair of '@@' marks.
'removeUnused' => false,
// array, list of patterns that specify which files (not directories) should be processed.
// If empty or not set, all files will be processed.
// Please refer to "except" for details about the patterns.
'only' => ['*.php'],
// array, list of patterns that specify which files/directories should NOT be processed.
// If empty or not set, all files/directories will be processed.
// A path matches a pattern if it contains the pattern string at its end. For example,
// '/a/b' will match all files and directories ending with '/a/b';
// the '*.svn' will match all files and directories whose name ends with '.svn'.
// and the '.svn' will match all files and directories named exactly '.svn'.
// Note, the '/' characters in a pattern matches both '/' and '\'.
// See helpers/FileHelper::findFiles() description for more details on pattern matching rules.
// If a file/directory matches both a pattern in "only" and "except", it will NOT be processed.
'except' => [
'.svn',
'.git',
'.gitignore',
'.gitkeep',
'.hg',
'.hgignore',
'.hgkeep',
'/messages',
'/migrations',
],
// 'php' output format is for saving messages to php files.
'format' => 'php',
// Root directory containing message translations.
'messagePath' => dirname(__DIR__) . '/resource/message',
// boolean, whether the message file should be overwritten with the merged messages
'overwrite' => true,
// Message categories to ignore
'ignoreCategories' => [
'yii',
],
];
9 changes: 9 additions & 0 deletions config/params.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

return [
'common.aliases' => [
'@yii-filepond' => '@vendor/yii2-extensions/filepond',
],
];
30 changes: 30 additions & 0 deletions resource/message/de/yii.filepond.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/**
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Drag & Drop your files or <span class="filepond--label-action"> Browse </span>' => 'Dateien per Drag & Drop ablegen oder <span class="filepond--label-action"> Durchsuchen </span>',
'Expects {allButLastType} or {lastType}' => 'Erwartet {allButLastType} oder {lastType}',
'File is too large' => 'Datei ist zu groß',
'File type not allowed' => 'Dateityp nicht erlaubt',
'Maximum file size is {filesize}' => 'Maximale Dateigröße beträgt {filesize}',
'Maximum total file size is {filesize}' => 'Maximale Gesamtdateigröße beträgt {filesize}',
'Maximum total size exceeded' => 'Maximale Gesamtgröße überschritten',
];
30 changes: 30 additions & 0 deletions resource/message/es/yii.filepond.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/**
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Drag & Drop your files or <span class="filepond--label-action"> Browse </span>' => 'Arrastra y suelta tus archivos o <span class="filepond--label-action"> Navega </span>',
'Expects {allButLastType} or {lastType}' => 'Espera {allButLastType} o {lastType}',
'File is too large' => 'El archivo es demasiado grande',
'File type not allowed' => 'Tipo de archivo no permitido',
'Maximum file size is {filesize}' => 'El tamaño máximo del archivo es {filesize}',
'Maximum total file size is {filesize}' => 'El tamaño total máximo del archivo es {filesize}',
'Maximum total size exceeded' => 'Se ha excedido el tamaño total máximo',
];
30 changes: 30 additions & 0 deletions resource/message/fr/yii.filepond.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/**
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Drag & Drop your files or <span class="filepond--label-action"> Browse </span>' => 'Glissez et déposez vos fichiers ou <span class="filepond--label-action"> Parcourir </span>',
'Expects {allButLastType} or {lastType}' => 'Attend {allButLastType} ou {lastType}',
'File is too large' => 'Le fichier est trop volumineux',
'File type not allowed' => 'Type de fichier non autorisé',
'Maximum file size is {filesize}' => 'La taille maximale du fichier est {filesize}',
'Maximum total file size is {filesize}' => 'La taille totale maximale du fichier est {filesize}',
'Maximum total size exceeded' => 'Taille totale maximale dépassée',
];
30 changes: 30 additions & 0 deletions resource/message/pt/yii.filepond.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/**
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Drag & Drop your files or <span class="filepond--label-action"> Browse </span>' => 'Arraste e solte seus arquivos ou <span class="filepond--label-action"> Navegar </span>',
'Expects {allButLastType} or {lastType}' => 'Espera {allButLastType} ou {lastType}',
'File is too large' => 'O arquivo é muito grande',
'File type not allowed' => 'Tipo de arquivo não permitido',
'Maximum file size is {filesize}' => 'O tamanho máximo do arquivo é {filesize}',
'Maximum total file size is {filesize}' => 'O tamanho total máximo do arquivo é {filesize}',
'Maximum total size exceeded' => 'Tamanho total máximo excedido',
];
30 changes: 30 additions & 0 deletions resource/message/ru/yii.filepond.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/**
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Drag & Drop your files or <span class="filepond--label-action"> Browse </span>' => 'Перетащите файлы или <span class="filepond--label-action"> Обзор </span>',
'Expects {allButLastType} or {lastType}' => 'Ожидает {allButLastType} или {lastType}',
'File is too large' => 'Файл слишком большой',
'File type not allowed' => 'Тип файла не разрешен',
'Maximum file size is {filesize}' => 'Максимальный размер файла {filesize}',
'Maximum total file size is {filesize}' => 'Максимальный общий размер файла {filesize}',
'Maximum total size exceeded' => 'Превышен максимальный общий размер',
];
30 changes: 30 additions & 0 deletions resource/message/zh/yii.filepond.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/**
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Drag & Drop your files or <span class="filepond--label-action"> Browse </span>' => '拖放文件或<span class="filepond--label-action">浏览</span>',
'Expects {allButLastType} or {lastType}' => '期望{allButLastType}或{lastType}',
'File is too large' => '文件太大',
'File type not allowed' => '文件类型不允许',
'Maximum file size is {filesize}' => '文件大小最大为{filesize}',
'Maximum total file size is {filesize}' => '总文件大小最大为{filesize}',
'Maximum total size exceeded' => '超出最大总大小',
];
9 changes: 7 additions & 2 deletions src/FilePond.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ final class FilePond extends InputWidget
/**
* @var string The label to show when there are no files.
*/
public string $labelIdle = 'Drag & Drop your files or <span class="filepond--label-action"> Browse </span>';
public string $labelIdle = '';
/**
* @var string Label for max files size.
*/
Expand Down Expand Up @@ -309,7 +309,12 @@ public function init(): void
'imageTransformVariantsDefaultName' => $this->imageTransformVariantsDefaultName,
'imageTransformVariantsIncludeOriginal' => $this->imageTransformVariantsIncludeDefault,
'labelFileTypeNotAllowed' => Yii::t('yii.filepond', 'File type not allowed'),
'labelIdle' => $this->labelIdle,
'labelIdle' => $this->labelIdle === ''
? Yii::t(
'yii.filepond',
'Drag & Drop your files or <span class="filepond--label-action"> Browse </span>',
)
: $this->labelIdle,
'labelMaxFileSize' => Yii::t('yii.filepond', 'Maximum file size is {filesize}'),
'labelMaxFileSizeExceeded' => Yii::t('yii.filepond', 'File is too large'),
'labelMaxTotalFileSize' => Yii::t('yii.filepond', 'Maximum total file size is {filesize}'),
Expand Down

0 comments on commit 5ddcb85

Please sign in to comment.