R
R
Ruslan Kasymov2015-03-13 08:46:59
Yii
Ruslan Kasymov, 2015-03-13 08:46:59

YII2 translations, what's wrong?

In config:
app/common/config/main.php

return [
    'sourceLanguage' => 'ru',
    'language' => 'kk',

    'components' => [
        'i18n' => [
            'translations' => [
                'app*' => [
                    'class' => 'yii\i18n\GettextMessageSource',
                    'basePath' => '@common/messages',
                    //'sourceLanguage' => 'en_US',
                    'fileMap' => array(
                        'app'=>'app.php',
                    )
                ],
            ],
        ],
    ]
]

Translation file
app/common/messages/kk/app.php
return [
  'Контакты' => 'Контакты - KAZ',
];

when called Unknown Property
Yii::t("app", "Контакты");
Error - yii\base\UnknownPropertyException Setting unknown property: yii\i18n\GettextMessageSource::fileMap

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vit, 2015-03-13
@HDAPache

You are trying to set the GettextMessageSource component's fileMap property. It does not have such a public property: www.yiiframework.com/doc-2.0/yii-i18n-gettextmessa...

R
Ruslan Kasymov, 2015-03-13
@HDAPache

I did as indicated here:
https://github.com/yiisoft/yii2/blob/master/docs/g...

'components' => [
    // ...
    'i18n' => [
        'translations' => [
            'app*' => [
                'class' => 'yii\i18n\PhpMessageSource',
                //'basePath' => '@app/messages',
                //'sourceLanguage' => 'en-US',
                'fileMap' => [
                    'app' => 'app.php',
                    'app/error' => 'error.php',
                ],
            ],
        ],
    ],
],

what about with this option
'translations' => [
                '*' => [
                    'class' => 'yii\i18n\GettextMessageSource',
                    'basePath' => '@common/messages',
                    //'sourceLanguage' => 'en_US',
                    'fileMap' => array(
                        'app'=>'app.php',
                    )
                ],
            ],

There are no errors and the translation does not work...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question