[Internationalization] sourceLanguage don't accept 'en-US' but accept 'en'

Hi,

I’m using Locale and Language. Here i’m read the guide and use like this:


return [

    // set target language to be Russian

    'language' => 'ru-RU',

    

    // set source language to be English

    'sourceLanguage' => 'en-US',

    

    ......

];

when i use


'sourceLanguage' => 'en-US' translete is not work

. but when i use


'sourceLanguage' => 'en',

translate is works.

My translate document is in: "…\common\messages\en-US\general.php"

I don’t understand why. Is anyone know this?

Thanks…

Why do you have translations in your source language?

I have translation english => english like this:


'dont have permission'  => 'You don\'t have permission for this page.',

because when i want to use russian i don’t want to write


'You don\'t have permission for this page.'  => 'У вас нет разрешения на этой странице.',

i just write:


'dont have permission'  => 'У вас нет разрешения на этой странице.',

on the other hand i dont want to wirte my function:


\Yii::t('general','You don\'t have permission for this page.')

i just want to use this:


\Yii::t('general','dont have permission')

When i want cahnge language i’m use:


\Yii::$app->language = 'en-US'

Or when i write


'language' => 'ru-RU',

in main.php i can use russian language.

everything is works fine but why


'sourceLanguage' => 'en-US'

not work


'sourceLanguage' => 'en'

is work.

I’m write because i lost a time to found this. Maybe needs to cahange guide example or maybe i make a mistake somewhere to using Internationalization.

Yii won’t translate from source language to identical target language by default. Would be a waste of performance.

You need this:

http://www.yiiframework.com/doc-2.0/yii-i18n-messagesource.html#$forceTranslation-detail

Thanks! :)