luci-mod-network: avoid needlessly writing `none` RA flags
[project/luci.git] / build / i18n-scan.pl
index ddec094caab48c25c9d7a2affdc2157a44246aad..0374b6d872b6e80b3e032a6828b0372f70600c68 100755 (executable)
@@ -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
@@ -160,7 +170,7 @@ sub preprocess_json($$) {
        my ($path, $source) = @_;
        my ($file) = $path =~ m!([^/]+)$!;
 
-       $source =~ s/("(?:title)")\s*:\s*("(?:[^"\\]|\\.)*")/$1: _($2)/sg;
+       $source =~ s/("(?:title|description)")\s*:\s*("(?:[^"\\]|\\.)*")/$1: _($2)/sg;
 
        return ($source);
 }
@@ -171,7 +181,7 @@ my $msguniq_pid = open2($msguniq_out, $msguniq_in, 'msguniq', '-s');
 
 print $msguniq_in "msgid \"\"\nmsgstr \"Content-Type: text/plain; charset=UTF-8\"\n";
 
-if (open F, "find @ARGV -type f '(' -name '*.htm' -o -name '*.lua' -o -name '*.js' -o -path '*/menu.d/*.json' ')' |")
+if (open F, "find @ARGV -type f '(' -name '*.htm' -o -name '*.lua' -o -name '*.js' -o -path '*/menu.d/*.json' -o -path '*/acl.d/*.json' -o -path '*/statistics/plugins/*.json' ')' |")
 {
        while (defined( my $file = readline F))
        {