- $filename = $gettext_php_dir;
- if (substr($filename, -1) != '/')
- $filename .= '/';
- $filename .= $squirrelmail_language . '/LC_MESSAGES/' .
- $gettext_php_domain . '.po';
-
- $file = @fopen($filename, 'r');
- if ($file === false) {
- // Uh-ho -- we can't load the file. Just fake it. :-)
- // This is also for English, which doesn't use translations
- $gettext_php_loaded = true;
- $gettext_php_loaded_language = $squirrelmail_language;
- return;
- }
-
- $key = '';
- $SkipRead = false;
- while (! feof($file)) {
- if (! $SkipRead)
- $line = trim(fgets($file, 4096));
- else
- $SkipRead = false;
-
- 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)) {
- $key .= $match[1];
- $line = trim(fgets($file, 4096));
- }
- $SkipRead = true;
- } 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)) {
- $gettext_php_translateStrings[$key] .= $match[1];
- $line = trim(fgets($file, 4096));
- }
- $SkipRead = true;
- } else {
- // msgstr "string string"
- $gettext_php_translateStrings[$key] = $match[1];
- }
- $gettext_php_translateStrings[$key] =
- stripslashes($gettext_php_translateStrings[$key]);
- $key = '';
- }
- }
- fclose($file);