diff options
author | Filip Komar <filip@mageia.org> | 2014-04-20 16:32:11 +0000 |
---|---|---|
committer | Filip Komar <filip@mageia.org> | 2014-04-20 16:32:11 +0000 |
commit | a6195f326a43a9c62f9f85efc8ff0861de9475e1 (patch) | |
tree | 64e45ea8eea86c2e3fe50fe64cbf847dbe0d55a7 /lib.php | |
parent | 8331232b6f486bf32d110ac86de14614fce503ee (diff) | |
download | nav-a6195f326a43a9c62f9f85efc8ff0861de9475e1.tar nav-a6195f326a43a9c62f9f85efc8ff0861de9475e1.tar.gz nav-a6195f326a43a9c62f9f85efc8ff0861de9475e1.tar.bz2 nav-a6195f326a43a9c62f9f85efc8ff0861de9475e1.tar.xz nav-a6195f326a43a9c62f9f85efc8ff0861de9475e1.zip |
conversion of mognase to gettext
Diffstat (limited to 'lib.php')
-rw-r--r-- | lib.php | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -126,7 +126,7 @@ class NCache class l10n { - public static $t; +// public static $t; /** * Load langs/$lang.lang into global $_t array. @@ -143,37 +143,36 @@ class l10n if ($lang == 'en') return; - $lang_file = __DIR__ . '/langs/' . $lang . '.lang'; + $po_file = __DIR__ . '/langs/' . $lang . '.po'; $cache_file = __DIR__ . '/var/tmp/cache/nav_lang_' . $lang . '.php'; - $lang_ts = filemtime($lang_file); + $po_ts = filemtime($po_file); if (file_exists($cache_file)) { include $cache_file; - if ($_ts > $lang_ts) + if ($_ts > $po_ts) return; } - if (file_exists($lang_file)) { + if (file_exists($po_file)) { + $dictionary = phpmo_parse_po_file($po_file); - $f = file($lang_file); - - foreach ($f as $k => $v) { - - if (substr($v, 0, 1) == ';' - && !empty($f[$k+1])) - { - $_t[trim(substr($v, 1))] = trim($f[$k+1]); + foreach ($dictionary as $key => $value) { + if ($key != '') { + if ($value['msgstr'][0] != '') { + $_t[trim($key)] = trim($value['msgstr'][0]); + } else { + $_t[trim($key)] = trim($key); + } } } - // $_t_data = var_export($_t, true); $cache = <<<P <?php /**! Generated. Do not edit. */ -// filemtime($lang_file) -\$_ts = $lang_ts; +// filemtime($po_file) +\$_ts = $po_ts; // $lang strings global \$_t; |