luci-0.10: restore i18n-po2lua.pl
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 9 May 2011 23:52:34 +0000 (23:52 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 9 May 2011 23:52:34 +0000 (23:52 +0000)
build/i18n-po2lua.pl [new file with mode: 0755]

diff --git a/build/i18n-po2lua.pl b/build/i18n-po2lua.pl
new file mode 100755 (executable)
index 0000000..5129055
--- /dev/null
@@ -0,0 +1,27 @@
+#!/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;
+}