From 2b8d695b49d9202c250d4a34844a1a6ceb2d48d0 Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 3 Jul 2013 00:12:28 -0400 Subject: tools/i18n_*: introduction of translation tools for tinyboard; supporting javascript i18n --- tools/i18n_compile.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 tools/i18n_compile.php (limited to 'tools/i18n_compile.php') 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 + Date: Wed, 3 Jul 2013 01:04:08 -0400 Subject: js i18n: misc fixes; quick-reply.js i18n --- js/quick-reply.js | 6 +++--- templates/main.js | 4 ++-- tools/i18n_compile.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tools/i18n_compile.php') diff --git a/js/quick-reply.js b/js/quick-reply.js index bc36ca48..ea504b48 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -17,7 +17,7 @@ $(document).ready(function(){ return; // not index txt_new_topic = $('form[name=post] input[type=submit]').val(); - txt_new_reply = txt_new_topic == 'Submit' ? txt_new_topic : new_reply_string; + txt_new_reply = txt_new_topic == _('Submit') ? txt_new_topic : new_reply_string; undo_quick_reply = function() { $('div.banner').remove(); @@ -27,9 +27,9 @@ $(document).ready(function(){ $('div.post.op').each(function() { var id = $(this).children('p.intro').children('a.post_no:eq(1)').text(); - $('[Quick reply]').insertAfter($(this).children('p.intro').children('a:last')).click(function() { + $('['+_("Quick reply")+']').insertAfter($(this).children('p.intro').children('a:last')).click(function() { $('div.banner').remove(); - $('') + $('') .insertBefore('form[name=post]'); $('form[name=post] input[type=submit]').val(txt_new_reply); diff --git a/templates/main.js b/templates/main.js index b3e773a3..31c0254a 100644 --- a/templates/main.js +++ b/templates/main.js @@ -2,12 +2,12 @@ /* gettext-compatible _ function, example of usage: * - * > // Loading pl_PL.json here (containing polish translation strings generated by tools/locale_compile.php) + * > // Loading pl_PL.json here (containing polish translation strings generated by tools/i18n_compile.php) * > alert(_("Hello!")); * Witaj! */ function _(s) { - return (typeof tb_l10n != 'undefined' && typeof tb_l10n[s] != 'undefined') ? tb_l10n[s] : s; + return (typeof l10n != 'undefined' && typeof l10n[s] != 'undefined') ? l10n[s] : s; } /* printf-like formatting function, example of usage: diff --git a/tools/i18n_compile.php b/tools/i18n_compile.php index c85ccb83..ce00051c 100755 --- a/tools/i18n_compile.php +++ b/tools/i18n_compile.php @@ -35,10 +35,10 @@ foreach ($locales as $loc) { if (file_exists($locdir."/LC_MESSAGES/tinyboard.po")) $join = "-j"; else $join = ""; `cd $locdir/LC_MESSAGES; - msgfmt tinyboard.po`; + msgfmt tinyboard.po -o tinyboard.mo`; // 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`; + -o ../../../../$locdir/LC_MESSAGES/javascript.js`; } -- cgit v1.3 From f2128758f26a9f6402c906c3e10728f16822d779 Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 3 Jul 2013 01:24:09 -0400 Subject: i18n tools: small fixes --- tools/i18n_compile.php | 8 ++++---- tools/i18n_extract.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tools/i18n_compile.php') diff --git a/tools/i18n_compile.php b/tools/i18n_compile.php index ce00051c..ba193767 100755 --- a/tools/i18n_compile.php +++ b/tools/i18n_compile.php @@ -34,11 +34,11 @@ foreach ($locales as $loc) { // Generate tinyboard.po if (file_exists($locdir."/LC_MESSAGES/tinyboard.po")) $join = "-j"; else $join = ""; - `cd $locdir/LC_MESSAGES; - msgfmt tinyboard.po -o tinyboard.mo`; + passthru("cd $locdir/LC_MESSAGES; + msgfmt tinyboard.po -o tinyboard.mo"); // Generate javascript.po - `cd tools/inc/lib/jsgettext/; + passthru("cd tools/inc/lib/jsgettext/; php po2json.php -i ../../../../$locdir/LC_MESSAGES/javascript.po \ - -o ../../../../$locdir/LC_MESSAGES/javascript.js`; + -o ../../../../$locdir/LC_MESSAGES/javascript.js"); } diff --git a/tools/i18n_extract.php b/tools/i18n_extract.php index 1e729c3b..b43e16a0 100755 --- a/tools/i18n_extract.php +++ b/tools/i18n_extract.php @@ -38,10 +38,10 @@ foreach ($locales as $loc) { // 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)`; + passthru("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)`; + passthru("cd tools/inc/lib/jsgettext/; + php jsgettext.php -o ../../../../$locdir/LC_MESSAGES/javascript.po $(find ../../../../js/ -name \*.js)"); } -- cgit v1.3