2013-07-03 06:12:28 +02:00
|
|
|
#!/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
|
2015-03-18 09:59:42 +01:00
|
|
|
if (file_exists($locdir."/LC_MESSAGES/tinyboard.po")) $join = "-j --omit-header";
|
2013-07-03 06:12:28 +02:00
|
|
|
else $join = "";
|
2013-07-03 07:24:09 +02:00
|
|
|
passthru("cd $locdir/LC_MESSAGES;
|
2015-04-03 08:08:57 +02:00
|
|
|
xgettext -d tinyboard -L php --from-code utf-8 $join $(find ../../../../ -name \*.php)");
|
2013-07-03 06:12:28 +02:00
|
|
|
|
|
|
|
// Generate javascript.po
|
2014-02-23 19:39:20 +01:00
|
|
|
passthru("cd $locdir/LC_MESSAGES;".
|
2015-04-03 08:08:57 +02:00
|
|
|
"xgettext -d javascript -L Python --force-po --from-code utf-8 $join ".
|
2014-02-23 19:39:20 +01:00
|
|
|
"$(find ../../../../js/ ../../../../templates/ -not -path \*node_modules\* -name \*.js)");
|
2013-07-03 06:12:28 +02:00
|
|
|
}
|