Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 281
b24 Avatar asked Jul 18 '14 05:07

b24


People also ask

What language is Yii?

Yii is a high-performance, component-based PHP framework for developing large-scale Web applications rapidly. It enables maximum reusability in Web programming and can significantly accelerate your Web application development process. The name Yii (pronounced Yee or [ji:] ) is an acroynym for "Yes It Is!".

What is yii:: t()?

The Yii::t() method will call the i18n application component translate method to perform the actual translation work.


1 Answers

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.

like image 63
b24 Avatar answered Oct 19 '22 16:10

b24