mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 05:25:56 +00:00
automatically extract i18n data from .js files
This commit is contained in:
15
utils/extract-i18n-js.pl
Executable file
15
utils/extract-i18n-js.pl
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/perl -w
|
||||
#
|
||||
use strict;
|
||||
|
||||
while (<STDIN>) {
|
||||
chomp;
|
||||
|
||||
if (/(__|notify_progress|notify|notify_info|notify_error)\(['"](.*?)['"]\)/) {
|
||||
my $msg = $2;
|
||||
|
||||
$msg =~ s/\"/\\\"/g;
|
||||
|
||||
print "print T_js_decl(\"$msg\");\n";
|
||||
}
|
||||
}
|
||||
48
utils/update-js-translations.sh
Executable file
48
utils/update-js-translations.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ! -f localized_js.php ]; then
|
||||
echo "please run this script from tt-rss directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat >localized_js.php <<HEADER
|
||||
<?php
|
||||
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
||||
define('DISABLE_SESSIONS', true);
|
||||
|
||||
require "functions.php";
|
||||
header("Content-Type: text/plain; charset=UTF-8");
|
||||
|
||||
function T_js_decl(\$s1) {
|
||||
|
||||
if (!\$s1) return;
|
||||
|
||||
// \$T_s1 = __(\$s1);
|
||||
|
||||
// if (\$T_s1 != \$s1) {
|
||||
return "T_messages[\"\$s1\"] = \"".__(\$s1)."\";\n";
|
||||
// } else {
|
||||
// return "";
|
||||
// }
|
||||
}
|
||||
?>
|
||||
|
||||
var T_messages = new Object();
|
||||
|
||||
function __(msg) {
|
||||
if (T_messages[msg]) {
|
||||
return T_messages[msg];
|
||||
} else {
|
||||
debug('[gettext] not found: ' + msg);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
<?php
|
||||
HEADER
|
||||
|
||||
cat *js | ./utils/extract-i18n-js.pl | sort | uniq >> localized_js.php
|
||||
|
||||
cat >>localized_js.php <<FOOTER
|
||||
?>
|
||||
FOOTER
|
||||
Reference in New Issue
Block a user