diff options
| author | czaks <marcin@6irc.net> | 2013-07-03 00:12:28 -0400 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2013-07-03 00:12:28 -0400 |
| commit | 2b8d695b49d9202c250d4a34844a1a6ceb2d48d0 (patch) | |
| tree | 75964b61a8e37c008e31cdab50a6719848f3a192 /tools/i18n_compile.php | |
| parent | 8fd569ce1ea93871d025c405de3f72a4b8da6b4f (diff) | |
tools/i18n_*: introduction of translation tools for tinyboard; supporting javascript i18n
Diffstat (limited to 'tools/i18n_compile.php')
| -rwxr-xr-x | tools/i18n_compile.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/i18n_compile.php b/tools/i18n_compile.php new file mode 100755 index 00000000..c85ccb83 --- /dev/null +++ b/tools/i18n_compile.php @@ -0,0 +1,44 @@ +#!/usr/bin/php +<?php + +/* + * i18n_compile.php - compiles the i18n + * + * Options: + * -l [locale], --locale=[locale] + * Compiles [locale] locale. + * + */ + +require dirname(__FILE__) . '/inc/cli.php'; + +// parse command line +$opts = getopt('l:', Array('locale:')); +$options = Array(); + +$options['locale'] = isset($opts['l']) ? $opts['l'] : (isset($opts['locale']) ? $opts['locale'] : false); + +if ($options['locale']) $locales = array($options['locale']); +else die("Error: no locales specified; use -l switch, eg. -l pl_PL\n"); + +foreach ($locales as $loc) { + if (file_exists ($locdir = "inc/locale/".$loc)) { + if (!is_dir ($locdir)) { + continue; + } + } + else { + die("Error: $locdir does not exist\n"); + } + + // Generate tinyboard.po + if (file_exists($locdir."/LC_MESSAGES/tinyboard.po")) $join = "-j"; + else $join = ""; + `cd $locdir/LC_MESSAGES; + msgfmt tinyboard.po`; + + // Generate javascript.po + `cd tools/inc/lib/jsgettext/; + php po2json.php -i ../../../../$locdir/LC_MESSAGES/javascript.po \ + -o ../../../../$locdir/LC_MESSAGES/javascript.js -k tb_i18n`; +} |
