X-Git-Url: http://git.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=build%2Fi18n-scan.pl;fp=build%2Fi18n-scan.pl;h=e46863942be622be52db51a67d2ca18aa3adb08a;hp=ddec094caab48c25c9d7a2affdc2157a44246aad;hb=9939fc5a26d07da4756497bb6a7dc51dcf379e98;hpb=6f6f3e84ca0bc04cd69433f723371fdd3416add9 diff --git a/build/i18n-scan.pl b/build/i18n-scan.pl index ddec094caa..e46863942b 100755 --- a/build/i18n-scan.pl +++ b/build/i18n-scan.pl @@ -124,14 +124,24 @@ sub preprocess_htm($$) { '=' => '(%s)', '_' => 'translate([==[%s]==])', ':' => 'translate([==[%s]==])', - '+' => 'include([==[%s]==)', + '+' => 'include([==[%s]==])', '#' => '--[==[%s]==]', '' => '%s' }; # Translate the .htm source into a valid Lua source using bracket quotes # to avoid the need for complex escaping. - $source =~ s|<%-?([=_:+#]?)(.*?)-?%>|sprintf "]==]; $sub->{$1}; [==[", $2|sge; + $source =~ s!<%-?([=_:+#]?)(.*?)-?%>! + my $t = $1; + my $s = $2; + + # Split translation expressions on first non-escaped pipe. + if ($t eq ':' || $t eq '_') { + $s =~ s/^((?:[^\|\\]|\\.)*)\|(.*)$/$1]==],[==[$2/; + } + + sprintf "]==]; $sub->{$t}; [==[", $s + !sge; # Discover expressions like "lng.translate(...)" or "luci.i18n.translate(...)" # and return them as extra keyword so that xgettext recognizes such expressions