summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-01-14 23:23:37 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-01-14 23:23:37 +0000
commit4ab2d1017e3e3b925d06713eb196f1dc99ae5da8 (patch)
treedffbdaa07025b1b25fe247ce2b86371f8c032f8a
parent3e9e883c1583ba85132cec7a4598d92ad7152a64 (diff)
build: fix some errors in i18n-scan.pl, support bracketed Lua string notation
-rwxr-xr-xbuild/i18n-scan.pl34
1 files changed, 25 insertions, 9 deletions
diff --git a/build/i18n-scan.pl b/build/i18n-scan.pl
index 8c01a99c4..cee07fdfe 100755
--- a/build/i18n-scan.pl
+++ b/build/i18n-scan.pl
@@ -12,10 +12,10 @@ my %stringtable;
sub dec_lua_str
{
my $s = shift;
+ $s =~ s/[\s\n]+/ /g;
$s =~ s/\\n/\n/g;
- $s =~ s/\\t/\n/g;
+ $s =~ s/\\t/\t/g;
$s =~ s/\\(.)/$1/g;
- $s =~ s/[\s\n]+/ /g;
$s =~ s/^ //;
$s =~ s/ $//;
return $s;
@@ -50,23 +50,39 @@ if( open F, "find @ARGV -type f '(' -name '*.htm' -o -name '*.lua' ')' |" )
while( $text =~ s/ ^ .*? (?:translate|translatef|i18n|_) [\n\s]* \( /(/sgx )
{
( my $code, $text ) = extract_bracketed($text, q{('")});
- $code =~ s/^\(//; $code =~ s/\)$//;
+
+ $code =~ s/^\([\n\s]*//;
+ $code =~ s/[\n\s]*\)$//;
my $res = "";
my $sub = "";
- while( defined $sub )
+ if( $code =~ /^['"]/ )
{
- ( $sub, $code ) = extract_delimited($code, q{'"}, q{\s*(?:\.\.\s*)?});
-
- if( defined $sub )
+ while( defined $sub )
{
- $res .= substr $sub, 1, length($sub) - 2;
+ ( $sub, $code ) = extract_delimited($code, q{'"}, q{\s*(?:\.\.\s*)?});
+
+ if( defined $sub )
+ {
+ $res .= substr $sub, 1, length($sub) - 2;
+ }
}
}
+ elsif( $code =~ /^(\[=*\[)/ )
+ {
+ my $stag = quotemeta $1;
+ my $etag = $stag;
+ $etag =~ s/\[/]/g;
+
+ ( $res ) = extract_tagged($code, $stag, $etag);
+
+ $res =~ s/^$stag//;
+ $res =~ s/$etag$//;
+ }
$res = dec_lua_str($res);
- $stringtable{$res}++;
+ $stringtable{$res}++ if $res;
}