Start 0.11.x branch
[project/luci.git] / build / i18n-po2lua.pl
1 #!/usr/bin/perl
2
3 @ARGV == 2 || die "Usage: $0 <source-dir> <dest-dir>\n";
4
5 my $source_dir = shift @ARGV;
6 my $target_dir = shift @ARGV;
7
8 if( ! -d $target_dir )
9 {
10 system('mkdir', '-p', $target_dir);
11 }
12
13 if( open F, "find $source_dir -type f -name '*.po' |" )
14 {
15 while( chomp( my $file = readline F ) )
16 {
17 my ( $lang, $basename ) = $file =~ m{.+/(\w+)/([^/]+)\.po$};
18 $lang = lc $lang;
19 $lang =~ s/_/-/g;
20
21 printf "Generating %-40s ", "$target_dir/$basename.$lang.lmo";
22 system("./build/po2lmo", $file, "$target_dir/$basename.$lang.lmo");
23 print ( -f "$target_dir/$basename.$lang.lmo" ? "done\n" : "empty\n" );
24 }
25
26 close F;
27 }