From adde93d2e2b0e38de01ad6ca07458fb3a405f356 Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Fri, 29 Jun 2012 13:58:35 +0000 Subject: scripts to manage localized strings --- tools/extract2lang.php | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 tools/extract2lang.php (limited to 'tools/extract2lang.php') diff --git a/tools/extract2lang.php b/tools/extract2lang.php new file mode 100644 index 000000000..8d3a05188 --- /dev/null +++ b/tools/extract2lang.php @@ -0,0 +1,100 @@ + $strs) { + $f = array(); + $f[] = sprintf('# Generated by extract2lang.php on %s', date('c')); + $f[] = sprintf('# Domain %s', $domain); + + foreach ($strs as $str => $info) { + $str = str_replace(array("\'", "\""), array("'", '"'), $str); + $f[] = ''; + $f[] = sprintf('# %s', $info[0]); + $f[] = ';' . $str; + $f[] = $str; + $f[] = ''; + } + $f = implode("\n", $f); + $dest = sprintf('%s/langs/%s/%s.%s.lang', APP_ROOT, 'en', $domain, 'en'); + $dir = dirname($dest); + + if (!is_dir($dir)) { + echo "making $dir\n"; + mkdir($dir, 0755, true); + } + echo sprintf("saved %d strings in %s\n", count($strs), $dest); + if (FALSE === file_put_contents($dest, $f)) + echo "Failed to write.\n"; +} +echo "Done. kthxbye.\n"; +exit(0); -- cgit v1.2.1