mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-24 07:30:10 +01:00
tools/i18n_*: introduction of translation tools for tinyboard; supporting javascript i18n
This commit is contained in:
parent
8fd569ce1e
commit
2b8d695b49
44
tools/i18n_compile.php
Executable file
44
tools/i18n_compile.php
Executable file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
/*
|
||||
* i18n_compile.php - compiles the i18n
|
||||
*
|
||||
* Options:
|
||||
* -l [locale], --locale=[locale]
|
||||
* Compiles [locale] locale.
|
||||
*
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
if ($options['locale']) $locales = array($options['locale']);
|
||||
else die("Error: no locales specified; use -l switch, eg. -l pl_PL\n");
|
||||
|
||||
foreach ($locales as $loc) {
|
||||
if (file_exists ($locdir = "inc/locale/".$loc)) {
|
||||
if (!is_dir ($locdir)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
die("Error: $locdir does not exist\n");
|
||||
}
|
||||
|
||||
// Generate tinyboard.po
|
||||
if (file_exists($locdir."/LC_MESSAGES/tinyboard.po")) $join = "-j";
|
||||
else $join = "";
|
||||
`cd $locdir/LC_MESSAGES;
|
||||
msgfmt tinyboard.po`;
|
||||
|
||||
// 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`;
|
||||
}
|
47
tools/i18n_extract.php
Executable file
47
tools/i18n_extract.php
Executable file
@ -0,0 +1,47 @@
|
||||
#!/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 = "";
|
||||
`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)`;
|
||||
}
|
Loading…
Reference in New Issue
Block a user