Exemplo n.º 1
0
function smarty_block_tr($params, $content, &$smarty)
{
    global $_SERVER;
    // < 4.1.0
    static $init;
    static $default_languages = false;
    if (!$init) {
        $init = true;
        fbGettext::init();
        if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
            $default_languages =& fbLocale::parseAcceptLanguages($_SERVER['HTTP_ACCEPT_LANGUAGE']);
        }
    }
    $lang = false;
    extract($params);
    if ($lang) {
        $languages =& fbLocale::parseAcceptLanguages($lang);
    } else {
        $languages = $default_languages;
    }
    /// \todo only switch locales if the current locale is different!
    fbLocale::pushLocale(LC_ALL, $languages);
    $rv = gettext($content);
    fbLocale::popLocale(LC_ALL);
    return $rv;
}
Exemplo n.º 2
0
        if (function_exists('money_format')) {
            $money = money_format('%i', $amount) . "<br />\n" . money_format('%n', $amount);
        }
        $charset = fbLocale::getCharset();
        $codepage = fbLocale::getCodepage();
        $long_month_names = join(',', fbDateTime::getLongMonthNames());
        $short_month_names = join(',', fbDateTime::getShortMonthNames());
        $long_weekday_names = join(',', fbDateTime::getLongWeekdayNames());
        $short_weekday_names = join(',', fbDateTime::getShortWeekdayNames());
        $long_month_names_hash[$long_month_names][$locale] = $locale_name;
        $long_weekday_names_hash[$long_weekday_names][$locale] = $locale_name;
    } else {
        //		$locale_name	= '&nbsp;';
    }
    print "<tr>\n<td>\n{$name}\n<br />\nlocale={$locale}\n<br />\nrv={$rv}\n<br />\nlocale_name={$locale_name}\n&nbsp;\n</td>\n<td>\n{$string}\n&nbsp;\n</td>\n<td>\n{$long_date}\n&nbsp;\n</td>\n<td>\n{$short_date}\n&nbsp;\n</td>\n<td>\n{$datetime}\n&nbsp;\n</td>\n<td>\n{$number}\n&nbsp;\n</td>\n<td>\n{$money}\n&nbsp;\n</td>\n<td>\n{$long_month_names}\n&nbsp;\n</td>\n<td>\n{$short_month_names}\n&nbsp;\n</td>\n<td>\n{$long_weekday_names}\n&nbsp;\n</td>\n<td>\n{$short_weekday_names}\n&nbsp;\n</td>\n<td>\n{$locale_name}\n&nbsp;\n</td>\n<td>\n{$charset}\n&nbsp;\n</td>\n<td>\n{$codepage}\n&nbsp;\n</td>\n</tr>\n";
    fbLocale::popLocale(LC_ALL);
    /////////////////////////
    //break;
    /////////////////////////
}
echo "</table>\n";
/*
echo 'fbLocale::getLongMonthNames()=';
print_r(fbLocale::getLongMonthNames());
echo 'fbLocale::getShortMonthNames()=';
print_r(fbLocale::getShortMonthNames());
echo 'fbLocale::getLongWeekdayNames()=';
print_r(fbLocale::getLongWeekdayNames());
echo 'fbLocale::getShortWeekdayNames()=';
print_r(fbLocale::getShortWeekdayNames());
*/
Exemplo n.º 3
0
 function _getDateNames($format, $locale = null)
 {
     static $rv = array();
     $get_locale = is_null($locale);
     if ($get_locale) {
         $locale = fbLocale::getLocale(LC_TIME);
     }
     if (!isset($rv[$locale])) {
         if (!$get_locale) {
             fbLocale::pushLocale(LC_TIME, $locale);
         }
         $t = array();
         for ($i = 0; $i < 12; ++$i) {
             $date = mktime(0, 0, 0, 1 + $i, 1, 2003);
             $t['B'][] = strftime('%B', $date);
             $t['b'][] = strftime('%b', $date);
         }
         for ($i = 0; $i < 7; ++$i) {
             $date = mktime(0, 0, 0, 11, 9 + $i, 2003);
             // 9-Nov-2003 was a Sunday
             $t['A'][] = strftime('%A', $date);
             $t['a'][] = strftime('%a', $date);
         }
         $rv[$locale] = $t;
         if (!$get_locale) {
             fbLocale::popLocale(LC_TIME);
         }
     }
     return $rv[$locale][$format];
 }
Exemplo n.º 4
0
 function numberFormat($number, $digits = null, $locale = null)
 {
     fbDebug::enter();
     static $localeconv_cache = array();
     $get_locale = is_null($locale);
     fbDebug::dump($get_locale, '$get_locale');
     if ($get_locale) {
         $locale = fbLocale::getLocale(LC_MONETARY);
         fbDebug::dump($locale, '$locale');
     }
     fbDebug::dump($localeconv_cache, '$localeconv_cache');
     if (!isset($localeconv_cache[$locale])) {
         fbDebug::dump($locale, '$locale');
         if (!$get_locale) {
             $rv = fbLocale::pushLocale(LC_MONETARY, $locale);
             fbDebug::dump($rv, '$rv');
         }
         $_locale = fbLocale::getLocale(LC_MONETARY);
         fbDebug::dump($_locale, '$_locale');
         $localeconv_cache[$locale] = localeconv();
         fbDebug::dump($localeconv_cache[$locale], '$localeconv_cache[$locale]');
         if (!$get_locale) {
             fbLocale::popLocale(LC_MONETARY);
         }
     }
     $lc = $localeconv_cache[$locale];
     fbDebug::dump($lc, '$lc');
     if (is_null($digits)) {
         $digits = $lc['int_frac_digits'];
     }
     $rv = number_format($number, $digits, $lc['mon_decimal_point'], $lc['mon_thousands_sep']);
     $n = strpos($rv, '-');
     if ($n !== false) {
         $rv = str_replace('-', $lc['negative_sign'], $rv);
     }
     fbDebug::leave($rv);
     return $rv;
 }