예제 #1
0
require_once './_demo.php';
require_once FREEBEER_BASE . '/lib/ISO639.php';
require_once FREEBEER_BASE . '/lib/ISO639/Alpha3.php';
require_once FREEBEER_BASE . '/lib/ISO639/Map.php';
require_once FREEBEER_BASE . '/lib/ISO3166.php';
require_once FREEBEER_BASE . '/lib/Locale.php';
require_once FREEBEER_BASE . '/lib/DateTime.php';
require_once FREEBEER_BASE . '/lib/Gettext.php';
require_once FREEBEER_BASE . '/lib/Debug.php';
//fbDebug::setLevel(FB_DEBUG_ALL);
echo html_header_demo('fbGettext Class (gettext() Emulation)');
echo "<pre>\n";
//echo 'setlocale(0, 0)=', setlocale(0, 0),"\n";
$default_locale = fbLocale::getLocale();
echo "fbLocale::getLocale()={$default_locale}\n";
$default_locale_name = fbLocale::getDefaultLocale();
echo "fbLocale::getLocaleName()={$default_locale_name}\n";
$rv = bindtextdomain('freebeer', FREEBEER_BASE . '/lib/locale');
printf("bindtextdomain('freebeer', '%s')=%s\n", FREEBEER_BASE . '/lib/locale', $rv);
$rv = textdomain('freebeer');
echo 'textdomain(\'freebeer\')=', $rv, "\n";
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();
예제 #2
0
파일: Locale.php 프로젝트: Artea/freebeer
 function getLocale($category = LC_ALL, $locale = null)
 {
     fbDebug::enter();
     assert('$category == LC_ALL   || $category == LC_COLLATE ||' . '$category == LC_CTYPE || $category == LC_MONETARY ||' . '$category == LC_NUMERIC  || $category == LC_TIME');
     fbDebug::dump($locale, '$locale');
     if (is_null($locale)) {
         $locale = fbLocale::_getLocale($category);
         fbDebug::dump($locale, '$locale');
         if (!$locale || $locale == 'C') {
             $locale = fbLocale::getDefaultLocale();
         }
         fbDebug::dump($locale, '$locale');
     }
     $_locale_cache =& fbLocale::_locale_cache();
     if (!isset($_locale_cache[$category][$locale])) {
         $a = fbLocale::_parseLocale($locale);
         fbDebug::dump($a, '$a');
         $iso_locale = $a['locale'];
         $_locale_cache[$category][$locale] = $a;
         $_locale_cache[$category][$iso_locale] = $a;
     }
     fbDebug::dump($_locale_cache, '$_locale_cache');
     $rv = $_locale_cache[$category][$locale]['locale'];
     fbDebug::leave($rv);
     return $rv;
 }