Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
38ccc9e7
Commit
38ccc9e7
authored
Oct 17, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #930: Added i18n docs about configuring message source
parent
eacfe0d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
2 deletions
+39
-2
i18n.md
docs/guide/i18n.md
+39
-2
No files found.
docs/guide/i18n.md
View file @
38ccc9e7
...
...
@@ -47,9 +47,46 @@ translation of the message from source language into target language. Message it
echo
\Yii
::
t
(
'app'
,
'This is a string to translate!'
);
```
Yii tries to load approprite translation from one of the message sources defined via
`i18n`
component configuration
.
Yii tries to load approprite translation from one of the message sources defined via
`i18n`
component configuration
:
TBD: https://github.com/yiisoft/yii2/issues/930
```
php
'components'
=>
array
(
// ...
'i18n'
=>
array
(
'translations'
=>
array
(
'app*'
=>
array
(
'class'
=>
'yii\i18n\PhpMessageSource'
,
//'basePath' => '@app/messages',
//'sourceLanguage' => 'en_US',
'fileMap'
=>
array
(
'app'
=>
'app.php'
,
'app/error'
=>
'error.php'
,
),
),
),
),
),
```
In the above
`app*`
is a pattern that specifies which categories are handled by the message source. In this case we're
handling everything that begins with
`app`
.
`class`
defines which message source is used. There following message sources are available:
-
PhpMessageSource that uses PHP files.
-
GettextMessageSource that uses GNU Gettext MO or PO files.
-
DbMessageSource that uses database.
`basePath`
defines where to store messages for the currently used message source. In this case it's
`messages`
directory
in your application directory. In case of using database this option should be skipped.
`sourceLanguage`
defines which language is used in
`\Yii::t`
second argument. If not specified, application's source
language is used.
`fileMap`
specifies how message categories specified in the first argument of
`\Yii::t()`
are mapped to files when
`PhpMessageSource`
is used. In the example we're defining two categories
`app`
and
`app/error`
.
Instead of configuring
`fileMap`
you can rely on convention which is
`messages/BasePath/LanguageID/CategoryName.php`
.
### Named placeholders
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment