summaryrefslogtreecommitdiffhomepage
path: root/build
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-05-09 02:46:39 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-05-09 02:46:39 +0000
commitb75a258aecab4f863446e078b10f10ad4ddbfcab (patch)
tree3313d70191fda659d0fe75578bcd0c2170d626b2 /build
parentfd31bb2fcc2f0ee8d2b2684756443e17be3d4a38 (diff)
build: add script to extract i18n tags from templates
Diffstat (limited to 'build')
-rwxr-xr-xbuild/i18n-html2lua.pl48
1 files changed, 48 insertions, 0 deletions
diff --git a/build/i18n-html2lua.pl b/build/i18n-html2lua.pl
new file mode 100755
index 0000000000..c6b893eee4
--- /dev/null
+++ b/build/i18n-html2lua.pl
@@ -0,0 +1,48 @@
+#!/usr/bin/perl
+
+@ARGV || die "Usage: $0 template1.htm [... templateN.htm]\n";
+
+
+my %tags;
+
+foreach my $file ( @ARGV )
+{
+ if( open F, "< $file" )
+ {
+ local $/ = undef;
+
+ my $data = <F>;
+
+ while( $data =~ m/ <%: -? (\w+) (.*?) %> /sgx )
+ {
+ my ( $key, $val ) = ( $1, $2 );
+
+ if( $key && $val )
+ {
+ $val =~ s/\s+/ /sg;
+ $val =~ s/^\s+//;
+ $val =~ s/\s+$//;
+
+ $tags{$key} = $val;
+ }
+ else
+ {
+ $tags{$key} ||= '';
+ }
+ }
+
+ close F;
+ }
+}
+
+foreach my $key ( sort keys %tags )
+{
+ if( $val =~ /'/ )
+ {
+ printf "%s = [[%s]]\n", $key, $tags{$key};
+ }
+ else
+ {
+ printf "%s = '%s'\n", $key, $tags{$key};
+ }
+}