From a6195f326a43a9c62f9f85efc8ff0861de9475e1 Mon Sep 17 00:00:00 2001 From: Filip Komar Date: Sun, 20 Apr 2014 16:32:11 +0000 Subject: conversion of mognase to gettext --- lib.php | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'lib.php') diff --git a/lib.php b/lib.php index e603380..f18d468 100644 --- a/lib.php +++ b/lib.php @@ -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 = <<