diff --git a/framework/yii/YiiBase.php b/framework/yii/YiiBase.php index d7b2bd6..ee75822 100644 --- a/framework/yii/YiiBase.php +++ b/framework/yii/YiiBase.php @@ -606,10 +606,7 @@ class YiiBase public static function t($category, $message, $params = array(), $language = null) { if (self::$app !== null) { - if ($language === null) { - $language = self::$app->language; - } - return self::$app->getI18N()->translate($category, $message, $language); + return self::$app->getI18N()->translate($category, $message, $params, $language ?: self::$app->language); } else { return is_array($params) ? strtr($message, $params) : $message; } diff --git a/framework/yii/i18n/I18N.php b/framework/yii/i18n/I18N.php index a358683..b929f49 100644 --- a/framework/yii/i18n/I18N.php +++ b/framework/yii/i18n/I18N.php @@ -78,16 +78,11 @@ class I18N extends Component * @param string $category the message category. * @param string $message the message to be translated. * @param array $params the parameters that will be used to replace the corresponding placeholders in the message. - * @param string $language the language code (e.g. `en_US`, `en`). If this is null, the current - * [[\yii\base\Application::language|application language]] will be used. + * @param string $language the language code (e.g. `en_US`, `en`). * @return string the translated message. */ - public function translate($category, $message, $params = array(), $language = null) + public function translate($category, $message, $params, $language) { - if ($language === null) { - $language = Yii::$app->language; - } - $message = $this->getMessageSource($category)->translate($category, $message, $language); if (!is_array($params)) {