Fix gettext importer to correctly convert launchpad .po files

pull/1/head
thomascube 13 years ago
parent e31c56a5af
commit 6a41bef07d

@ -54,17 +54,18 @@ foreach ($out as $outfn => $texts) {
+-----------------------------------------------------------------------+ +-----------------------------------------------------------------------+
| Author: %-62s| | Author: %-62s|
+-----------------------------------------------------------------------+ +-----------------------------------------------------------------------+
@version $Id$ @version %s$
*/ */
$%s = array(); $%s = array();
EOF; EOF;
$output = sprintf($header, $lang, $varname.'.inc', date('Y'), $texts['_translator'], $varname); $output = sprintf($header, $lang, $varname.'.inc', date('Y'), $texts['_translator'], '$Id', $varname);
foreach ($texts as $label => $value) { foreach ($texts as $label => $value) {
if ($label[0] != '_') if (is_array($value)) { var_dump($outfn, $label, $value); exit; }
if ($label[0] != '_' && strlen($value))
$output .= sprintf("\$%s['%s'] = '%s';\n", $varname, $label, strtr(addcslashes($value, "'"), array("\r" => '', "\n" => '\n'))); $output .= sprintf("\$%s['%s'] = '%s';\n", $varname, $label, strtr(addcslashes($value, "'"), array("\r" => '', "\n" => '\n')));
} }
@ -95,7 +96,7 @@ function import_file($fn)
{ {
$out = array(); $out = array();
$lines = file($fn); $lines = file($fn);
$language = 'xx_XX'; $language = '';
$translator = ''; $translator = '';
$is_header = true; $is_header = true;
@ -163,7 +164,7 @@ function import_file($fn)
} }
} }
return $out; return $language ? $out : array();
} }
@ -177,14 +178,14 @@ function gettext_decode($str)
*/ */
function expand_langcode($lang) function expand_langcode($lang)
{ {
static $rcube_language_aliases; static $rcube_language_aliases, $rcube_languages;
if (!$rcube_language_aliases) if (!$rcube_language_aliases)
include(INSTALL_PATH . 'program/localization/index.inc'); include(INSTALL_PATH . 'program/localization/index.inc');
if ($rcube_language_aliases[$lang]) if ($rcube_language_aliases[$lang])
return $rcube_language_aliases[$lang]; return $rcube_language_aliases[$lang];
else if (strlen($lang) == 2) else if (strlen($lang) == 2 && !isset($rcube_languages[$lang]))
return strtolower($lang) . '_' . strtoupper($lang); return strtolower($lang) . '_' . strtoupper($lang);
else else
return $lang; return $lang;

Loading…
Cancel
Save