luci-0.10: merge r6746, r6747 and r6748
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 18 Jan 2011 19:15:46 +0000 (19:15 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 18 Jan 2011 19:15:46 +0000 (19:15 +0000)
build/i18n-lua2po.pl [new file with mode: 0755]
build/i18n-po2lua.pl [deleted file]
contrib/package/iwinfo/src/iwinfo_nl80211.c
modules/admin-core/luasrc/controller/admin/servicectl.lua

diff --git a/build/i18n-lua2po.pl b/build/i18n-lua2po.pl
new file mode 100755 (executable)
index 0000000..d72d2e9
--- /dev/null
@@ -0,0 +1,120 @@
+#!/usr/bin/perl
+
+@ARGV >= 2 || die "Usage: $0 <source-dir> <dest-dir> [<target-language>]\n";
+
+my $source_dir  = shift @ARGV;
+my $target_dir  = shift @ARGV;
+my $target_lang = shift @ARGV;
+my $master_lang = "en";
+
+
+if( ! -d "$target_dir/" . ( $target_lang || 'templates' ) )
+{
+       system('mkdir', '-p', "$target_dir/" . ( $target_lang || 'templates' ));
+}
+
+
+my %target_strings;
+
+if( $target_lang && open F, "find $source_dir -path '*/luasrc/i18n/*' -name '*.$target_lang.lua' |" )
+{
+       while( chomp( my $file = readline F ) )
+       {
+               if( open L, "< $file" )
+               {
+                       my ( $basename ) = $file =~ m{.+/([^/]+)\.[\w\-]+\.lua$};
+                       $target_strings{$basename} = { };
+
+                       while( chomp( my $entry = readline L ) )
+                       {
+                               my ( $k, $v );
+                               if( $entry =~ /^\s*(\w+)\s*=\s*\[\[(.+)\]\]/ )
+                               {
+                                       ( $k, $v ) = ( $1, $2 );
+                               }
+                               elsif( $entry =~ /^\s*(\w+)\s*=\s*'(.+)'/ )
+                               {
+                                       ( $k, $v ) = ( $1, $2 );
+                               }
+                               elsif( $entry =~ /^\s*(\w+)\s*=\s*"(.+)"/ )
+                               {
+                                       ( $k, $v ) = ( $1, $2 );
+                               }
+                               
+                               if( $k && $v )
+                               {
+                                       $v =~ s/"/\\"/g;
+                                       $v =~ s/\\\\"/\\"/g;
+                                       $target_strings{$basename}{$k} = $v;
+                               }
+                       }
+
+                       close L;
+               }
+       }
+
+       close F;
+}
+
+
+if( open F, "find . -path '*/luasrc/i18n/*' -name '*.$master_lang.lua' |" )
+{
+       my $destfile = sprintf '%s/%s/%%s.%s',
+               $target_dir,
+               $target_lang || 'templates',
+               $target_lang ? 'po' : 'pot'
+       ;
+
+       while( chomp( my $file = readline F ) )
+       {
+               if( open L, "< $file" )
+               {
+                       my ( $basename ) = $file =~ m{.+/([^/]+)\.\w+\.lua$};
+                       my $filename = sprintf $destfile, $basename;
+
+                       if( open T, "> $filename" )
+                       {
+                               printf "Generating %-40s ", $filename;
+
+                               printf T "#  %s.%s\n#  generated from %s\n\nmsgid \"\"\n" .
+                                        "msgstr \"Content-Type: text/plain; charset=UTF-8\"\n\n",
+                                       $basename, $target_lang ? 'po' : 'pot', $file;
+               
+                               while( chomp( my $entry = readline L ) )
+                               {
+                                       my ( $k, $v );
+                                       if( $entry =~ /^\s*(\w+)\s*=\s*\[\[(.+)\]\]/ )
+                                       {
+                                               ( $k, $v ) = ( $1, $2 );
+                                       }
+                                       elsif( $entry =~ /^\s*(\w+)\s*=\s*'(.+)'/ )
+                                       {
+                                               ( $k, $v ) = ( $1, $2 );
+                                       }
+                                       elsif( $entry =~ /^\s*(\w+)\s*=\s*"(.+)"/ )
+                                       {
+                                               ( $k, $v ) = ( $1, $2 );
+                                       }
+                               
+                                       if( $k && $v )
+                                       {
+                                               $v =~ s/"/\\"/g;
+                                               $v =~ s/\\\\"/\\"/g;
+                                               printf T "#: %s:%d\n#. %s\nmsgid \"%s\"\nmsgstr \"%s\"\n\n",
+                                                       $file, $., $v, $k,
+                                                       ( $target_strings{$basename} && $target_strings{$basename}{$k} )
+                                                               ? $target_strings{$basename}{$k} : "";
+                                       }
+                               }
+                               
+                               close T;
+                               
+                               print "done\n";
+                       }
+
+                       close L;
+               }
+       }
+
+       close F;
+}
diff --git a/build/i18n-po2lua.pl b/build/i18n-po2lua.pl
deleted file mode 100755 (executable)
index 5129055..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/perl
-
-@ARGV == 2 || die "Usage: $0 <source-dir> <dest-dir>\n";
-
-my $source_dir  = shift @ARGV;
-my $target_dir  = shift @ARGV;
-
-if( ! -d $target_dir )
-{
-       system('mkdir', '-p', $target_dir);
-}
-
-if( open F, "find $source_dir -type f -name '*.po' |" )
-{
-       while( chomp( my $file = readline F ) )
-       {
-               my ( $lang, $basename ) = $file =~ m{.+/(\w+)/([^/]+)\.po$};
-               $lang = lc $lang;
-               $lang =~ s/_/-/g;
-
-               printf "Generating %-40s ", "$target_dir/$basename.$lang.lmo";
-               system("./build/po2lmo", $file, "$target_dir/$basename.$lang.lmo");
-               print ( -f "$target_dir/$basename.$lang.lmo" ? "done\n" : "empty\n" );
-       }
-
-       close F;
-}
index aca2be233ee286497fb9295084f540862899703c..fa714e906393405f280e4c154d0fd9c5753c2bc2 100644 (file)
@@ -356,6 +356,7 @@ static inline int nl80211_wpactl_recv(int sock, char *buf, int blen)
 static char * nl80211_wpactl_info(const char *ifname, const char *cmd,
                                                                   const char *event)
 {
+       int numtry = 0;
        int sock = -1;
        char *rv = NULL;
        size_t remote_length, local_length;
@@ -395,7 +396,7 @@ static char * nl80211_wpactl_info(const char *ifname, const char *cmd,
 
        send(sock, cmd, strlen(cmd), 0);
 
-       while( 1 )
+       while( numtry++ < 5 )
        {
                if( nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0 )
                {
index 3ef8847c058fb625025ad6517e2e617c91051896..83f07d7f2731004c6cfd3ee891c084af935ea4d0 100644 (file)
@@ -18,9 +18,9 @@ function index()
        luci.i18n.loadc("base")
        local i18n = luci.i18n.translate
 
-       entry({"servicectl"}, alias("servicectl", "status"), "", 1).sysauth = "root"
-       entry({"servicectl", "status"}, call("action_status"), "", 2).leaf = true
-       entry({"servicectl", "restart"}, call("action_restart"), "", 3).leaf = true
+       entry({"servicectl"}, alias("servicectl", "status"), nil, 1).sysauth = "root"
+       entry({"servicectl", "status"}, call("action_status"), nil, 2).leaf = true
+       entry({"servicectl", "restart"}, call("action_restart"), nil, 3).leaf = true
 end
 
 function action_status()