Search code examples
phpyiiyii-extensionsyii-componentsyii2

yii2 framework message language


As you know in Yii2 the core messages are available in 26 languages. I want to change yii core message language to display validation message in my language.

I added this line to my config file:

'language' => 'fa_IR',

and also added this lines:

'i18n'=>[
            ...
                'yii'=>[
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => "@vendor/yiisoft/yii2/messages",
                    'sourceLanguage' => 'en_US',
                    'fileMap' => [
                        'yii'=>'yii.php',
                    ]
                ]
            ]
        ],

but core message shown in English. I only want to use framework message available with Yii2. For example in this path vendor/yiisoft/yii2/messages/fa_IR/yii.php

What is the best solution for this work.


Solution

  • Ohhhh it's my mistake. Language code is fa-IR but I set it fa_IR. I think all language code seperate by _ like 'sourceLanguage' => 'en_US', but it's different. Sorry all.