You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.3 KiB
62 lines
1.3 KiB
<?php
|
|
|
|
exec ('locale -a | sort -u', $locales);
|
|
$locale = 'C';
|
|
|
|
/*
|
|
* First find the browser encoding and try to create a valid locale
|
|
* from one of the supported browser encodings. Start with the most
|
|
* preferred encoding.
|
|
*/
|
|
$langs = explode (",", $_SERVER[HTTP_ACCEPT_LANGUAGE]);
|
|
|
|
foreach ($langs as $lang)
|
|
{
|
|
preg_match("/^([a-z]{2})(-([a-zA-Z]{2})){0,1}(;q=([0-9].[0-9])){0,1}$/",
|
|
$lang, $lng_pref);
|
|
|
|
$la = $lng_pref[1];
|
|
if (isset ($lng_pref[3]) && $lng_pref[3] !== "")
|
|
$co = '_' . strtoupper ($lng_pref[3]);
|
|
else
|
|
$co = '';
|
|
if (isset ($lng_pref[5]) && $lng_pref[5] !== "")
|
|
$pr = $lng_pref[5];
|
|
else
|
|
$pr = 1.0;
|
|
|
|
if ($co != "US")
|
|
$la_specs[$la . $co] = $pr;
|
|
else
|
|
$la_specs["POSIX"]=$pr;
|
|
}
|
|
array_multisort ($la_specs, SORT_DESC, SORT_NUMERIC);
|
|
|
|
/*
|
|
* Set locale and initialize gettext catalogs
|
|
*/
|
|
foreach ($la_specs as $key => $value)
|
|
{
|
|
foreach ($locales as $l)
|
|
{
|
|
if (isset ($key) && "" !== $key && strpos ($l, $key) !== FALSE)
|
|
{
|
|
$locale = $l;
|
|
break;
|
|
}
|
|
}
|
|
if ('C' !== $locale) break;
|
|
}
|
|
|
|
$l = setlocale (LC_MESSAGES, $locale);
|
|
if ($l !== $locale)
|
|
{
|
|
$locale = 'C';
|
|
setlocale (LC_MESSAGES, $locale);
|
|
}
|
|
setlocale (LC_TIME, $locale);
|
|
bindtextdomain ("bilder", LOCALEDIR);
|
|
bind_textdomain_codeset ("bilder", "UTF-8");
|
|
textdomain ("bilder");
|
|
|
|
?>
|