T
T
Theory Theory2020-08-31 07:10:57
Yii
Theory Theory, 2020-08-31 07:10:57

Why doesn't i18n work in yii2?

web.php:

'components' => [
    "language" => 'ru-RU',
    'i18n' => [
      'translations' => [
        'en2ru' => [
          'class' => 'yii\i18n\PhpMessageSource',
          'basePath' => '@app/messages',
          'sourceLanguage' => 'en',
        ],
      ],
    ],
]


messages/en2ru.php:
<?php 
return [ 
  "home" => "дом",
 ]


views/site/index.php: Finally I see home. I changed the language to ru-RU

<h1><?php echo \Yii::t('en2ru', 'home') ?></h1>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question