Zend_Locale
should be able to help, about that.
See the examples and explanations on the page Using Zend_Locale (quoting) :
For most situations, new
Zend_Locale()
will automatically
select the correct locale, with
preference given to information
provided by the user's web browser.
And there are a couple more details later on that page (quoting) :
The search algorithm used by
Zend_Locale
for automatic selection
of a locale uses three sources of
information:
1. const
Zend_Locale::BROWSER
- The user's Web
browser provides information with each
request, which is published by PHP in
the global variable
HTTP_ACCEPT_LANGUAGE
. if no matching
locale can be found, then preference
is given to ENVIRONMENT
and lastly
FRAMEWORK
.
2. const
Zend_Locale::ENVIRONMENT
- PHP
publishes the host server's locale via
the PHP internal function
setlocale()
. If no matching locale
can be found, then preference is given
to FRAMEWORK
and lastly BROWSER
.
3. const
Zend_Locale::FRAMEWORK
- When Zend
Framework has a standardized way of
specifying component defaults
(planned, but not yet available), then using this constant during
instantiation will give preference to
choosing a locale based on these
defaults. If no matching locale can be
found, then preference is given to
ENVIRONMENT
and lastly BROWSER
.
(Advice : go read that page -- I will not copy-paste everything there is to read ^^ )
Edit : And here's the portion of code that illustrates my comment :
$locale = new Zend_Locale();
var_dump($locale->getLanguage());
var_dump($locale->getRegion());
die;
Gives me :
string(2) "fr"
bool(false)
Well, my browser is asking for french, without specifying a region ^^