I18Nv2 - get locale from language/country

From: Date: Wed, 02 Mar 2005 16:06:23 +0000
Subject: I18Nv2 - get locale from language/country
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-36469@lists.php.net to get a copy of this message
Hi! Is it possible to get a locale from a given language and a given country? I need this for the date-format. I have two users: 1. $lang = 'en'; $country = 'GB'; 2. $lang = 'en'; $country = 'US'; Now I want to use: strftime('%x') For 'en_GB' this will output: 02/03/05 For 'en_US' this will output: 03/02/2005 In this example I could simply use: $locale = $lang.'_'.$country; setlocale (LC_TIME, $locale); echo strftime('%x'); But does this allways work, with all languages and countries in PEAR::I18Nv2? 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? kind regards Andreas

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