From c7d84390723771b97e2e41e793d9a5500a05d3f7 Mon Sep 17 00:00:00 2001 From: Alexander Makarov <sam@rmcreative.ru> Date: Sun, 8 Jun 2014 02:38:32 +0400 Subject: [PATCH] Fixes #3687: Default `sourceLanguage` and `language` are now `en-US` in order for i18n formatter to work correctly --- docs/guide/structure-applications.md | 4 ++-- docs/guide/tutorial-i18n.md | 8 ++++---- extensions/jui/DatePicker.php | 2 +- framework/CHANGELOG.md | 1 + framework/base/Application.php | 4 ++-- framework/i18n/I18N.php | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/guide/structure-applications.md b/docs/guide/structure-applications.md index 6706b15..329e682 100644 --- a/docs/guide/structure-applications.md +++ b/docs/guide/structure-applications.md @@ -325,8 +325,8 @@ without touching any dependent code. #### [[yii\base\Application::sourceLanguage|sourceLanguage]] <a name="sourceLanguage"></a> -This property specifies the language that the application code is written in. The default value is `'en'`, -meaning English. You should configure this property if the text content in your code is not in English. +This property specifies the language that the application code is written in. The default value is `'en-US'`, +meaning English (United States). You should configure this property if the text content in your code is not in English. Like the [language](#language) property, you should configure this property in terms of an [IETF language tag](http://en.wikipedia.org/wiki/IETF_language_tag). For example, `en` stands for English, diff --git a/docs/guide/tutorial-i18n.md b/docs/guide/tutorial-i18n.md index dd66a39..967d7f7 100644 --- a/docs/guide/tutorial-i18n.md +++ b/docs/guide/tutorial-i18n.md @@ -70,7 +70,7 @@ Yii tries to load appropriate translation from one of the message sources define 'app*' => [ 'class' => 'yii\i18n\PhpMessageSource', //'basePath' => '@app/messages', - //'sourceLanguage' => 'en', + //'sourceLanguage' => 'en-US', 'fileMap' => [ 'app' => 'app.php', 'app/error' => 'error.php', @@ -323,7 +323,7 @@ class Module extends \yii\base\Module { Yii::$app->i18n->translations['modules/users/*'] = [ 'class' => 'yii\i18n\PhpMessageSource', - 'sourceLanguage' => 'en', + 'sourceLanguage' => 'en-US', 'basePath' => '@app/modules/users/messages', 'fileMap' => [ 'modules/users/validation' => 'validation.php', @@ -370,7 +370,7 @@ class Menu extends Widget $i18n = Yii::$app->i18n; $i18n->translations['widgets/menu/*'] = [ 'class' => 'yii\i18n\PhpMessageSource', - 'sourceLanguage' => 'en', + 'sourceLanguage' => 'en-US', 'basePath' => '@app/widgets/menu/messages', 'fileMap' => [ 'widgets/menu/messages' => 'messages.php', @@ -407,7 +407,7 @@ Sometimes you want to correct default framework message translation for your app 'translations' => [ 'yii' => [ 'class' => 'yii\i18n\PhpMessageSource', - 'sourceLanguage' => 'en', + 'sourceLanguage' => 'en-US', 'basePath' => '/path/to/my/message/files' ], ], diff --git a/extensions/jui/DatePicker.php b/extensions/jui/DatePicker.php index 9360a22..550b6c2 100644 --- a/extensions/jui/DatePicker.php +++ b/extensions/jui/DatePicker.php @@ -79,7 +79,7 @@ class DatePicker extends InputWidget echo $this->renderWidget() . "\n"; $containerID = $this->inline ? $this->containerOptions['id'] : $this->options['id']; $language = $this->language ? $this->language : Yii::$app->language; - if ($language != 'en') { + if ($language != 'en-US') { $view = $this->getView(); DatePickerRegionalAsset::register($view); diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 1b91b60..74f8abd 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -94,6 +94,7 @@ Yii Framework 2 Change Log - Chg #3383: Added `$type` parameter to `IdentityInterface::findIdentityByAccessToken()` (qiangxue) - Chg #3531: \yii\grid\GridView now allows any character (except ":") in the attribute part of the shorthand syntax for columns (rawtaz) - Chg #3544: Added `$key` as a parameter to the callable specified via `yii\grid\DataColumn::value` (mdmunir) +- Chg #3687: Default `sourceLanguage` and `language` are now `en-US` in order for i18n formatter to work correctly (samdark) - Chg: Replaced `clearAll()` and `clearAllAssignments()` in `yii\rbac\ManagerInterface` with `removeAll()`, `removeAllRoles()`, `removeAllPermissions()`, `removeAllRules()` and `removeAllAssignments()` (qiangxue) - Chg: Added `$user` as the first parameter of `yii\rbac\Rule::execute()` (qiangxue) - Chg: `yii\grid\DataColumn::getDataCellValue()` visibility is now `public` to allow accessing the value from a GridView directly (cebe) diff --git a/framework/base/Application.php b/framework/base/Application.php index 8074d79..73eda02 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -106,13 +106,13 @@ abstract class Application extends Module * for English, while `en-US` stands for English (United States). * @see sourceLanguage */ - public $language = 'en'; + public $language = 'en-US'; /** * @var string the language that the application is written in. This mainly refers to * the language that the messages and view files are written in. * @see language */ - public $sourceLanguage = 'en'; + public $sourceLanguage = 'en-US'; /** * @var Controller the currently active controller instance */ diff --git a/framework/i18n/I18N.php b/framework/i18n/I18N.php index 2b1130f..f9bfc8f 100644 --- a/framework/i18n/I18N.php +++ b/framework/i18n/I18N.php @@ -57,7 +57,7 @@ class I18N extends Component if (!isset($this->translations['yii']) && !isset($this->translations['yii*'])) { $this->translations['yii'] = [ 'class' => 'yii\i18n\PhpMessageSource', - 'sourceLanguage' => 'en', + 'sourceLanguage' => 'en-US', 'basePath' => '@yii/messages', ]; } -- libgit2 0.27.1