Answer the question
In order to leave comments, you need to log in
How to properly organize multilingualism in Yii2?
After reading the documentation and a couple of articles, I understood the following:
1. It is necessary to assign the main language (which is used in the source code of the dictionary files as an array key) and the target language (to which the translation will be made, specified as an array value). For example:
web.php file
<?php
return [
'sourceLanguage' => 'ru-RU',
'language' => 'en-US'
];
<?php
return [
'Текст' => 'Text'
];
\Yii::t('app', 'Текст');
Answer the question
In order to leave comments, you need to log in
In our bike, we use aliases so that in the first place we don’t write something like:
\Yii::t('app', 'Разлюбезная моя Елизавета Петровна! С этим письмом прилагаю свою любовь бла бла');
// instead use alias
\Yii::t('app', 'suhov_mail');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question