diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-05-19 02:18:28 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-05-19 02:18:28 +0000 |
commit | 7bf803250be75dac62c6e048fa675c93c9093b9a (patch) | |
tree | f84bb33ebc6ba26e2fc2a2b19e9f8e537de61a62 /build | |
parent | 2d0ead91d7e4a6ccdbf3029baf3aca66a7729b9b (diff) |
build: integrate po files in the build system
Diffstat (limited to 'build')
-rwxr-xr-x | build/i18n-po2lua.pl | 22 | ||||
-rw-r--r-- | build/module.mk | 12 |
2 files changed, 21 insertions, 13 deletions
diff --git a/build/i18n-po2lua.pl b/build/i18n-po2lua.pl index 38e6529bb..8466fd989 100755 --- a/build/i18n-po2lua.pl +++ b/build/i18n-po2lua.pl @@ -20,11 +20,14 @@ if( open F, "find $source_dir -type f -name '*.po' |" ) { if( open L, "< $file" ) { - my ( $basename ) = $file =~ m{.+/([^/]+\.[\w\-]+)\.po$}; - - if( open D, "> $target_dir/$basename.lua" ) + 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.lua"; + printf "Generating %-40s ", "$target_dir/$basename.$lang.lua"; my ( $k, $v ); @@ -44,21 +47,26 @@ if( open F, "find $source_dir -type f -name '*.po' |" ) } else { - if( $k && defined($v) ) + if( $k && defined($v) && length($v) > 0 ) { $v =~ s/\\(['"\\])/$1/g; $v =~ s/(['\\])/\\$1/g; - printf D "%s%s='%s'\n", $v ? '' : '--', $k, $v; + printf D "%s='%s'\n", $k, $v; + $content++; } $k = $v = undef; } } - print "done\n"; + print $content ? "done ($content strings)\n" : "empty\n"; close D; + + + unlink("$target_dir/$basename.$lang.lua") + unless( $content > 0 ); } close L; diff --git a/build/module.mk b/build/module.mk index de86855be..6aeb9ba56 100644 --- a/build/module.mk +++ b/build/module.mk @@ -8,17 +8,13 @@ all: build build: luabuild gccbuild -luabuild: i18n lua$(LUA_TARGET) +luabuild: lua$(LUA_TARGET) gccbuild: compile compile: clean: luaclean -i18n: - [ -n "$(XSLTPROC)" ] && for i in luasrc/i18n/*.xml; do [ "$$i" -nt "$${i%%[.]xml}.lua" ]\ - && $(XSLTPROC) $(MAKEPATH)i18n-lua-xhtml1.xsl $$i > $${i%%[.]xml}.lua; done || true - luasource: mkdir -p dist$(LUA_MODULEDIR) mkdir -p dist$(LUCI_MODULEDIR) @@ -28,7 +24,11 @@ luasource: cp -pR lua/* dist$(LUA_MODULEDIR) 2>/dev/null || true cp -pR htdocs/* dist$(HTDOCS) 2>/dev/null || true for i in $$(find dist -name .svn -or -name .gitignore); do rm -rf $$i || true; done - for i in dist$(LUCI_MODULEDIR)/i18n/*.xml; do [ -f "$$i" ] && rm $$i; done || true + ifneq ($(PO),) + for file in $(PO); do \ + cp $(HOST)/lua-po/$$file.*.lua dist$(LUCI_MODULEDIR)/i18n/; \ + done + endif luastrip: luasource |