Re: I18Nv2 - get locale from language/country

From: Date: Wed, 02 Mar 2005 19:24:55 +0000
Subject: Re: I18Nv2 - get locale from language/country
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-36485@lists.php.net to get a copy of this message
Michael Wallner wrote:
$locale = &I18Nv2::createLocale($lang .'_'. $country); echo $locale->date();
But does this allways work, with all languages and countries in PEAR::I18Nv2?
As long as you're using locales which I18Nv2 knows of (only important for Windows -- or which are installed on your Linux machine) - yes.
How could I check if a locale is supported on a system?
Or what is the recommended way to get the correct locale? The value from Accept-Language HTTP-Header could be correct, but is not allways correct. The user must be able to change that. Most users do not know what a "locale" is. So I hope the combination of $lang and $country based on PEAR::I18Nv2 values could do the job. Is this correct?
Well... AFAIK IE even don't let one define ones locale, but uses the system locale...
That's right.
I suppose, negotiating the locale at the first visit, providing a drop-down or similar and storing the preferred language/locale in the session/db, to be common practice.
My problem is _what_ to provide in these drop-downs, so that every user understands what to do. At the moment I have a drop-down for the language of the software (for translation), and I have a drop-down for the country which belongs to the users address. But I have to avoid invalid combinations of these two values, if I use these as locale later. But this is not allways possible. If I am german and work for a company in United States, my selected language is "de" and my selected country is "US". So I get the locale "de_US", which is not valid I think ;-) So if this is common practice, what is the typical content of such drop-downs? Or do you know a good Example? Firefox uses something like: Language -------- [...] German [de] German/Germany [de_DE] German/Austria [de_AT] English [en] English/Great Britain [en_GB] English/United States [en_US] [...] But I don't like it so much for a web-application. kind regards Andreas

« previous php.pear.dev (#36485) next »