Translation: system messages and Locale ID


from the documentation you can read:

So in your config file you may set:

'sourceLanguage' => 'en_us',

And then do:


to set it to Italian language.

If I’m right, this should define both localization and internationalization so I should be able to get system messages in italian and also other information like date format and currency.

So for example if I want to have italian language for Switzerland, that doesn’t uses the Euro, I should set it to “it_ch”…

But using the locale id in the LanguageID_RegionID format leads to the problem that the system messages are mainly using only the "LanguageID" format… (in the framework "messages/" folder)

And if using the getPreferredLanguage() method, I could get the Locale ID (from my browser) in the LanguageID_RegionID format (“it_it”) but then, in order to have system messages to work, I’d have to do something like this:

$language =Yii::app()->request->getPreferredLanguage();

$language = substr($language, 0, 2);


…to grab only the LanguageID part…

but in this way I would loose the information about the “RegionID” so it won’t work for Switzerland (it_ch), right?

So my question is: is there a way to keep the locale id in the LanguageID_RegionID and at the same time grab the translations only in the LanguageID format?





am I the only one facing this “problem”? :rolleyes:



Yep, that seems to be a problem. I think there should be some kind of fall back mechanism so in case when a directory with full canonical locale_language is missing, language directory is searched for. Try to fill a future request maybe.


++ for this issue. I’ve been asking myself if it was just me, but it is not!

Did you file a request. Ideally the fallback would be to look in <language>_<region> first and if missing there, look in <language>.