diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-07-09 15:05:02 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-07-09 15:05:02 +0000 |
commit | f2b1b113dea96215b42727c2c00c757d2809a837 (patch) | |
tree | 0267fc3de59ad67274cf68212480f752c391d1d2 /build/i18n-po2lua.pl | |
parent | d9d3c714351b82cfd387fc6f83d89591909312a2 (diff) |
build: embed lmo in the build process
Diffstat (limited to 'build/i18n-po2lua.pl')
-rwxr-xr-x | build/i18n-po2lua.pl | 62 |
1 files changed, 6 insertions, 56 deletions
diff --git a/build/i18n-po2lua.pl b/build/i18n-po2lua.pl index c57198fd5..5129055ff 100755 --- a/build/i18n-po2lua.pl +++ b/build/i18n-po2lua.pl @@ -10,67 +10,17 @@ if( ! -d $target_dir ) system('mkdir', '-p', $target_dir); } - -my %target_strings; - - if( open F, "find $source_dir -type f -name '*.po' |" ) { while( chomp( my $file = readline F ) ) { - if( open L, "< $file" ) - { - my $content = 0; - my ( $lang, $basename ) = $file =~ m{.+/(\w+)/([^/]+)\.po$}; - $lang = lc $lang; - $lang =~ s/_/-/g; - - if( open D, "> $target_dir/$basename.$lang.lua" ) - { - printf "Generating %-40s ", "$target_dir/$basename.$lang.lua"; - - my ( $k, $v ); - - while( chomp( my $line = readline L ) || ( defined($k) && defined($v) ) ) - { - if( $line =~ /^msgid "(.+)"/ ) - { - $k = $1; - } - elsif( $k && $line =~ /^msgstr "(.*)"/ ) - { - $v = $1; - } - elsif( $k && defined($v) && $line =~ /^"(.+)"/ ) - { - $v .= $1; - } - else - { - if( $k && defined($v) && length($v) > 0 ) - { - $v =~ s/\\(['"\\])/$1/g; - $v =~ s/(['\\])/\\$1/g; - - printf D "%s='%s'\n", $k, $v; - $content++; - } - - $k = $v = undef; - } - } - - print $content ? "done ($content strings)\n" : "empty\n"; - - close D; - - - unlink("$target_dir/$basename.$lang.lua") - unless( $content > 0 ); - } + my ( $lang, $basename ) = $file =~ m{.+/(\w+)/([^/]+)\.po$}; + $lang = lc $lang; + $lang =~ s/_/-/g; - close L; - } + 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; |