summaryrefslogtreecommitdiff
path: root/tools/i18n_extract.php
diff options
context:
space:
mode:
authorczaks <marcin@6irc.net>2013-07-03 00:12:28 -0400
committerMichael Foster <savetheinternet@tinyboard.org>2013-07-31 15:58:31 -0400
commit73fb2cfe5531a74a6368ed653ef1026774febcd0 (patch)
tree8d38471e25158d7c3a18c9746cbbe2c29ae4074f /tools/i18n_extract.php
parentad809eecebbede02b7e089c5ca2451f9520adddf (diff)
tools/i18n_*: introduction of translation tools for tinyboard; supporting javascript i18n
Diffstat (limited to 'tools/i18n_extract.php')
-rwxr-xr-xtools/i18n_extract.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/tools/i18n_extract.php b/tools/i18n_extract.php
new file mode 100755
index 00000000..1e729c3b
--- /dev/null
+++ b/tools/i18n_extract.php
@@ -0,0 +1,47 @@
+#!/usr/bin/php
+<?php
+
+/*
+ * i18n_extract.php - extracts the strings and updates all locales
+ *
+ * Options:
+ * -l [locale], --locale=[locale]
+ * Updates only [locale] locale. If it does not exist yet, we create a new directory.
+ *
+ */
+
+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);
+
+$locales = glob("inc/locale/*");
+$locales = array_map("basename", $locales);
+
+if ($options['locale']) $locales = array($options['locale']);
+
+
+foreach ($locales as $loc) {
+ if (file_exists ($locdir = "inc/locale/".$loc)) {
+ if (!is_dir ($locdir)) {
+ continue;
+ }
+ }
+ else {
+ mkdir($locdir);
+ mkdir($locdir."/LC_MESSAGES");
+ }
+
+ // Generate tinyboard.po
+ if (file_exists($locdir."/LC_MESSAGES/tinyboard.po")) $join = "-j";
+ else $join = "";
+ `cd $locdir/LC_MESSAGES;
+ xgettext -d tinyboard -L php --from-code utf-8 $join -c $(find ../../../../ -name \*.php)`;
+
+ // Generate javascript.po
+ `cd tools/inc/lib/jsgettext/;
+ php jsgettext.php -o ../../../../$locdir/LC_MESSAGES/javascript.po $(find ../../../../js/ -name \*.js)`;
+}