| | |
| | | #!/usr/bin/env php |
| | | <?php |
| | | /* |
| | | |
| | | +-----------------------------------------------------------------------+ |
| | | | bin/importgettext.sh | |
| | | | | |
| | |
| | | +-----------------------------------------------------------------------+ |
| | | | Author: Thomas Bruederli <roundcube@gmail.com> | |
| | | +-----------------------------------------------------------------------+ |
| | | |
| | | $Id$ |
| | | |
| | | */ |
| | | |
| | | define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' ); |
| | | define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' ); |
| | | require INSTALL_PATH.'program/include/clisetup.php'; |
| | | |
| | | if ($argc < 2) { |
| | |
| | | foreach ($out as $outfn => $texts) { |
| | | $lang = preg_match('!/([a-z]{2}(_[A-Z]{2})?)[./]!', $outfn, $m) ? $m[1] : ''; |
| | | $varname = strpos($outfn, 'messages.inc') !== false ? 'messages' : 'labels'; |
| | | |
| | | |
| | | $header = <<<EOF |
| | | <?php |
| | | |
| | |
| | | +-----------------------------------------------------------------------+ |
| | | | Author: %-62s| |
| | | +-----------------------------------------------------------------------+ |
| | | @version %s$ |
| | | */ |
| | | |
| | | $%s = array(); |
| | | |
| | | EOF; |
| | | |
| | | $output = sprintf($header, $lang, $varname.'.inc', date('Y'), $texts['_translator'], '$Id', $varname); |
| | | $author = preg_replace('/\s*<Unknown>/i', '', $texts['_translator']); |
| | | $output = sprintf($header, $lang, $varname.'.inc', date('Y'), $author, $varname); |
| | | |
| | | foreach ($texts as $label => $value) { |
| | | if (is_array($value)) { var_dump($outfn, $label, $value); exit; } |
| | | 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 .= "\n"; |
| | | $dir = dirname($outfn); |
| | | @mkdir($dir, 664, true); |
| | | @mkdir($dir, 0755, true); |
| | | if (file_put_contents($outfn, $output)) |
| | | echo "-> $outfn\n"; |
| | | } |
| | |
| | | foreach ($dests as $dest) { |
| | | list($file, $label) = explode(':', $dest); |
| | | $out[$file][$label] = $msgstr; |
| | | $out[$file]['_translator'] = $translator; |
| | | } |
| | | } |
| | | |
| | | |
| | | $msgid = null; |
| | | $msgstr = ''; |
| | | $dests = array(); |
| | |
| | | $out[$file]['_translator'] = $translator; |
| | | } |
| | | } |
| | | |
| | | |
| | | return $language ? $out : array(); |
| | | } |
| | | |