Skip to content

Commit

Permalink
yii\console\controllers\MessageController now sorts created message…
Browse files Browse the repository at this point in the history
…s, even if there is no new one, while saving to PHP file
  • Loading branch information
klimov-paul committed May 13, 2015
1 parent 72ec914 commit adb0460
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Yii Framework 2 Change Log
-----------------------

- Bug #8322: `yii\behaviors\TimestampBehavior::touch()` now throws an exception if owner is new record (klimov-paul)
- Enh #8070: `yii\console\controllers\MessageController` now sorts created messages, even if there is no new one, while saving to PHP file (klimov-paul)
- Enh #8286: `yii\console\controllers\MessageController` improved allowing extraction of nested translator calls (klimov-paul)


Expand Down
6 changes: 4 additions & 2 deletions framework/console/controllers/MessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,15 @@ protected function saveMessagesToPHP($messages, $dirName, $overwrite, $removeUnu
protected function saveMessagesCategoryToPHP($messages, $fileName, $overwrite, $removeUnused, $sort, $category)
{
if (is_file($fileName)) {
$existingMessages = require($fileName);
$rawExistingMessages = require($fileName);
$existingMessages = $rawExistingMessages;
sort($messages);
ksort($existingMessages);
if (array_keys($existingMessages) == $messages) {
if (array_keys($existingMessages) === $messages && (!$sort || array_keys($rawExistingMessages) === $messages)) {
$this->stdout("Nothing new in \"$category\" category... Nothing to save.\n\n", Console::FG_GREEN);
return;
}
unset($rawExistingMessages);
$merged = [];
$untranslated = [];
foreach ($messages as $message) {
Expand Down

0 comments on commit adb0460

Please sign in to comment.