Add loc_noop to Locale Lua library
authorWuzzy <almikes@aol.com>
Sat, 09 Apr 2016 22:13:47 +0200
changeset 12018 3e615852f36e
parent 12017 06afe8535b1c
child 12019 9937075bbfd5
Add loc_noop to Locale Lua library For collecting strings without translating them (yet)
misc/loc_gen.txt
share/hedgewars/Data/Scripts/Locale.lua
--- a/misc/loc_gen.txt	Sat Apr 09 20:44:55 2016 +0200
+++ b/misc/loc_gen.txt	Sat Apr 09 22:13:47 2016 +0200
@@ -1,7 +1,7 @@
 # this is inefficient and clunky, but, figured it might as well be kept somewhere so people are aware of it
 # Is how I'm currently updated the locale files.
 # collect strings - run in Data
-grep -F 'loc("' */*/*.lua | sed 's/")/")\n/g' | sed 's/.*loc("/loc("/;s/").*/")/' | grep loc | sort | uniq  > loc.txt
+echo -n "" > loc.txt; for F in loc loc_noop; do grep -F "$F(\"" */*/*.lua | sed 's/")/")\n/g' | sed "s/.*$F(\"/loc(\"/;s/\").*/\")/" | grep loc | sort | uniq >> loc.txt; done
 # Update locale files - run in Locale
 for i in *.lua;do cat ../loc.txt | while read f;do STR=$(echo "$f" | sed 's/loc("//;s/")\s*$//;s/"/\\"/g');MAPS=$(grep -F -l -- "loc(\"${STR}\")" ../*/*/*.lua ../*/*/*/*.lua | sed 's/.*\/\([^\/]*\)\/map.lua/\1/;s/.*Campaign\/\([^\/]*\)\//\1:/;s/.*\///;s/.lua//;s/ /_/g' | xargs | sed 's/ /, /g');C=$(echo $MAPS | sed 's/,/\n/' | wc -l);grep -Fq -- "[\"${STR}\"]" $i;if(($?));then if((C>0));then echo "--      [\"${STR}\"] = \"\", -- $MAPS" >> $i;else echo "--      [\"${STR}\"] = \"\"," >> $i;fi;fi;done;done
 # sort - run in Locale
--- a/share/hedgewars/Data/Scripts/Locale.lua	Sat Apr 09 20:44:55 2016 +0200
+++ b/share/hedgewars/Data/Scripts/Locale.lua	Sat Apr 09 22:13:47 2016 +0200
@@ -7,3 +7,7 @@
     else return text
     end
 end
+
+function loc_noop(text)
+    return text
+end