diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2011-01-02 19:20:23 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2011-01-02 19:20:23 +0000 |
commit | 800a2630497e1ec2c61199b3bc645d778c714529 (patch) | |
tree | 2edad02015bdb0995b6f95505deb51f866253f34 /build/i18n-lua2po.pl | |
parent | 73578276afa8d64128d10a4b0ff9b7246b178cc3 (diff) |
build: remove some obsolete support scripts
Diffstat (limited to 'build/i18n-lua2po.pl')
-rwxr-xr-x | build/i18n-lua2po.pl | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/build/i18n-lua2po.pl b/build/i18n-lua2po.pl deleted file mode 100755 index d72d2e975..000000000 --- a/build/i18n-lua2po.pl +++ /dev/null @@ -1,120 +0,0 @@ -#!/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; -} |