mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
added doc about translating message.
This commit is contained in:
@ -7,12 +7,15 @@ where contribution is very welcome are documentation and framework messages.
|
|||||||
Framework messages
|
Framework messages
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
Framework has two types of messsages: exceptions that are intended to developer and are never translated and messages
|
Framework has two types of messages: exceptions that are intended to developer and are never translated and messages
|
||||||
that are actually visible to end user such as validation errors.
|
that are actually visible to end user such as validation errors.
|
||||||
|
|
||||||
In order to start with message translation:
|
In order to start with message translation:
|
||||||
|
|
||||||
1. Check `framework/messages/config.php` and make sure your language is listed in `languages`.
|
1. Check `framework/messages/config.php` and make sure your language is listed in `languages`. If not,
|
||||||
|
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 messages/config.php`.
|
2. Go to `framework` and run `yii message/extract messages/config.php`.
|
||||||
3. Translate messages in `framework/messages/your_language/yii.php`. Make sure file is saved using UTF-8 encoding.
|
3. Translate messages in `framework/messages/your_language/yii.php`. Make sure file is saved using UTF-8 encoding.
|
||||||
4. [Make a pull request](https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md).
|
4. [Make a pull request](https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md).
|
||||||
|
|||||||
@ -7,7 +7,7 @@ return [
|
|||||||
'messagePath' => __DIR__,
|
'messagePath' => __DIR__,
|
||||||
// array, required, list of language codes that the extracted messages
|
// array, required, list of language codes that the extracted messages
|
||||||
// should be translated to. For example, ['zh-CN', 'de'].
|
// should be translated to. For example, ['zh-CN', 'de'].
|
||||||
'languages' => ['ar', 'da', 'de', 'es', 'it', 'ja', 'pl', 'pt-BR', 'ro', 'ru', 'sr','sr-Latn', 'zh-CN'],
|
'languages' => ['ar', 'da', 'de', 'es', 'it', 'ja', 'pl', 'pt-BR', 'ro', 'ru', 'sr', 'sr-Latn', 'zh-CN'],
|
||||||
// string, the name of the function for translating messages.
|
// string, the name of the function for translating messages.
|
||||||
// Defaults to 'Yii::t'. This is used as a mark to find the messages to be
|
// 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
|
// translated. You may use a string for single function name or an array for
|
||||||
|
|||||||
Reference in New Issue
Block a user