Ejemplo n.º 1
0
}
function resetlocale()
{
    setlocale(LC_ALL, 'C');
    setlocale(LC_ALL, '');
    //setlocale(LC_ALL, 'usa');
    //setlocale(LC_ALL, 'us');
    //setlocale(LC_ALL, 'en_US');
}
resetlocale();
$default_locale = setlocale(LC_ALL, 0);
echo "default_locale={$default_locale}\n";
$date = time();
$supported_locales = array();
echo "setlocale('two letter code')\n\n";
$id2_language_hash = fbISO639::getIDToNameHash();
foreach ($id2_language_hash as $id2 => $language) {
    $locale = strtolower($id2);
    while (true) {
        $rv = setlocale(LC_ALL, $locale);
        if ($rv) {
            break;
        }
        $iso3166 = fbISO639_ISO3166_Map::getCountryID($id2);
        $locale = strtolower($id2) . '_' . strtoupper($iso3166);
        $rv = setlocale(LC_ALL, $locale);
        if ($rv) {
            break;
        }
        $locale = strtolower($id2) . '_' . strtoupper($id2);
        $rv = setlocale(LC_ALL, $locale);
Ejemplo n.º 2
0
 function getLocalizedLanguageName($id)
 {
     $ID_TO_LOCALIZED_NAME_HASH =& fbISO639::getIDToLocalizedNameHash();
     /// \todo make multibyte saavy
     $id = fbString::strtoupper($id);
     return isset($ID_TO_LOCALIZED_NAME_HASH[$id]) ? $ID_TO_LOCALIZED_NAME_HASH[$id] : false;
 }
Ejemplo n.º 3
0
 function _setLocaleWindows($category, $locale)
 {
     fbDebug::enter();
     static $locale_cache = array();
     if (isset($locale_cache[$locale])) {
         return fbLocale::_setLocale($category, $locale_cache[$locale]);
     }
     $language_id2 = $locale;
     if (preg_match('/^([^_]+)_(.*)$/', $locale, $matches)) {
         $language_id2 = $matches[1];
         $country_id2 = $matches[2];
     }
     fbDebug::dump($language_id2, '$language_id2');
     do {
         // get the full language name for the ISO 639 2 character language code
         $language_name = fbISO639::getLanguageName($language_id2);
         fbDebug::dump($language_name, '$language_name');
         if (!$language_id2) {
             // if it's not a valid language, then try the locale and return
             $rv = fbLocale::_setLocale($category, $locale);
             break;
         }
         // first, try the full language name
         $rv = fbLocale::_setLocale($category, $language_name);
         if ($rv) {
             break;
         }
         $language_id3 = fbISO639_Alpha3::getLanguageID($language_name);
         fbDebug::dump($language_id3, '$language_id3');
         if (!$language_id3) {
             $rv = fbLocale::_setLocale($category, $locale);
             break;
         }
         // next, try the ISO 639 3 character language code
         $rv = fbLocale::_setLocale($category, $language_id3);
         if ($rv) {
             break;
         }
         // next, try the ISO 639 2 character language code
         $rv = fbLocale::_setLocale($category, $language_id2);
         if ($rv) {
             break;
         }
         // finally, try the original locale
         $rv = fbLocale::_setLocale($category, $locale);
     } while (false);
     $locale_cache[$locale] = $rv;
     fbDebug::leave($rv);
     return $rv;
 }
Ejemplo n.º 4
0
print "<table border='1'>\n<tr>\n<th>\nISO Code\n</th>\n<th>\n_('24 hours')\n</th>\n<th>\nLong Date\n</th>\n<th>\nShort Date\n</th>\n<th>\nDate/Time\n</th>\n<th>\nNumber\n</th>\n<th>\nMoney\n</th>\n<th>\nLong Month Names\n</th>\n<th>\nShort Month Names\n</th>\n<th>\nLong Weekday Names\n</th>\n<th>\nShort Weekday Names\n</th>\n<th>\nLocale\n</th>\n<th>\nCharset\n</th>\n<th>\nCode Page\n</th>\n</tr>\n";
$date = mktime(13, 14, 15, 2, 1, 2003);
//$locales = &fbLocaleWindows::mimeToWindowsLocaleMap();
$locales = fbLocale::getAvailableLocales();
$locales[$default_locale] = $default_locale_name;
$locales['en_US'] = 'English.United States';
$locales['en_GB'] = 'English.United Kingdom';
ksort($locales);
$long_month_names_hash = array();
$long_weekday_names_hash = array();
foreach ($locales as $locale => $language) {
    $rv = fbLocale::pushLocale(LC_ALL, $locale);
    //echo "fbLocale::pushLocale(LC_ALL, $locale) returned '$rv'\n";
    $name = $locale;
    $language_id = substr($locale, 0, 2);
    $language = fbISO639::getLanguageName($language_id);
    $country_id = substr($locale, 3, 2);
    $country = fbISO3166::getCountryName($country_id);
    $id3 = fbISO639_Map::getID3($language_id);
    $language3 = fbISO639_Alpha3::getLanguageName($id3);
    $name .= " ({$language}";
    if ($language3 != $language) {
        $name .= ' [' . $language3 . ']';
    }
    $name .= "/{$country}/{$id3})";
    $string = '<i>Unavailable</i>';
    $long_date = '';
    $short_date = '';
    $datetime = '';
    $number = '';
    $money = '';
Ejemplo n.º 5
0
 function test_getlocalizedlanguagename_1()
 {
     $h = fbISO639::getidtolocalizednamehash();
     foreach ($h as $id => $name) {
         $id = strtoupper($id);
         $rv = fbISO639::getLocalizedLanguageName($id);
         $this->assertEquals($name, $rv, "id={$id}");
     }
 }