示例#1
0
文件: ChemDB.php 项目: labmai/chem-db
 public static function setup()
 {
     date_default_timezone_set(\Gini\Config::get('system.timezone') ?: 'Asia/Shanghai');
     class_exists('\\Gini\\Those');
     class_exists('\\Gini\\ThoseIndexed');
     isset($_GET['locale']) and $_SESSION['locale'] = $_GET['locale'];
     isset($_SESSION['locale']) and \Gini\Config::set('system.locale', $_SESSION['locale']);
     \Gini\I18N::setup();
     setlocale(LC_MONETARY, (\Gini\Config::get('system.locale') ?: 'zh_CN') . '.UTF-8');
 }
示例#2
0
 function T($fmt, $params = null)
 {
     if (!$fmt) {
         return $fmt;
     }
     if (is_array($fmt)) {
         $a = \Gini\I18N::stripContext($fmt[0]);
         //msgid
         $b = \Gini\I18N::stripContext($fmt[1]);
         //plural msgid
         $c = ngettext($fmt[0], $fmt[1], $fmt[2]);
         if ($c == $fmt[0] || $c == $fmt[1]) {
             $fmt = $fmt[2] == 1 ? $a : $b;
         } else {
             $fmt = $c;
         }
     } else {
         $a = \Gini\I18N::stripContext($fmt);
         $b = gettext($fmt);
         $fmt = $b == $fmt ? $a : $b;
     }
     return $params ? strtr($fmt, (array) $params) : $fmt;
 }
示例#3
0
 public function actionTest($args)
 {
     $l10n_path = $path . '/' . RAW_DIR . '/l10n';
     $locales = $args;
     foreach (glob($l10n_path . '/*.po') as $fname) {
         $locale = basename($fname, '.po');
         $locales[] = $locale;
     }
     foreach ($locales as $locale) {
         echo "locale = {$locale}\n";
         \Gini\I18N::setLocale($locale);
         echo '  Hello, world! => ' . T('Hello, world!') . "\n";
     }
 }