diff --git a/.php_cs b/.php_cs index d98e72f..8550239 100644 --- a/.php_cs +++ b/.php_cs @@ -24,6 +24,4 @@ return yii\cs\YiisoftConfig::create() ->notPath('framework/classes.php') ->notPath('framework/helpers/mimeTypes.php') ->notPath('framework/views/messageConfig.php') - // temporary disable messages processing - conflicts with header fixer - ->exclude('framework/messages') ); diff --git a/docs/internals-es/translation-workflow.md b/docs/internals-es/translation-workflow.md index 68317a9..2896bc8 100644 --- a/docs/internals-es/translation-workflow.md +++ b/docs/internals-es/translation-workflow.md @@ -14,11 +14,11 @@ El orden para comenzar con la traducción de mensajes: 1. Comprobar que en `framework/messages/config.php` su idioma aparece en `languages`. Si no, añade tu idioma allí (recuerda que debes mantener la lista en orden alfabético). El formato de código de idioma debe seguir el [Código de Idiomas IETF](http://es.wikipedia.org/wiki/C%C3%B3digo_de_idioma_IETF), por ejemplo, `es`. -2. Ir al directorio `framework` y ejecutar el comando `yii message/extract messages/config.php`. +2. Ir al directorio `framework` y ejecutar el comando `yii message/extract @yii/messages/config.php --languages=`. 3. Traducir los mensajes en `framework/messages/tu-idioma/yii.php`. Asegúrate de guardar el archivo con codificación UTF-8. 4. [Crear un pull request](https://github.com/yiisoft/yii2/blob/master/docs/internals-es/git-workflow.md). -Con el fin de mantener la traducción al día puedes ejecutar `yii message/extract messages/config.php` nuevamente. +Con el fin de mantener la traducción al día puedes ejecutar `yii message/extract @yii/messages/config.php --languages=` nuevamente. Se volverán a extraer automáticamente los mensajes de mantenimiento intactos sin los cambios. En el archivo de traducción de cada elemento del `array` representa un mensaje (clave) y su la traducción (valor). Si el valor está vacío, el mensaje se considera como no traducido. diff --git a/docs/internals-ja/translation-workflow.md b/docs/internals-ja/translation-workflow.md index 9c22a37..cfbc701 100644 --- a/docs/internals-ja/translation-workflow.md +++ b/docs/internals-ja/translation-workflow.md @@ -15,11 +15,11 @@ Yii は国際的なアプリケーションと開発者にとって役に立つ 1. `framework/messages/config.php` をチェックして、あなたの言語が `languages` のリストに載っていることを確認してください。 もし無ければ、あなたの言語をそこに追加します (リストをアルファベット順に保つことを忘れないでください)。 言語コードの形式は、例えば `ru` や `zh-CN` のように、[IETF言語タグ](http://ja.wikipedia.org/wiki/IETF%E8%A8%80%E8%AA%9E%E3%82%BF%E3%82%B0) に従うべきです。 -2. `framework` に入って、`./yii message/extract --languages=` を走らせます。 +2. `framework` に入って、`./yii message/extract @yii/messages/config.php --languages=` を走らせます。 3. `framework/messages/your_language/yii.php` のメッセージを翻訳します。ファイルは必ず UTF-8 エンコーディングを使って保存してください。 4. [プルリクエスト](git-workflow.md) をします。 -あなたの翻訳を最新状態に保つために、`./yii message/extract --languages=` を再び走らせることが出来ます。 +あなたの翻訳を最新状態に保つために、`./yii message/extract @yii/messages/config.php --languages=` を再び走らせることが出来ます。 このコマンドは、変更のなかった箇所には触れることなく、自動的にメッセージを再抽出してくれます。 翻訳ファイルの中で、配列の各要素は、メッセージ(キー)と翻訳(値)をあらわします。 diff --git a/docs/internals-pl/translation-workflow.md b/docs/internals-pl/translation-workflow.md index 798caac..40d5dea 100644 --- a/docs/internals-pl/translation-workflow.md +++ b/docs/internals-pl/translation-workflow.md @@ -15,11 +15,11 @@ Aby rozpocząć tłumaczenie komunikatów: 1. Sprawdź plik `framework/messages/config.php` i upewnij się, że Twój język jest wymieniony w sekcji `languages`. Jeśli nie, dodaj go tam (pamiętaj, że lista powinna być posortowana alfabetycznie). Format kodu języka powinien być zgodny ze [specyfikacją IETF](http://en.wikipedia.org/wiki/IETF_language_tag) (przykładowo `ru`, `zh-CN`). -2. Przejdź do folderu `framework` i uruchom `./yii message/extract --languages=`. +2. Przejdź do folderu `framework` i uruchom `./yii message/extract @yii/messages/config.php --languages=`. 3. Przetłumacz komunikaty w pliku `framework/messages/twoj_jezyk/yii.php`. Upewnij się, że zapisujesz plik z kodowaniem UTF-8. 4. [Wyślij prośbę o dołączenie kodu](git-workflow.md). -Aby Twoje tłumaczenia pozostawały aktualne, możesz uruchomić `./yii message/extract --languages=` ponownie po pewnym czasie. +Aby Twoje tłumaczenia pozostawały aktualne, możesz uruchomić `./yii message/extract @yii/messages/config.php --languages=` ponownie po pewnym czasie. Komunikaty zostaną jeszcze raz wyekstraktowane, pozostawiając w pliku te, które się nie zmieniły. W pliku tłumaczeń każdy element tablicy reprezentuje przetłumaczony (wartość) komunikat (klucz). Jeśli wartość jest pusta, diff --git a/docs/internals-pt-BR/translation-workflow.md b/docs/internals-pt-BR/translation-workflow.md index 0bbb9f0..b381abc 100644 --- a/docs/internals-pt-BR/translation-workflow.md +++ b/docs/internals-pt-BR/translation-workflow.md @@ -15,7 +15,7 @@ para o usuário final, tais como erros de validação. Os passos para iniciar a tradução de mensagens são: 1. Com o `console` entre na pasta `yii2/framework` e execute o seguinte comando: - `yii message/extract messages/config.php`. + `./yii message/extract @yii/messages/config.php --languages=pt-BR`. 2. As mensagens a serem traduzidas encontram-se no seguinte caminho: `framework/messages/pt-BR/yii.php`. Certifique-se de salvar o arquivo com a codificação UTF-8 (Plain). @@ -26,7 +26,7 @@ Os passos para iniciar a tradução de mensagens são: Para manter as traduções sempre atualizadas, certifique-se que seu fork do Yii esteja com a última versão. Em seguida, basta executar o comando -`yii message/extract messages/config.php` novamente e o mesmo irá adicionar +`./yii message/extract @yii/messages/config.php --languages=pt-BR` novamente e o mesmo irá adicionar automaticamente as novas mensagens a serem traduzidas. No arquivo de tradução cada elemento do array representa a tradução de uma @@ -115,4 +115,4 @@ Regras e Observações - query string - case-sensitive - case-insensitive -- callback \ No newline at end of file +- callback diff --git a/docs/internals-ru/translation-workflow.md b/docs/internals-ru/translation-workflow.md index 825031d..8bba542 100644 --- a/docs/internals-ru/translation-workflow.md +++ b/docs/internals-ru/translation-workflow.md @@ -11,7 +11,7 @@ Yii переводится на множество языков, в том чи Для того, чтобы обновить перевод: -1. Открываем в консоли директорию `framework`, запускаем `yii message/extract messages/config.php`. +1. Открываем в консоли директорию `framework`, запускаем `./yii message/extract @yii/messages/config.php --languages=ru`. 3. Переводим сообщения в `framework/messages/ru/yii.php`. Важно чтобы файлы были в кодировке UTF-8. 4. [Делаем pull request](https://github.com/yiisoft/yii2/blob/master/docs/internals-ru/git-workflow.md) с переводом из `ru`, остальные языки не трогаем. diff --git a/docs/internals-sr-Latn/translation-workflow.md b/docs/internals-sr-Latn/translation-workflow.md index 16b20aa..8cbf9ca 100644 --- a/docs/internals-sr-Latn/translation-workflow.md +++ b/docs/internals-sr-Latn/translation-workflow.md @@ -13,11 +13,11 @@ Da bi započeli rad sa prevodom poruka potrebno je da: 1. Otvorite `framework/messages/config.php` i proverite da li je vaš jezik naveden u `languages`. Ako nije, dodajte tu vaš jezik (ne zaboravite da zadržite alfabetički rapored). Format koda jezika treba da prati [IETF jezičku tag specifikaciju](http://en.wikipedia.org/wiki/IETF_language_tag), na primer, `ru`, `zh-CN`. -2. Uđite u `framework` direktorijum i pokrenite `yii message/extract messages/config.php`. +2. Uđite u `framework` direktorijum i pokrenite `./yii message/extract @yii/messages/config.php --languages=`. 3. Prevedite poruke unutar `framework/messages/your_language/yii.php` fajla. Pobrinite se da se fajl sačuva sa UTF-8 enkodingom. 4. [Napravite pull zahtev](https://github.com/yiisoft/yii2/blob/master/docs/internals-sr-Latn/git-workflow.md). -Kako bi vaš prevod bio ažuran možete pokrenuti komandu `yii message/extract messages/config.php` još jednom. Ona će automatski ponovo izvući poruke ostavljajući nepromenjene netaknutim. +Kako bi vaš prevod bio ažuran možete pokrenuti komandu `./yii message/extract @yii/messages/config.php --languages=` još jednom. Ona će automatski ponovo izvući poruke ostavljajući nepromenjene netaknutim. U fajlu za prevođenje svaki element niza predstavlja prevod (vrednost) poruke (ključ). Ako je vrednost prazna, poruka se smatra neprevedenom. Poruke koje više ne trebaju prevod će imati svoje prevode zatvorene između para '@@' znaka. Poruke se mogu koristiti i u formatu za množinu. Pogledajte [i18n sekciju uputstva](../guide-sr-Latn/tutorial-i18n.md) za više informacija. @@ -32,4 +32,4 @@ Nakon što je inicijalni posao završen možete dobiti šta je promenjeno nakon php build translation "../docs/guide" "../docs/guide-ru" "Russian guide translation report" > report_guide_ru.html ``` -Ako se bude bunio u vezi composer-a, izvršite `composer install` u samom root-u direktorijumu. \ No newline at end of file +Ako se bude bunio u vezi composer-a, izvršite `composer install` u samom root-u direktorijumu. diff --git a/docs/internals-uk/translation-workflow.md b/docs/internals-uk/translation-workflow.md index 685f30b..28059a0 100644 --- a/docs/internals-uk/translation-workflow.md +++ b/docs/internals-uk/translation-workflow.md @@ -12,11 +12,11 @@ Yii перекладається на багато різних мов, щоб Щоб розпочати переклад повідомлень необхідно: -1. Перейти до директорії `framework` та виконати команду `./yii message/extract messages/config.php`. +1. Перейти до директорії `framework` та виконати команду `./yii message/extract @yii/messages/config.php --languages=uk`. 2. Перекласти повідомлення у файлі `framework/messages/uk/yii.php`. Зберегти файл у кодуванні UTF-8. 3. [Відправити "pull request"](git-workflow.md). -Для підтримання перекладу в актуальному стані можна знову використовувати команду `./yii message/extract messages/config.php`. +Для підтримання перекладу в актуальному стані можна знову використовувати команду `./yii message/extract @yii/messages/config.php --languages=uk`. Це автоматично здобуде нові повідомлення, зберігаючи при цьому вже перекладені. У файлі перекладу кожний ключ елементу масиву представляє повідомлення, а значення елементу масиву представляє переклад. diff --git a/docs/internals-uz/translation-workflow.md b/docs/internals-uz/translation-workflow.md index f29b723..b535fb7 100644 --- a/docs/internals-uz/translation-workflow.md +++ b/docs/internals-uz/translation-workflow.md @@ -10,7 +10,7 @@ Ikki turdagi habarlar bor: istisnolar, qaysiki ishlab chiquvchi nazarda tutgan v Tarjimani yangilash uchun: -1. Konsolda `framework` direktoriyani ochamiz, `yii message/extract messages/config.php` ni ishga tushiramiz. +1. Konsolda `framework` direktoriyani ochamiz, `./yii message/extract @yii/messages/config.php --languages=uz` ni ishga tushiramiz. 3. Habarlarni `framework/messages/uz/yii.php` ga ko`chiramiz. Muhimi fayllar UTF-8 kodlashda bo'lishi kerak. 4. `uz` dagi tarjimalar bilan [pull request qilamiz](https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md), qolgan tillarga tegmaymiz. @@ -133,4 +133,4 @@ Oxirgi variantni tashlashdan oldin uni umumiy stilini, orfografiyasini, punktlar - validator — validator. - validator class — validator klasi. - view — namoyish. -- query builder — so'rovlar konstruktori. \ No newline at end of file +- query builder — so'rovlar konstruktori. diff --git a/docs/internals/translation-workflow.md b/docs/internals/translation-workflow.md index b77f4a9..88ceee6 100644 --- a/docs/internals/translation-workflow.md +++ b/docs/internals/translation-workflow.md @@ -16,11 +16,11 @@ In order to start with message translation: add your language there (remember to keep the list in alphabetical order). The format of language code should follow [IETF language tag spec](http://en.wikipedia.org/wiki/IETF_language_tag), for example, `ru`, `zh-CN`. -2. Go to `framework` and run `./yii message/extract --languages=`. +2. Go to `framework` and run `./yii message/extract @yii/messages/config.php --languages=`. 3. Translate messages in `framework/messages/your_language/yii.php`. Make sure file is saved using UTF-8 encoding. 4. [Make a pull request](git-workflow.md). -In order to keep your translation up to date you may run `./yii message/extract --languages=` again. It will +In order to keep your translation up to date you may run `./yii message/extract @yii/messages/config.php --languages=` again. It will automatically re-extract messages keeping unchanged ones intact. In the translation file each array element represents the translation (value) of a message (key). If the value is empty, diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 2f5a60e..ffab938 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -26,6 +26,7 @@ Yii Framework 2 Change Log - Enh #13378: Added skipOnEmpty option to SluggableBehaviour (andrewnester) - Enh #14389: Optimize `Validator::validateAttributes()` by calling `attributeNames()` only once (nicdnep) - Enh #14105: Implemented a solution for retrieving DBMS constraints in `yii\db\Schema` (sergeymakinen) +- Enh #14417: Added configuration for headers in PHP files generated by `message/extract` command (rob006) 2.0.12 June 05, 2017 diff --git a/framework/console/controllers/MessageController.php b/framework/console/controllers/MessageController.php index 0e4fb52..a2bf2e8 100644 --- a/framework/console/controllers/MessageController.php +++ b/framework/console/controllers/MessageController.php @@ -131,6 +131,25 @@ class MessageController extends \yii\console\Controller * @see isCategoryIgnored */ public $ignoreCategories = []; + /** + * @var string File header in generated PHP file with messages. This property is used only if [[$format]] is "php". + * @since 2.0.13 + */ + public $phpFileHeader = ''; + /** + * @var string|null DocBlock used for messages array in generated PHP file. If `null`, default DocBlock will be used. + * This property is used only if [[$format]] is "php". + * @since 2.0.13 + */ + public $phpDocBlock; + + /** + * @var array Config for messages extraction. + * @see actionExtract() + * @see initConfig() + * @since 2.0.13 + */ + protected $config; /** @@ -155,6 +174,8 @@ class MessageController extends \yii\console\Controller 'messageTable', 'catalog', 'ignoreCategories', + 'phpFileHeader', + 'phpDocBlock', ]); } @@ -271,81 +292,45 @@ EOD; */ public function actionExtract($configFile = null) { - $configFileContent = []; - if ($configFile !== null) { - $configFile = Yii::getAlias($configFile); - if (!is_file($configFile)) { - throw new Exception("The configuration file does not exist: $configFile"); - } - $configFileContent = require $configFile; - } + $this->initConfig($configFile); - $config = array_merge( - $this->getOptionValues($this->action->id), - $configFileContent, - $this->getPassedOptionValues() - ); - $config['sourcePath'] = Yii::getAlias($config['sourcePath']); - $config['messagePath'] = Yii::getAlias($config['messagePath']); - - if (!isset($config['sourcePath'], $config['languages'])) { - throw new Exception('The configuration file must specify "sourcePath" and "languages".'); - } - if (!is_dir($config['sourcePath'])) { - throw new Exception("The source path {$config['sourcePath']} is not a valid directory."); - } - if (empty($config['format']) || !in_array($config['format'], ['php', 'po', 'pot', 'db'])) { - throw new Exception('Format should be either "php", "po", "pot" or "db".'); - } - if (in_array($config['format'], ['php', 'po', 'pot'])) { - if (!isset($config['messagePath'])) { - throw new Exception('The configuration file must specify "messagePath".'); - } - if (!is_dir($config['messagePath'])) { - throw new Exception("The message path {$config['messagePath']} is not a valid directory."); - } - } - if (empty($config['languages'])) { - throw new Exception('Languages cannot be empty.'); - } - - $files = FileHelper::findFiles(realpath($config['sourcePath']), $config); + $files = FileHelper::findFiles(realpath($this->config['sourcePath']), $this->config); $messages = []; foreach ($files as $file) { - $messages = array_merge_recursive($messages, $this->extractMessages($file, $config['translator'], $config['ignoreCategories'])); + $messages = array_merge_recursive($messages, $this->extractMessages($file, $this->config['translator'], $this->config['ignoreCategories'])); } - $catalog = isset($config['catalog']) ? $config['catalog'] : 'messages'; + $catalog = isset($this->config['catalog']) ? $this->config['catalog'] : 'messages'; - if (in_array($config['format'], ['php', 'po'])) { - foreach ($config['languages'] as $language) { - $dir = $config['messagePath'] . DIRECTORY_SEPARATOR . $language; + if (in_array($this->config['format'], ['php', 'po'])) { + foreach ($this->config['languages'] as $language) { + $dir = $this->config['messagePath'] . DIRECTORY_SEPARATOR . $language; if (!is_dir($dir) && !@mkdir($dir)) { throw new Exception("Directory '{$dir}' can not be created."); } - if ($config['format'] === 'po') { - $this->saveMessagesToPO($messages, $dir, $config['overwrite'], $config['removeUnused'], $config['sort'], $catalog, $config['markUnused']); + if ($this->config['format'] === 'po') { + $this->saveMessagesToPO($messages, $dir, $this->config['overwrite'], $this->config['removeUnused'], $this->config['sort'], $catalog, $this->config['markUnused']); } else { - $this->saveMessagesToPHP($messages, $dir, $config['overwrite'], $config['removeUnused'], $config['sort'], $config['markUnused']); + $this->saveMessagesToPHP($messages, $dir, $this->config['overwrite'], $this->config['removeUnused'], $this->config['sort'], $this->config['markUnused']); } } - } elseif ($config['format'] === 'db') { + } elseif ($this->config['format'] === 'db') { /** @var Connection $db */ - $db = Instance::ensure($config['db'], Connection::className()); - $sourceMessageTable = isset($config['sourceMessageTable']) ? $config['sourceMessageTable'] : '{{%source_message}}'; - $messageTable = isset($config['messageTable']) ? $config['messageTable'] : '{{%message}}'; + $db = Instance::ensure($this->config['db'], Connection::className()); + $sourceMessageTable = isset($this->config['sourceMessageTable']) ? $this->config['sourceMessageTable'] : '{{%source_message}}'; + $messageTable = isset($this->config['messageTable']) ? $this->config['messageTable'] : '{{%message}}'; $this->saveMessagesToDb( $messages, $db, $sourceMessageTable, $messageTable, - $config['removeUnused'], - $config['languages'], - $config['markUnused'] + $this->config['removeUnused'], + $this->config['languages'], + $this->config['markUnused'] ); - } elseif ($config['format'] === 'pot') { - $this->saveMessagesToPOT($messages, $config['messagePath'], $catalog); + } elseif ($this->config['format'] === 'pot') { + $this->saveMessagesToPOT($messages, $this->config['messagePath'], $catalog); } } @@ -739,23 +724,7 @@ EOD; $array = VarDumper::export($merged); $content = <<id}/{$this->action->id}' 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. - */ +{$this->config['phpFileHeader']}{$this->config['phpDocBlock']} return $array; EOD; @@ -902,4 +871,72 @@ EOD; $this->stdout("Nothing to save.\n", Console::FG_GREEN); } } + + /** + * @param string $configFile + * @throws Exception If configuration file does not exists. + * @since 2.0.13 + */ + protected function initConfig($configFile) + { + $configFileContent = []; + if ($configFile !== null) { + $configFile = Yii::getAlias($configFile); + if (!is_file($configFile)) { + throw new Exception("The configuration file does not exist: $configFile"); + } + $configFileContent = require $configFile; + } + + $this->config = array_merge( + $this->getOptionValues($this->action->id), + $configFileContent, + $this->getPassedOptionValues() + ); + $this->config['sourcePath'] = Yii::getAlias($this->config['sourcePath']); + $this->config['messagePath'] = Yii::getAlias($this->config['messagePath']); + + if (!isset($this->config['sourcePath'], $this->config['languages'])) { + throw new Exception('The configuration file must specify "sourcePath" and "languages".'); + } + if (!is_dir($this->config['sourcePath'])) { + throw new Exception("The source path {$this->config['sourcePath']} is not a valid directory."); + } + if (empty($this->config['format']) || !in_array($this->config['format'], ['php', 'po', 'pot', 'db'])) { + throw new Exception('Format should be either "php", "po", "pot" or "db".'); + } + if (in_array($this->config['format'], ['php', 'po', 'pot'])) { + if (!isset($this->config['messagePath'])) { + throw new Exception('The configuration file must specify "messagePath".'); + } + if (!is_dir($this->config['messagePath'])) { + throw new Exception("The message path {$this->config['messagePath']} is not a valid directory."); + } + } + if (empty($this->config['languages'])) { + throw new Exception('Languages cannot be empty.'); + } + + if ($this->config['format'] === 'php' && $this->config['phpDocBlock'] === null) { + $this->config['phpDocBlock'] = <<id}/{$this->action->id}' 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. + */ +DOCBLOCK; + } + } } diff --git a/framework/console/widgets/Table.php b/framework/console/widgets/Table.php index 5a0e770..6d32857 100644 --- a/framework/console/widgets/Table.php +++ b/framework/console/widgets/Table.php @@ -8,7 +8,6 @@ namespace yii\console\widgets; use Yii; -use yii\base\Object; use yii\base\Widget; use yii\helpers\ArrayHelper; use yii\helpers\Console; @@ -61,7 +60,7 @@ class Table extends Widget const CHAR_RIGHT = 'right'; const CHAR_RIGHT_MID = 'right-mid'; const CHAR_MIDDLE = 'middle'; - + /** * @var array table headers */ @@ -304,10 +303,10 @@ class Table extends Widget foreach ($columns as $column) { $columnWidth = max(array_map(function ($val) { if (is_array($val)) { - $encodings = array_fill(0, count($val), Yii::$app->charset); - return max(array_map('mb_strwidth', $val, $encodings)) + mb_strwidth($this->_listPrefix, Yii::$app->charset); - } - return mb_strwidth($val, Yii::$app->charset); + $encodings = array_fill(0, count($val), Yii::$app->charset); + return max(array_map('mb_strwidth', $val, $encodings)) + mb_strwidth($this->_listPrefix, Yii::$app->charset); + } + return mb_strwidth($val, Yii::$app->charset); }, $column)) + 2; $this->_columnWidths[] = $columnWidth; $totalWidth += $columnWidth; diff --git a/framework/messages/ar/yii.php b/framework/messages/ar/yii.php index 847f709..8657175 100644 --- a/framework/messages/ar/yii.php +++ b/framework/messages/ar/yii.php @@ -1,8 +1,14 @@ ['*.php'], + 'phpFileHeader' => '/** + * @link http://www.yiiframework.com/ + * @copyright Copyright (c) 2008 Yii Software LLC + * @license http://www.yiiframework.com/license/ + */ + +', // Generated file format. Can be "php", "db" or "po". 'format' => 'php', // Connection component ID for "db" format. diff --git a/framework/messages/cs/yii.php b/framework/messages/cs/yii.php index 0925d23..352eb43 100644 --- a/framework/messages/cs/yii.php +++ b/framework/messages/cs/yii.php @@ -1,8 +1,14 @@ '{nFormatted} B', - '{nFormatted} GB' => '{nFormatted} Gb', + '{nFormatted} B' => '{nFormatted} B', + '{nFormatted} GB' => '{nFormatted} Gb', '{nFormatted} GiB' => '{nFormatted} GiB', - '{nFormatted} KB' => '{nFormatted} KB', + '{nFormatted} KB' => '{nFormatted} KB', '{nFormatted} KiB' => '{nFormatted} KiB', - '{nFormatted} MB' => '{nFormatted} MB', + '{nFormatted} MB' => '{nFormatted} MB', '{nFormatted} MiB' => '{nFormatted} MiB', - '{nFormatted} PB' => '{nFormatted} PB', + '{nFormatted} PB' => '{nFormatted} PB', '{nFormatted} PiB' => '{nFormatted} PiB', - '{nFormatted} TB' => '{nFormatted} TB', + '{nFormatted} TB' => '{nFormatted} TB', '{nFormatted} TiB' => '{nFormatted} TiB', - '{nFormatted} {n, plural, =1{byte} other{bytes}}' => '{nFormatted} {n, plural, zero{baitu} one{baits} other{baiti}}', + '{nFormatted} {n, plural, =1{byte} other{bytes}}' => '{nFormatted} {n, plural, zero{baitu} one{baits} other{baiti}}', '{nFormatted} {n, plural, =1{gibibyte} other{gibibytes}}' => '{nFormatted} gibi{n, plural, zero{baitu} one{baits} other{baiti}}', '{nFormatted} {n, plural, =1{gigabyte} other{gigabytes}}' => '{nFormatted} giga{n, plural, zero{baitu} one{baits} other{baiti}}', '{nFormatted} {n, plural, =1{kibibyte} other{kibibytes}}' => '{nFormatted} kibi{n, plural, zero{baitu} one{baits} other{baiti}}', diff --git a/framework/messages/ms/yii.php b/framework/messages/ms/yii.php index 7ea2b0f..9acba8b 100644 --- a/framework/messages/ms/yii.php +++ b/framework/messages/ms/yii.php @@ -1,8 +1,14 @@ 'Halaman tidak dijumpai.', 'Please fix the following errors:' => 'Sila betulkan ralat berikut:', 'Please upload a file.' => 'Sila muat naik fail', - 'Showing {begin, number}-{end, number} of {totalCount, number} {totalCount, plural, one{item} other{items}}.' => - 'Memaparkan {begin, number}-{end, number} daripada {totalCount, number} {totalCount, plural, one{item} other{items}}.', + 'Showing {begin, number}-{end, number} of {totalCount, number} {totalCount, plural, one{item} other{items}}.' => 'Memaparkan {begin, number}-{end, number} daripada {totalCount, number} {totalCount, plural, one{item} other{items}}.', 'The file "{file}" is not an image.' => 'Fail ini "{file}" bukan berjenis gambar.', - 'The file "{file}" is too big. Its size cannot exceed {formattedLimit}.' => - 'Fail ini "{file}" terlalu besar. Saiz tidak boleh lebih besar daripada {formattedLimit}.', - 'The file "{file}" is too small. Its size cannot be smaller than {formattedLimit}.' => - 'Fail ini "{file}" terlalu kecil. Saiznya tidak boleh lebih kecil daripada {formattedLimit}.', + 'The file "{file}" is too big. Its size cannot exceed {formattedLimit}.' => 'Fail ini "{file}" terlalu besar. Saiz tidak boleh lebih besar daripada {formattedLimit}.', + 'The file "{file}" is too small. Its size cannot be smaller than {formattedLimit}.' => 'Fail ini "{file}" terlalu kecil. Saiznya tidak boleh lebih kecil daripada {formattedLimit}.', 'The format of {attribute} is invalid.' => 'Format untuk atribut ini {attribute} tidak sah.', - 'The image "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => - 'Gambar "{file}" terlalu panjang. Panjang gambar tidak boleh lebih besar daripada {limit, number} {limit, plural, one{pixel} other{pixels}}.', - 'The image "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => - 'Gambar "{file}" terlalu lebar. Gambar tidak boleh lebih lebar daripada {limit, number} {limit, plural, one{pixel} other{pixels}}.', - 'The image "{file}" is too small. The height cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => - 'Gambar "{file}" terlalu singkat. Panjang tidak boleh lebih singkat daripada {limit, number} {limit, plural, one{pixel} other{pixels}}.', - 'The image "{file}" is too small. The width cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => - 'Gambar "{file}" terlalu kecil. Lebar gambar tidak boleh kurang daripada {limit, number} {limit, plural, one{pixel} other{pixels}}.', + 'The image "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Gambar "{file}" terlalu panjang. Panjang gambar tidak boleh lebih besar daripada {limit, number} {limit, plural, one{pixel} other{pixels}}.', + 'The image "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Gambar "{file}" terlalu lebar. Gambar tidak boleh lebih lebar daripada {limit, number} {limit, plural, one{pixel} other{pixels}}.', + 'The image "{file}" is too small. The height cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Gambar "{file}" terlalu singkat. Panjang tidak boleh lebih singkat daripada {limit, number} {limit, plural, one{pixel} other{pixels}}.', + 'The image "{file}" is too small. The width cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Gambar "{file}" terlalu kecil. Lebar gambar tidak boleh kurang daripada {limit, number} {limit, plural, one{pixel} other{pixels}}.', 'The requested view "{name}" was not found.' => 'Paparan yang diminta "{name}" tidak dijumpai.', 'The verification code is incorrect.' => 'Kod penyesah tidak tepat.', 'Total {count, number} {count, plural, one{item} other{items}}.' => 'Jumlah {count, number} {count, plural, one{item} other{items}}.', @@ -60,8 +59,7 @@ return [ 'View' => 'Paparan', 'Yes' => 'Ya', 'You are not allowed to perform this action.' => 'Anda tidak dibenarkan untuk mengunakan fungsi ini.', - 'You can upload at most {limit, number} {limit, plural, one{file} other{files}}.' => - 'Anda boleh memuat naik tidak lebih daripada {limit, number} {limit, plural, one{file} other{files}}.', + 'You can upload at most {limit, number} {limit, plural, one{file} other{files}}.' => 'Anda boleh memuat naik tidak lebih daripada {limit, number} {limit, plural, one{file} other{files}}.', 'in {delta, plural, =1{a day} other{# days}}' => 'dalam {delta, plural, =1{a day} other{# days}}', 'in {delta, plural, =1{a minute} other{# minutes}}' => 'dalam {delta, plural, =1{a minute} other{# minutes}}', 'in {delta, plural, =1{a month} other{# months}}' => 'dalam {delta, plural, =1{a month} other{# months}}', @@ -88,12 +86,9 @@ return [ '{attribute} must be no less than {min}.' => '{attribute} tidak boleh kurang daripada {min}.', '{attribute} must be repeated exactly.' => '{attribute} mestilah diulang dengan tepat.', '{attribute} must not be equal to "{compareValue}".' => '{attribute} mestilah tidak sama dengan "{compareValue}".', - '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => - '{attribute} mesti mengandungi sekurang-kurangnya {min, number} {min, plural, one{character} other{characters}}.', - '{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.' => - '{attribute} mesti mengangungi paling banyak {max, number} {max, plural, one{character} other{characters}}.', - '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.' => - '{attribute} mesti mengandungi {length, number} {length, plural, one{character} other{characters}}.', + '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => '{attribute} mesti mengandungi sekurang-kurangnya {min, number} {min, plural, one{character} other{characters}}.', + '{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.' => '{attribute} mesti mengangungi paling banyak {max, number} {max, plural, one{character} other{characters}}.', + '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.' => '{attribute} mesti mengandungi {length, number} {length, plural, one{character} other{characters}}.', '{delta, plural, =1{a day} other{# days}} ago' => '{delta, plural, =1{a day} other{# days}} lalu', '{delta, plural, =1{a minute} other{# minutes}} ago' => '{delta, plural, =1{a minute} other{# minutes}} lalu', '{delta, plural, =1{a month} other{# months}} ago' => '{delta, plural, =1{a month} other{# months}} lalu', diff --git a/framework/messages/nb-NO/yii.php b/framework/messages/nb-NO/yii.php index dce67da..946d9f9 100644 --- a/framework/messages/nb-NO/yii.php +++ b/framework/messages/nb-NO/yii.php @@ -1,8 +1,14 @@ 'Zestawienie {values} dla {attributes} jest już w użyciu.', - 'Unknown alias: -{name}' => 'Nieznany alias: -{name}', + ' and ' => ' i ', '(not set)' => '(brak wartości)', 'An internal server error occurred.' => 'Wystąpił wewnętrzny błąd serwera.', 'Are you sure you want to delete this item?' => 'Czy na pewno usunąć ten element?', @@ -37,7 +42,9 @@ return [ 'Page not found.' => 'Nie odnaleziono strony.', 'Please fix the following errors:' => 'Proszę poprawić następujące błędy:', 'Please upload a file.' => 'Proszę wgrać plik.', + 'Powered by {yii}' => 'Powered by {yii}', 'Showing {begin, number}-{end, number} of {totalCount, number} {totalCount, plural, one{item} other{items}}.' => 'Wyświetlone {begin, number}-{end, number} z {totalCount, number} {totalCount, plural, one{rekordu} other{rekordów}}.', + 'The combination {values} of {attributes} has already been taken.' => 'Zestawienie {values} dla {attributes} jest już w użyciu.', 'The file "{file}" is not an image.' => 'Plik "{file}" nie jest obrazem.', 'The file "{file}" is too big. Its size cannot exceed {formattedLimit}.' => 'Plik "{file}" jest zbyt duży. Jego rozmiar nie może przekraczać {formattedLimit}.', 'The file "{file}" is too small. Its size cannot be smaller than {formattedLimit}.' => 'Plik "{file}" jest za mały. Jego rozmiar nie może być mniejszy niż {formattedLimit}.', @@ -50,10 +57,12 @@ return [ 'The verification code is incorrect.' => 'Kod weryfikacyjny jest nieprawidłowy.', 'Total {count, number} {count, plural, one{item} other{items}}.' => 'Razem {count, number} {count, plural, one{rekord} few{rekordy} many{rekordów} other{rekordu}}.', 'Unable to verify your data submission.' => 'Nie udało się zweryfikować przesłanych danych.', + 'Unknown alias: -{name}' => 'Nieznany alias: -{name}', 'Unknown option: --{name}' => 'Nieznana opcja: --{name}', 'Update' => 'Aktualizuj', 'View' => 'Zobacz szczegóły', 'Yes' => 'Tak', + 'Yii Framework' => 'Yii Framework', 'You are not allowed to perform this action.' => 'Brak upoważnienia do wykonania tej czynności.', 'You can upload at most {limit, number} {limit, plural, one{file} other{files}}.' => 'Możliwe wgranie najwyżej {limit, number} {limit, plural, one{pliku} few{plików} many{plików} other{pliku}}.', 'in {delta, plural, =1{a day} other{# days}}' => 'za {delta, plural, =1{jeden dzień} other{# dni}}', diff --git a/framework/messages/pt-BR/yii.php b/framework/messages/pt-BR/yii.php index 5b0cd0f..35d99eb 100644 --- a/framework/messages/pt-BR/yii.php +++ b/framework/messages/pt-BR/yii.php @@ -1,8 +1,14 @@ '{attribute} ne sme biti jednak "{compareValue}".', '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => '{attribute} treba da sadrži bar {min, number} {min, plural, one{karakter} other{karaktera}}.', '{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.' => '{attribute} treba da sadrži najviše {max, number} {max, plural, one{karakter} other{karaktera}}.', - '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.' => '{attribute} treba da sadrži {length, number} {length, plural, one{karakter} other{karaktera}}.' + '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.' => '{attribute} treba da sadrži {length, number} {length, plural, one{karakter} other{karaktera}}.', ]; diff --git a/framework/messages/sr/yii.php b/framework/messages/sr/yii.php index 288db91..61b461d 100644 --- a/framework/messages/sr/yii.php +++ b/framework/messages/sr/yii.php @@ -1,8 +1,14 @@ '{attribute} не сме бити једнак "{compareValue}".', '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => '{attribute} треба да садржи барем {min, number} {min, plural, one{карактер} other{карактера}}.', '{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.' => '{attribute} треба да садржи највише {max, number} {max, plural, one{карактер} other{карактера}}.', - '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.' => '{attribute} треба да садржи {length, number} {length, plural, one{карактер} other{карактера}}.' + '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.' => '{attribute} треба да садржи {length, number} {length, plural, one{карактер} other{карактера}}.', ]; diff --git a/framework/messages/sv/yii.php b/framework/messages/sv/yii.php index 4d5a43f..24416f7 100644 --- a/framework/messages/sv/yii.php +++ b/framework/messages/sv/yii.php @@ -1,8 +1,14 @@ __DIR__, // boolean, whether the message file should be overwritten with the merged messages 'overwrite' => true, + /* + // File header used in generated messages files + 'phpFileHeader' => '', + // PHPDoc used for array of messages with generated messages files + 'phpDocBlock' => null, + */ /* // Message categories to ignore diff --git a/tests/framework/behaviors/SluggableBehaviorTest.php b/tests/framework/behaviors/SluggableBehaviorTest.php index 858583d..094f01f 100644 --- a/tests/framework/behaviors/SluggableBehaviorTest.php +++ b/tests/framework/behaviors/SluggableBehaviorTest.php @@ -302,8 +302,8 @@ class SkipOnEmptySluggableActiveRecord extends ActiveRecordSluggable 'attribute' => 'name', 'slugAttribute' => 'slug', 'ensureUnique' => true, - 'skipOnEmpty' => true + 'skipOnEmpty' => true, ], ]; } -} \ No newline at end of file +} diff --git a/tests/framework/console/controllers/PHPMessageControllerTest.php b/tests/framework/console/controllers/PHPMessageControllerTest.php index c8a1fec..f4a2b90 100644 --- a/tests/framework/console/controllers/PHPMessageControllerTest.php +++ b/tests/framework/console/controllers/PHPMessageControllerTest.php @@ -42,6 +42,8 @@ class PHPMessageControllerTest extends BaseMessageControllerTest 'sourcePath' => $this->sourcePath, 'messagePath' => $this->messagePath, 'overwrite' => true, + 'phpFileHeader' => "/*file header*/\n", + 'phpDocBlock' => '/*doc block*/', ]; } @@ -92,4 +94,32 @@ class PHPMessageControllerTest extends BaseMessageControllerTest return require $messageFilePath; } + + // By default phpunit runs inherited test after inline tests, so `testCreateTranslation()` would be run after + // `testCustomFileHeaderAndDocBlock()` (that would break `@depends` annotation). This ensures that + // `testCreateTranslation() will be run before `testCustomFileHeaderAndDocBlock()`. + public function testCreateTranslation() + { + parent::testCreateTranslation(); + } + + /** + * @depends testCreateTranslation + */ + public function testCustomFileHeaderAndDocBlock() + { + $category = 'test_headers_category'; + $message = 'test message'; + $sourceFileContent = "Yii::t('{$category}', '{$message}');"; + $this->createSourceFile($sourceFileContent); + + $this->saveConfigFile($this->getConfig()); + $this->runMessageControllerAction('extract', [$this->configFileName]); + + $messageFilePath = $this->getMessageFilePath('test_headers_category'); + $content = file_get_contents($messageFilePath); + $head = substr($content, 0, strpos($content, 'return ')); + $expected = "assertSame($expected, $head); + } } diff --git a/tests/framework/db/ActiveRecordTest.php b/tests/framework/db/ActiveRecordTest.php index 1252fa5..434ea69 100644 --- a/tests/framework/db/ActiveRecordTest.php +++ b/tests/framework/db/ActiveRecordTest.php @@ -1505,5 +1505,4 @@ abstract class ActiveRecordTest extends DatabaseTestCase $this->assertEquals('Some {{updated}} name', $customer->name); $this->assertEquals('Some {{%updated}} address', $customer->address); } - } diff --git a/tests/framework/validators/ExistValidatorTest.php b/tests/framework/validators/ExistValidatorTest.php index b91ab41..e114f16 100644 --- a/tests/framework/validators/ExistValidatorTest.php +++ b/tests/framework/validators/ExistValidatorTest.php @@ -7,11 +7,9 @@ namespace yiiunit\framework\validators; -use Yii; use yii\base\Exception; use yii\validators\ExistValidator; use yiiunit\data\ar\ActiveRecord; -use yiiunit\data\ar\Document; use yiiunit\data\ar\Order; use yiiunit\data\ar\OrderItem; use yiiunit\data\validators\models\ValidatorTestMainModel; @@ -192,7 +190,7 @@ abstract class ExistValidatorTest extends DatabaseTestCase OrderItem::$tableName = $oldTableName; } - /** + /** * Test expresssion in targetAttribute * @see https://github.com/yiisoft/yii2/issues/14304 */