projects
/
oweals
/
luci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1503 from user7887/master
[oweals/luci.git]
/
build
/
i18n-scan.pl
diff --git
a/build/i18n-scan.pl
b/build/i18n-scan.pl
index a31952bbbc840468104b48bf1d14dce043ea4718..899d90d22c282ada2e203cc249a75a52aa51aa83 100755
(executable)
--- a/
build/i18n-scan.pl
+++ b/
build/i18n-scan.pl
@@
-12,10
+12,10
@@
my %stringtable;
sub dec_lua_str
{
my $s = shift;
sub dec_lua_str
{
my $s = shift;
+ $s =~ s/[\s\n]+/ /g;
$s =~ s/\\n/\n/g;
$s =~ s/\\n/\n/g;
- $s =~ s/\\t/\
n
/g;
+ $s =~ s/\\t/\
t
/g;
$s =~ s/\\(.)/$1/g;
$s =~ s/\\(.)/$1/g;
- $s =~ s/[\s\n]+/ /g;
$s =~ s/^ //;
$s =~ s/ $//;
return $s;
$s =~ s/^ //;
$s =~ s/ $//;
return $s;
@@
-24,14
+24,16
@@
sub dec_lua_str
sub dec_tpl_str
{
my $s = shift;
sub dec_tpl_str
{
my $s = shift;
+ $s =~ s/-$//;
$s =~ s/[\s\n]+/ /g;
$s =~ s/^ //;
$s =~ s/ $//;
$s =~ s/[\s\n]+/ /g;
$s =~ s/^ //;
$s =~ s/ $//;
+ $s =~ s/\\/\\\\/g;
return $s;
}
return $s;
}
-if( open F, "find @ARGV -type f '(' -name '*.htm' -o
r
-name '*.lua' ')' |" )
+if( open F, "find @ARGV -type f '(' -name '*.htm' -o -name '*.lua' ')' |" )
{
while( defined( my $file = readline F ) )
{
{
while( defined( my $file = readline F ) )
{
@@
-49,29
+51,50
@@
if( open F, "find @ARGV -type f '(' -name '*.htm' -or -name '*.lua' ')' |" )
while( $text =~ s/ ^ .*? (?:translate|translatef|i18n|_) [\n\s]* \( /(/sgx )
{
( my $code, $text ) = extract_bracketed($text, q{('")});
while( $text =~ s/ ^ .*? (?:translate|translatef|i18n|_) [\n\s]* \( /(/sgx )
{
( my $code, $text ) = extract_bracketed($text, q{('")});
- $code =~ s/^\(//; $code =~ s/\)$//;
+
+ $code =~ s/\\\n/ /g;
+ $code =~ s/^\([\n\s]*//;
+ $code =~ s/[\n\s]*\)$//;
my $res = "";
my $sub = "";
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 && length($sub) > 2 )
+ {
+ $res .= substr $sub, 1, length($sub) - 2;
+ }
+ else
+ {
+ undef $sub;
+ }
}
}
}
}
+ 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);
$res = dec_lua_str($res);
- $stringtable{$res}++;
+ $stringtable{$res}++
if $res
;
}
$text = $raw;
}
$text = $raw;
- while( $text =~ s/ ^ .*? <%
[:_] -?
/<%/sgx )
+ while( $text =~ s/ ^ .*? <%
-? [:_]
/<%/sgx )
{
( my $code, $text ) = extract_tagged($text, '<%', '%>');
{
( my $code, $text ) = extract_tagged($text, '<%', '%>');