From 7ab1ec4caa74fc017948829dbd57c91a659a4b4b Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 2 Jul 2013 22:48:43 -0400 Subject: tools/inc/lib/jsgettext/: bundle jsgettext library from https://code.google.com/p/jsgettext --- tools/inc/lib/jsgettext/po2json.php | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tools/inc/lib/jsgettext/po2json.php (limited to 'tools/inc/lib/jsgettext/po2json.php') diff --git a/tools/inc/lib/jsgettext/po2json.php b/tools/inc/lib/jsgettext/po2json.php new file mode 100644 index 00000000..847b0899 --- /dev/null +++ b/tools/inc/lib/jsgettext/po2json.php @@ -0,0 +1,42 @@ + null, + '-i' => null, + '-n' => 'l10n' + ); + $len = count($args); + $i = 0; + while ($i < $len) { + if (preg_match('#^-[a-z]$#i', $args[$i])) { + $options[$args[$i]] = isset($args[$i+1]) ? trim($args[$i+1]) : true; + $i += 2; + } + else { + $options[] = $args[$i]; + $i++; + } + } + return $options; + } + + $options = buildOptions($argv); + + if (!file_exists($options['-i']) || !is_readable($options['-i'])) { + die("Invalid input file. Make sure it exists and is readable."); + } + + $poeditParser = new PoeditParser($options['-i']); + $poeditParser->parse(); + + if ($poeditParser->toJSON($options['-o'], $options['-n'])) { + $strings = count($poeditParser->getStrings()); + echo "Successfully exported " . count($strings) . " strings.\n"; + } + else { + echo "Cannor write to file '{$options['-o']}'.\n"; + } +?> -- cgit v1.3