From: Andrew Dolgov Date: Fri, 20 Feb 2009 09:57:02 +0000 (+0300) Subject: automatically extract i18n data from .js files X-Git-Tag: 1.3.1~3 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=10bccf7d57ddd885507b1a8d4ee29b0076c14724;p=tt-rss.git automatically extract i18n data from .js files --- diff --git a/localized_js.php b/localized_js.php index ee230940..849bab9f 100644 --- a/localized_js.php +++ b/localized_js.php @@ -9,13 +9,13 @@ function T_js_decl($s1) { if (!$s1) return; - $T_s1 = __($s1); +// $T_s1 = __($s1); - if ($T_s1 != $s1) { +// if ($T_s1 != $s1) { return "T_messages[\"$s1\"] = \"".__($s1)."\";\n"; - } else { - return ""; - } +// } else { +// return ""; +// } } ?> @@ -31,124 +31,152 @@ function __(msg) { } diff --git a/offline.js b/offline.js index 9054ea45..010bbe05 100644 --- a/offline.js +++ b/offline.js @@ -854,8 +854,6 @@ function update_offline_data(stage) { if (!db || offline_mode || getInitParam("offline_enabled") != "1") return; -// notify_progress("Updating offline data... (" + stage +")", true); - var query = "backend.php?op=rpc&subop=download"; var rs = db.execute("SELECT MAX(id), MIN(id) FROM articles"); diff --git a/update-translations.sh b/update-translations.sh index 0b78958b..93c4e5d7 100755 --- a/update-translations.sh +++ b/update-translations.sh @@ -25,3 +25,5 @@ for lang in $LANGS; do PO_BASENAME=`echo $lang | sed s/.po//` update_lang $PO_BASENAME done + +./utils/update-js-translations.sh diff --git a/utils/extract-i18n-js.pl b/utils/extract-i18n-js.pl new file mode 100755 index 00000000..d6179fc7 --- /dev/null +++ b/utils/extract-i18n-js.pl @@ -0,0 +1,15 @@ +#!/usr/bin/perl -w +# +use strict; + +while () { + 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 00000000..432cf7ec --- /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 <
+ +var T_messages = new Object(); + +function __(msg) { + if (T_messages[msg]) { + return T_messages[msg]; + } else { + debug('[gettext] not found: ' + msg); + return msg; + } +} + +> localized_js.php + +cat >>localized_js.php <