This question already has an answer here:
- Yii2 translation does not work 1 answer
How to create multilanguage app in yii2?
Is there any preinstall message in yii2?
config:
'language' => 'es',
'components' => [
'i18n' => [
'translations' => [
'app*' => [
'class' => 'yii\i18n\PhpMessageSource',
//'basePath' => '@app/messages',
'sourceLanguage' => 'ru-RU',
'fileMap' => [
'app' => 'app.php',
'app/error' => 'error.php',
],
],
],
],
view :
echo \Yii::t('app', 'I am a message!');
$username = 'Alexander';
echo \Yii::t('app', 'Hello, {username}!', [
'username' => $username,
]);
Try this:
Edit config.php in frontend or backend
create
app.php
infrontend/messages/ru/app.php
orbackend/messages/ru/app.php
View: