From 47640a0ce872038110ff011c22bf9e0b557aa67e Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 2 Jul 2013 22:45:52 -0400 Subject: tools/: move cli utils from tinyboard-tools to tinyboard repo --- tools/benchmark.php | 52 ++++++++++++++++++++++++++ tools/inc/cli.php | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ tools/rebuild.php | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100644 tools/benchmark.php create mode 100644 tools/inc/cli.php create mode 100755 tools/rebuild.php (limited to 'tools') diff --git a/tools/benchmark.php b/tools/benchmark.php new file mode 100644 index 00000000..8c97364c --- /dev/null +++ b/tools/benchmark.php @@ -0,0 +1,52 @@ +#!/usr/bin/php +resize( + $config['thumb_ext'] ? $config['thumb_ext'] : $extension, + $config['thumb_width'], + $config['thumb_height'] + ); + + $thumb->to($out); + $thumb->_destroy(); + $image->destroy(); + } + $end = microtime(true); + + printf("Took %.2f seconds (%.2f/second; %.2f ms)\n", $end - $start, $rate = ($count / ($end - $start)), 1000 / $rate); + + unlink($out); +} + +benchmark('gd'); +benchmark('imagick'); +benchmark('convert'); + diff --git a/tools/inc/cli.php b/tools/inc/cli.php new file mode 100644 index 00000000..294609cd --- /dev/null +++ b/tools/inc/cli.php @@ -0,0 +1,100 @@ + -1, + 'type' => ADMIN, + 'username' => '?', + 'boards' => Array('*') +); + +function get_httpd_privileges() { + global $config, $shell_path, $argv; + + if(php_sapi_name() != 'cli') + die("get_httpd_privileges(): invoked from HTTP client.\n"); + + echo "Dropping priviledges...\n"; + + if(!is_writable('.')) + die("get_httpd_privileges(): web directory is not writable\n"); + + $filename = '.' . md5(rand()) . '.php'; + $inc_filename = '.' . md5(rand()) . '.php'; + + echo "Copying rebuilder to web directory...\n"; + + // replace "/inc/cli.php" with its new filename + passthru("cat " . escapeshellarg($shell_path . '/' . $_SERVER['PHP_SELF']) . " | sed \"s/'\/inc\/cli\.php'/'\/{$inc_filename}'/\" > {$filename}"); + + $inc_header = " + * Rebuild only the specified board. + * + * -f, --full + * Rebuild replies as well as threads (re-markup). + * + */ + +require dirname(__FILE__) . '/inc/cli.php'; + +if(!is_writable($config['file_script'])) { + get_httpd_privileges(); +} + +$start = microtime(true); + +// parse command line +$opts = getopt('qfb:', Array('board:', 'quick', 'full', 'quiet')); +$options = Array(); + +$options['board'] = isset($opts['board']) ? $opts['board'] : (isset($opts['b']) ? $opts['b'] : false); +$options['quiet'] = isset($opts['q']) || isset($opts['quiet']); +$options['quick'] = isset($opts['quick']); +$options['full'] = isset($opts['full']) || isset($opts['f']); + +if(!$options['quiet']) + echo "== Tinyboard {$config['version']} ==\n"; + +if(!$options['quiet']) + echo "Clearing template cache...\n"; + +load_twig(); +$twig->clearCacheFiles(); + +if(!$options['quiet']) + echo "Regenerating theme files...\n"; +rebuildThemes('all'); + +if(!$options['quiet']) + echo "Generating Javascript file...\n"; +buildJavascript(); + +$main_js = $config['file_script']; + +$boards = listBoards(); + +foreach($boards as &$board) { + if($options['board'] && $board['uri'] != $options['board']) + continue; + + if(!$options['quiet']) + echo "Opening board /{$board['uri']}/...\n"; + openBoard($board['uri']); + + if($config['file_script'] != $main_js) { + // different javascript file + if(!$options['quiet']) + echo "Generating Javascript file...\n"; + buildJavascript(); + } + + + if(!$options['quiet']) + echo "Creating index pages...\n"; + buildIndex(); + + if($options['quick']) + continue; // do no more + + if($options['full']) { + $query = query(sprintf("SELECT `id` FROM `posts_%s`", $board['uri'])) or error(db_error()); + while($post = $query->fetch()) { + if(!$options['quiet']) + echo "Rebuilding #{$post['id']}...\n"; + rebuildPost($post['id']); + } + } + + $query = query(sprintf("SELECT `id` FROM `posts_%s` WHERE `thread` IS NULL", $board['uri'])) or error(db_error()); + while($post = $query->fetch()) { + if(!$options['quiet']) + echo "Rebuilding #{$post['id']}...\n"; + buildThread($post['id']); + } +} + +if(!$options['quiet']) + printf("Complete! Took %g seconds\n", microtime(true) - $start); + +unset($board); +modLog('Rebuilt everything using tools/rebuild.php'); + -- cgit v1.3 From 7ab1ec4caa74fc017948829dbd57c91a659a4b4b Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 2 Jul 2013 22:48:43 -0400 Subject: tools/inc/lib/jsgettext/: bundle jsgettext library from https://code.google.com/p/jsgettext --- tools/inc/lib/jsgettext/JSParser.php | 94 ++++++++++++++++++++++++++++++++ tools/inc/lib/jsgettext/PoeditParser.php | 83 ++++++++++++++++++++++++++++ tools/inc/lib/jsgettext/PoeditString.php | 29 ++++++++++ tools/inc/lib/jsgettext/jsgettext.php | 59 ++++++++++++++++++++ tools/inc/lib/jsgettext/po2json.php | 42 ++++++++++++++ tools/inc/lib/jsgettext/test.js | 27 +++++++++ 6 files changed, 334 insertions(+) create mode 100644 tools/inc/lib/jsgettext/JSParser.php create mode 100644 tools/inc/lib/jsgettext/PoeditParser.php create mode 100644 tools/inc/lib/jsgettext/PoeditString.php create mode 100644 tools/inc/lib/jsgettext/jsgettext.php create mode 100644 tools/inc/lib/jsgettext/po2json.php create mode 100644 tools/inc/lib/jsgettext/test.js (limited to 'tools') diff --git a/tools/inc/lib/jsgettext/JSParser.php b/tools/inc/lib/jsgettext/JSParser.php new file mode 100644 index 00000000..f3cec7f7 --- /dev/null +++ b/tools/inc/lib/jsgettext/JSParser.php @@ -0,0 +1,94 @@ +regs[$this->regsCounter] = $match[1]; + $id = "<regsCounter}>>"; + $this->regsCounter++; + return $id; + } + protected function _extractStrings($match) { + $this->strings[$this->stringsCounter] = $this->importRegExps($match[0]); + $id = "<stringsCounter}>>"; + $this->stringsCounter++; + return $id; + } + protected function importRegExps($input) { + $regs = $this->regs; + return preg_replace_callback("#<>#", function ($match) use($regs) { + return $regs[$match[1]]; + }, $input); + } + + protected function importStrings($input) { + $strings = $this->strings; + return preg_replace_callback("#<>#", function ($match) use($strings) { + return $strings[$match[1]]; + }, $input); + } + + public function __construct($file, $keywords = '_') { + $this->content = file_get_contents($file); + $this->keywords = (array)$keywords; + } + + public function parse() { + $output = htmlspecialchars($this->content, ENT_NOQUOTES); + + // extract reg exps + $output = preg_replace_callback( + '# ( / (?: (?>[^/\\\\]++) | \\\\\\\\ | (?[^"\\\\]++) | \\\\\\\\ | (?[^'\\\\]++) | \\\\\\\\ | (?strings; + $output = preg_replace_callback("#<>#", function($match) use($strings) { + return $strings[$match[1]]; + }, $output); + + $keywords = implode('|', $this->keywords); + + $strings = array(); + + // extract func calls + preg_match_all( + '# (?:'.$keywords.') \(\\ *" ( (?: (?>[^"\\\\]++) | \\\\\\\\ | (?[^'\\\\]++) | \\\\\\\\ | (? \ No newline at end of file diff --git a/tools/inc/lib/jsgettext/PoeditParser.php b/tools/inc/lib/jsgettext/PoeditParser.php new file mode 100644 index 00000000..5ed0ac00 --- /dev/null +++ b/tools/inc/lib/jsgettext/PoeditParser.php @@ -0,0 +1,83 @@ +file = $file; + } + + public function parse() { + $contents = file_get_contents($this->file); + + $parts = preg_split('#(\r\n|\n){2}#', $contents, -1, PREG_SPLIT_NO_EMPTY); + + $this->header = array_shift($parts); + + foreach ($parts as $part) { + + // parse comments + $comments = array(); + preg_match_all('#^\\#: (.*?)$#m', $part, $matches, PREG_SET_ORDER); + foreach ($matches as $m) $comments[] = $m[1]; + + $isFuzzy = preg_match('#^\\#, fuzzy$#im', $part) ? true : false; + + preg_match_all('# ^ (msgid|msgstr)\ " ( (?: (?>[^"\\\\]++) | \\\\\\\\ | (?_fixQuotes($matches2[0][2]); + $v = !empty($matches2[1][2]) ? $this->_fixQuotes($matches2[1][2]) : ''; + + $this->strings[$k] = new PoeditString($k, $v, $isFuzzy, $comments); + } + } + + public function merge($strings) { + foreach ((array)$strings as $str) { + if (!in_array($str, array_keys($this->strings))) { + $this->strings[$str] = new PoeditString($str); + } + } + } + + public function getHeader() { + return $this->header; + } + + public function getStrings() { + return $this->strings; + } + + public function getJSON() { + $str = array(); + foreach ($this->strings as $s) { + if ($s->value) $str[$s->key] = $s->value; + } + return json_encode($str); + } + + public function toJSON($outputFilename, $varName = 'l10n') { + $str = "$varName = " . $this->getJSON(); + return file_put_contents($outputFilename, $str) !== false; + } + + public function save($filename = null) { + $data = $this->header . "\n\n"; + foreach ($this->strings as $str) { + $data .= $str; + } + return file_put_contents($filename ? $filename : $this->file, $data) !== false; + } +} + + +?> \ No newline at end of file diff --git a/tools/inc/lib/jsgettext/PoeditString.php b/tools/inc/lib/jsgettext/PoeditString.php new file mode 100644 index 00000000..3d59d004 --- /dev/null +++ b/tools/inc/lib/jsgettext/PoeditString.php @@ -0,0 +1,29 @@ +key = $key; + $this->value = $value; + $this->fuzzy = $fuzzy; + $this->comments = (array)$comments; + } + + public function __toString() { + $str =''; + foreach ($this->comments as $c) { + $str .= "#: $c\n"; + } + if ($this->fuzzy) $str .= "#, fuzzy\n"; + $str .= 'msgid "'.str_replace('"', '\\"', $this->key).'"' . "\n"; + $str .= 'msgstr "'.str_replace('"', '\\"', $this->value).'"' . "\n"; + $str .= "\n"; + return $str; + } +} + +?> \ No newline at end of file diff --git a/tools/inc/lib/jsgettext/jsgettext.php b/tools/inc/lib/jsgettext/jsgettext.php new file mode 100644 index 00000000..3ce2c9f7 --- /dev/null +++ b/tools/inc/lib/jsgettext/jsgettext.php @@ -0,0 +1,59 @@ + array(), + '-o' => null, + '-k' => '_' + ); + $len = count($args); + $i = 0; + while ($i < $len) { + if (preg_match('#^-[a-z]$#i', $args[$i])) { + $options[$args[$i]] = isset($args[$i+1]) ? trim($args[$i+1]) : true; + $i += 2; + } + else { + $options['files'][] = $args[$i]; + $i++; + } + } + return $options; + } + + $options = buildOptions($argv); + + if (!file_exists($options['-o']) || !is_writable($options['-o'])) { + die("Invalid output file name. Make sure it exists and is writable."); + } + + $inputFiles = $options['files']; + + if (empty($inputFiles)) { + die("You did not provide any input file."); + } + + $poeditParser = new PoeditParser($options['-o']); + $poeditParser->parse(); + + $errors = array(); + + foreach ($inputFiles as $f) { + if (!is_readable($f) || !preg_match('#\.js$#', $f)) { + $errors[] = ("$f is not a valid javascript file."); + continue; + } + $jsparser = new JSParser($f, explode(' ', $options['-k'])); + $jsStrings = $jsparser->parse(); + $poeditParser->merge($jsStrings); + } + + if (!empty($errors)) { + echo "\nThe following errors occured:\n" . implode("\n", $errors) . "\n"; + } + + $poeditParser->save(); +?> diff --git a/tools/inc/lib/jsgettext/po2json.php b/tools/inc/lib/jsgettext/po2json.php new file mode 100644 index 00000000..847b0899 --- /dev/null +++ b/tools/inc/lib/jsgettext/po2json.php @@ -0,0 +1,42 @@ + null, + '-i' => null, + '-n' => 'l10n' + ); + $len = count($args); + $i = 0; + while ($i < $len) { + if (preg_match('#^-[a-z]$#i', $args[$i])) { + $options[$args[$i]] = isset($args[$i+1]) ? trim($args[$i+1]) : true; + $i += 2; + } + else { + $options[] = $args[$i]; + $i++; + } + } + return $options; + } + + $options = buildOptions($argv); + + if (!file_exists($options['-i']) || !is_readable($options['-i'])) { + die("Invalid input file. Make sure it exists and is readable."); + } + + $poeditParser = new PoeditParser($options['-i']); + $poeditParser->parse(); + + if ($poeditParser->toJSON($options['-o'], $options['-n'])) { + $strings = count($poeditParser->getStrings()); + echo "Successfully exported " . count($strings) . " strings.\n"; + } + else { + echo "Cannor write to file '{$options['-o']}'.\n"; + } +?> diff --git a/tools/inc/lib/jsgettext/test.js b/tools/inc/lib/jsgettext/test.js new file mode 100644 index 00000000..996e9a8a --- /dev/null +++ b/tools/inc/lib/jsgettext/test.js @@ -0,0 +1,27 @@ +function _(s) { + return typeof l10n[s] != 'undefined' ? l10n[s] : s; +} +function test(param) { + var a = _("Hello world, testing jsgettext"); + func(_('Test string')); + var reg1 = /"[a-z]+"/i; + var reg2 = /[a-z]+\+\/"aa"/i; + var s1 = _('string 1: single quotes'); + var s2 = _("string 2: double quotes"); + var s3 = _("/* comment in string */"); + var s4 = _("regexp in string: /[a-z]+/i"); + var s5 = jsgettext( "another function" ); + var s6 = avoidme("should not see me!"); + var s7 = _("string 2: \"escaped double quotes\""); + var s8 = _('string 2: \'escaped single quotes\''); + + // "string in comment" + //; + + /** + * multiple + * lines + * comment + * _("Hello world from comment") + */ +} \ No newline at end of file -- cgit v1.3 From f7d7981248c50262253a4f86cab922919e8dfd84 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 2 Jul 2013 23:57:47 -0400 Subject: tools/inc/lib/jsgettext/: apply fixes from bugtracker --- tools/inc/lib/jsgettext/jsgettext.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/inc/lib/jsgettext/jsgettext.php b/tools/inc/lib/jsgettext/jsgettext.php index 3ce2c9f7..6c70f0b4 100644 --- a/tools/inc/lib/jsgettext/jsgettext.php +++ b/tools/inc/lib/jsgettext/jsgettext.php @@ -10,7 +10,7 @@ '-k' => '_' ); $len = count($args); - $i = 0; + $i = 1; while ($i < $len) { if (preg_match('#^-[a-z]$#i', $args[$i])) { $options[$args[$i]] = isset($args[$i+1]) ? trim($args[$i+1]) : true; @@ -26,7 +26,11 @@ $options = buildOptions($argv); - if (!file_exists($options['-o']) || !is_writable($options['-o'])) { + if (!file_exists($options['-o'])) { + touch($options['-o']); + } + + if (!is_writable($options['-o'])) { die("Invalid output file name. Make sure it exists and is writable."); } -- cgit v1.3 From 8fd569ce1ea93871d025c405de3f72a4b8da6b4f Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 2 Jul 2013 23:58:37 -0400 Subject: tools/inc/lib/jsgettext/: remove unnecessary file --- tools/inc/lib/jsgettext/test.js | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 tools/inc/lib/jsgettext/test.js (limited to 'tools') diff --git a/tools/inc/lib/jsgettext/test.js b/tools/inc/lib/jsgettext/test.js deleted file mode 100644 index 996e9a8a..00000000 --- a/tools/inc/lib/jsgettext/test.js +++ /dev/null @@ -1,27 +0,0 @@ -function _(s) { - return typeof l10n[s] != 'undefined' ? l10n[s] : s; -} -function test(param) { - var a = _("Hello world, testing jsgettext"); - func(_('Test string')); - var reg1 = /"[a-z]+"/i; - var reg2 = /[a-z]+\+\/"aa"/i; - var s1 = _('string 1: single quotes'); - var s2 = _("string 2: double quotes"); - var s3 = _("/* comment in string */"); - var s4 = _("regexp in string: /[a-z]+/i"); - var s5 = jsgettext( "another function" ); - var s6 = avoidme("should not see me!"); - var s7 = _("string 2: \"escaped double quotes\""); - var s8 = _('string 2: \'escaped single quotes\''); - - // "string in comment" - //; - - /** - * multiple - * lines - * comment - * _("Hello world from comment") - */ -} \ No newline at end of file -- cgit v1.3 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 ++++++++++++++++++++++++++++++++++++++++++++ tools/i18n_extract.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100755 tools/i18n_compile.php create mode 100755 tools/i18n_extract.php (limited to 'tools') 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 00:50:43 -0400 Subject: tools/inc/lib/jsgettext/: misc fixes --- tools/inc/lib/jsgettext/JSParser.php | 4 ++-- tools/inc/lib/jsgettext/PoeditParser.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/inc/lib/jsgettext/JSParser.php b/tools/inc/lib/jsgettext/JSParser.php index f3cec7f7..adba59bc 100644 --- a/tools/inc/lib/jsgettext/JSParser.php +++ b/tools/inc/lib/jsgettext/JSParser.php @@ -41,7 +41,7 @@ class JSParser { } public function parse() { - $output = htmlspecialchars($this->content, ENT_NOQUOTES); + $output = $this->content; //htmlspecialchars($this->content, ENT_NOQUOTES); // extract reg exps $output = preg_replace_callback( @@ -91,4 +91,4 @@ class JSParser { return $strings; } } -?> \ No newline at end of file +?> diff --git a/tools/inc/lib/jsgettext/PoeditParser.php b/tools/inc/lib/jsgettext/PoeditParser.php index 5ed0ac00..eebd816e 100644 --- a/tools/inc/lib/jsgettext/PoeditParser.php +++ b/tools/inc/lib/jsgettext/PoeditParser.php @@ -66,7 +66,7 @@ class PoeditParser { } public function toJSON($outputFilename, $varName = 'l10n') { - $str = "$varName = " . $this->getJSON(); + $str = "$varName = " . $this->getJSON() . ";"; return file_put_contents($outputFilename, $str) !== false; } @@ -80,4 +80,4 @@ class PoeditParser { } -?> \ No newline at end of file +?> -- cgit v1.3 From da9f367f2f9cf24d47b8d6a04cf2e54cb14a03bc Mon Sep 17 00:00:00 2001 From: czaks 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') 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') 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 From 0a6a982ae9f3418d905b1869a8f284f3c08b3382 Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 3 Jul 2013 01:37:48 -0400 Subject: i18n_extract tool: replace the bundled lib with gettext forced to assume python, since it extracts more strings --- tools/i18n_extract.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/i18n_extract.php b/tools/i18n_extract.php index b43e16a0..33650b50 100755 --- a/tools/i18n_extract.php +++ b/tools/i18n_extract.php @@ -42,6 +42,6 @@ foreach ($locales as $loc) { xgettext -d tinyboard -L php --from-code utf-8 $join -c $(find ../../../../ -name \*.php)"); // Generate javascript.po - passthru("cd tools/inc/lib/jsgettext/; - php jsgettext.php -o ../../../../$locdir/LC_MESSAGES/javascript.po $(find ../../../../js/ -name \*.js)"); + passthru("cd $locdir/LC_MESSAGES; + xgettext -d javascript -L Python --force-po --from-code utf-8 $join -c $(find ../../../../js/ -name \*.js)"); } -- cgit v1.3