1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-24 07:30:10 +01:00
vichan/tools/i18n_extract.php

49 lines
1.3 KiB
PHP
Raw Permalink Normal View History

#!/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
if (file_exists($locdir."/LC_MESSAGES/tinyboard.po")) $join = "-j";
else $join = "";
2013-07-03 07:24:09 +02:00
passthru("cd $locdir/LC_MESSAGES;
xgettext -d tinyboard -L php --from-code utf-8 $join -c $(find ../../../../ -name \*.php)");
// Generate javascript.po
passthru("cd $locdir/LC_MESSAGES;".
"xgettext -d javascript -L Python --force-po --from-code utf-8 $join -c ".
"$(find ../../../../js/ ../../../../templates/ -not -path \*node_modules\* -name \*.js)");
}