I’m a bit confused when it comes to Yii and i18n and l10n.
In the config/main.php I only can define a default language, but no country.
locale_id = lowercase(language + "_" + country);
But Yii mixes up languages and locales. Why? A language id is no locale id.
My case: A simple drop down with countries: "de", "at" and "ch".
The user chooses his country: “ch”. Ok. What’s next?
Shall I use Yii::app()->language="de_ch" ?
The Yii-core translation files are only available under the locale_id "de", so now every error message appears in english, instead of german. But as Switzerland has (partly) the same language, but other currency as germany I DO have to choose this way.
If I save the country separately in a session (or whatever) and it’ll look like this:
$country = Yii::app()->session['country'];
$language = Yii::app()->language;
… but the currency problem isn’t solved.
Very messy I think.
I’d suggest the following:
-
A user can set a locale, or a language and/or a country
-
If user sets a country and no language is defined or the actual language isn’t spoken in this country, use the default language of the selected country.
-
If user sets a language and there’s no country defined, or the language isn’t spoken in the actual country use a default country for this language.
-
User gets/sets the language by Yii::app()->language, the country by Yii::app()->country and the locale by Yii::app()->locale
-
Like in Zend: If there’s no country specific language file, use the default language file if(!file_exists(“de_at”)) use “de”
Would this be possible?