summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2009-02-20 12:57:02 +0300
committerAndrew Dolgov <[email protected]>2009-02-20 12:57:02 +0300
commit10bccf7d57ddd885507b1a8d4ee29b0076c14724 (patch)
tree19a5442ff71a78669dcd7ec1fc04dd55df0aa5d4 /utils
parentbe9d09a1b38325f5c1150dae07862f44c815d850 (diff)
automatically extract i18n data from .js files
Diffstat (limited to 'utils')
-rwxr-xr-xutils/extract-i18n-js.pl15
-rwxr-xr-xutils/update-js-translations.sh48
2 files changed, 63 insertions, 0 deletions
diff --git a/utils/extract-i18n-js.pl b/utils/extract-i18n-js.pl
new file mode 100755
index 000000000..d6179fc70
--- /dev/null
+++ b/utils/extract-i18n-js.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/perl -w
+#
+use strict;
+
+while (<STDIN>) {
+ chomp;
+
+ if (/(__|notify_progress|notify|notify_info|notify_error)\(['"](.*?)['"]\)/) {
+ my $msg = $2;
+
+ $msg =~ s/\"/\\\"/g;
+
+ print "print T_js_decl(\"$msg\");\n";
+ }
+}
diff --git a/utils/update-js-translations.sh b/utils/update-js-translations.sh
new file mode 100755
index 000000000..432cf7ece
--- /dev/null
+++ b/utils/update-js-translations.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+if [ ! -f localized_js.php ]; then
+ echo "please run this script from tt-rss directory"
+ exit 1
+fi
+
+cat >localized_js.php <<HEADER
+<?php
+error_reporting(E_ERROR | E_WARNING | E_PARSE);
+define('DISABLE_SESSIONS', true);
+
+require "functions.php";
+header("Content-Type: text/plain; charset=UTF-8");
+
+function T_js_decl(\$s1) {
+
+ if (!\$s1) return;
+
+// \$T_s1 = __(\$s1);
+
+// if (\$T_s1 != \$s1) {
+ return "T_messages[\"\$s1\"] = \"".__(\$s1)."\";\n";
+// } else {
+// return "";
+// }
+}
+?>
+
+var T_messages = new Object();
+
+function __(msg) {
+ if (T_messages[msg]) {
+ return T_messages[msg];
+ } else {
+ debug('[gettext] not found: ' + msg);
+ return msg;
+ }
+}
+
+<?php
+HEADER
+
+cat *js | ./utils/extract-i18n-js.pl | sort | uniq >> localized_js.php
+
+cat >>localized_js.php <<FOOTER
+?>
+FOOTER