R
R
ryzhak2015-08-10 14:01:43
Yii
ryzhak, 2015-08-10 14:01:43

Why doesn't translation work in views in yii2?

In general, there is a yii2 advanced application template.
i18n configured. The translations work correctly in the
file , that is, this line will honestly translate "Home" to "Home" for me, depending on the language . But in the frontend/views/site/index.php file, the translations DO NOT work. This line still returns "Home" to me when switching from the English version to the Russian version of common/config/main.php:frontend/views/layouts/main.php
<?= Yii::t('frontend', 'Home'); ?>
<?= Yii::t('frontend', 'Home'); ?>

<?php
return [
    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
    'components' => [
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'i18n' => [
            'translations' => [
                'frontend*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@common/messages',
                ],
                'backend*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@common/messages',
                ],
            ],
        ],
    ],
];

Please tell me what could be wrong.
Thanks in advance

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