mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 13:58:55 +08:00
Fix #18988: Fix default value of yii\console\controllers\MessageController::$translator
This commit is contained in:
@ -27,7 +27,7 @@ Yii Framework 2 Change Log
|
||||
- Bug #18913: Add filename validation for `MessageSource::getMessageFilePath()` (uaoleg)
|
||||
- Bug #18909: Fix bug with binding default action parameters for controllers (bizley)
|
||||
- Bug #18955: Check `yiisoft/yii2-swiftmailer` before using as default mailer in `yii\base\Application` (WinterSilence)
|
||||
- Enh #18962: Extend ignore list in `yii\console\MessageController::$except` (WinterSilence)
|
||||
- Bug #18988: Fix default value of `yii\console\controllers\MessageController::$translator` (WinterSilence)
|
||||
|
||||
|
||||
2.0.43 August 09, 2021
|
||||
|
||||
@ -58,12 +58,11 @@ class MessageController extends \yii\console\Controller
|
||||
*/
|
||||
public $languages = [];
|
||||
/**
|
||||
* @var string|array 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.
|
||||
* @var string|string[] the name of the function for translating messages.
|
||||
* 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.
|
||||
*/
|
||||
public $translator = 'Yii::t';
|
||||
public $translator = ['Yii::t', '\Yii::t'];
|
||||
/**
|
||||
* @var bool whether to sort messages by keys when merging new messages
|
||||
* with the existing ones. Defaults to false, which means the new (untranslated)
|
||||
|
||||
@ -170,7 +170,8 @@ abstract class BaseMessageControllerTest extends TestCase
|
||||
{
|
||||
$category = 'test.category1';
|
||||
$message = 'test message';
|
||||
$sourceFileContent = "Yii::t('{$category}', '{$message}');";
|
||||
$message2 = 'test message 2';
|
||||
$sourceFileContent = "Yii::t('{$category}', '{$message}');\n\Yii::t('{$category}', '{$message2}');";
|
||||
$this->createSourceFile($sourceFileContent);
|
||||
|
||||
$this->saveConfigFile($this->getConfig());
|
||||
@ -178,6 +179,7 @@ abstract class BaseMessageControllerTest extends TestCase
|
||||
|
||||
$messages = $this->loadMessages($category);
|
||||
$this->assertArrayHasKey($message, $messages, "\"$message\" is missing in translation file. Command output:\n\n" . $out);
|
||||
$this->assertArrayHasKey($message2, $messages, "\"$message2\" is missing in translation file. Command output:\n\n" . $out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user