summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-05-14 20:16:00 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-05-14 20:16:00 +0000
commit35e9998ec7fa1a0dd657b81ef8a93aec2433b02b (patch)
treee522ee253e64a31b56943222c81749f2ba402795
parent6202881b5663f23095a3fed2f531899cdae4df53 (diff)
build/i18n-lua2po.pl: generate *.pot files if target language is unspecified, don't substitute undefined msg strings with english
-rwxr-xr-xbuild/i18n-lua2po.pl16
1 files changed, 10 insertions, 6 deletions
diff --git a/build/i18n-lua2po.pl b/build/i18n-lua2po.pl
index 262b427f2..a9bc3b4f6 100755
--- a/build/i18n-lua2po.pl
+++ b/build/i18n-lua2po.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-@ARGV == 3 || die "Usage: $0 <source-dir> <dest-dir> <target-language>\n";
+@ARGV >= 2 || die "Usage: $0 <source-dir> <dest-dir> [<target-language>]\n";
my $source_dir = shift @ARGV;
my $target_dir = shift @ARGV;
@@ -17,13 +17,13 @@ if( ! -d $target_dir )
my %target_strings;
-if( open F, "find $source_dir -path '*/luasrc/i18n/*' -name '*.$target_lang.lua' |" )
+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$};
+ my ( $basename ) = $file =~ m{.+/([^/]+)\.[\w\-]+\.lua$};
$target_strings{$basename} = { };
while( chomp( my $entry = readline L ) )
@@ -45,6 +45,7 @@ if( open F, "find $source_dir -path '*/luasrc/i18n/*' -name '*.$target_lang.lua'
if( $k && $v )
{
$v =~ s/"/\\"/g;
+ $v =~ s/\\\\"/\\"/g;
$target_strings{$basename}{$k} = $v;
}
}
@@ -59,16 +60,18 @@ if( open F, "find $source_dir -path '*/luasrc/i18n/*' -name '*.$target_lang.lua'
if( open F, "find . -path '*/luasrc/i18n/*' -name '*.$master_lang.lua' |" )
{
+ my $ext = $target_lang ? "$target_lang.po" : "pot";
+
while( chomp( my $file = readline F ) )
{
if( open L, "< $file" )
{
my ( $basename ) = $file =~ m{.+/([^/]+)\.\w+\.lua$};
- if( open T, "> $target_dir/$basename.$target_lang.po" )
+ if( open T, "> $target_dir/$basename.$ext" )
{
printf "Generating %-40s ",
- "$target_dir/$basename.$target_lang.po";
+ "$target_dir/$basename.$ext";
printf T "# %s.%s.po\n# generated from %s\n\nmsgid \"\"\n" .
"msgstr \"Content-Type: text/plain; charset=UTF-8\"\n\n",
@@ -93,10 +96,11 @@ if( open F, "find . -path '*/luasrc/i18n/*' -name '*.$master_lang.lua' |" )
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} : $v;
+ ? $target_strings{$basename}{$k} : "";
}
}