From 829a33b68436abfe9de8339c61531a61208e58c6 Mon Sep 17 00:00:00 2001 From: fidian Date: Thu, 26 Apr 2001 19:55:27 +0000 Subject: [PATCH] * Everything should be in the session now git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1316 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/gettext.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/functions/gettext.php b/functions/gettext.php index 7883fd8a..ba44942b 100644 --- a/functions/gettext.php +++ b/functions/gettext.php @@ -3,6 +3,8 @@ /* Alternate to the system's built-in gettext. * relies on .po files (can't read .mo easily). * Uses the session for caching (speed increase) + * Possible use in other PHP scripts? The only SM-specific thing is + * $sm_language, I think */ if (defined('gettext_php')) @@ -16,16 +18,28 @@ $gettext_php_loaded = false; session_register('gettext_php_loaded'); } - + if (! isset($gettext_php_domain)) { + $gettext_php_domain = ''; + session_register('gettext_php_translateStrings'); + } + if (! isset($gettext_php_dir)) { + $gettext_php_dir = ''; + session_register('gettext_php_translateStrings'); + } + if (! isset($gettext_php_translateStrings)) { + $gettext_php_translateStrings = array(); + session_register('gettext_php_translateStrings'); + } + function gettext_php_load_strings() { global $sm_language, $gettext_php_translateStrings, $gettext_php_domain, $gettext_php_dir, $gettext_php_loaded; // $sm_language gives 'en' for English, 'de' for German, etc. - // I didn't wanna use getenv or similar. + // I didn't wanna use getenv or similar, but you easily could change + // my code to do that. $gettext_php_translateStrings = array(); - session_register('gettext_php_translateStrings'); $filename = $gettext_php_dir; if (substr($filename, -1) != '/') @@ -34,6 +48,7 @@ $file = fopen($filename, 'r'); if ($file === false) + // Uh-ho return; $key = ''; @@ -47,6 +62,9 @@ if (ereg('^msgid "(.*)"$', $line, $match)) { if ($match[1] == '') { // Potential multi-line + // msgid "" + // "string string " + // "string string" $key = ''; $line = trim(fgets($file, 4096)); while (ereg('^[ ]*"(.*)"[ ]*$', $line, $match)) { @@ -54,11 +72,15 @@ $line = trim(fgets($file, 4096)); } } else { + // msgid "string string" $key = $match[1]; } } elseif (ereg('^msgstr "(.*)"$', $line, $match)) { if ($match[1] == '') { // Potential multi-line + // msgstr "" + // "string string " + // "string string" $gettext_php_translateStrings[$key] = ''; $line = trim(fgets($file, 4096)); while (ereg('^[ ]*"(.*)"[ ]*$', $line, $match)) { @@ -66,6 +88,7 @@ $line = trim(fgets($file, 4096)); } } else { + // msgstr "string string" $gettext_php_translateStrings[$key] = $match[1]; } $key = ''; -- 2.25.1