misc/loc_gen.txt
branch0.9.18
changeset 7935 f8941f0b7bef
parent 7828 63d9ea2c63be
child 12013 3e615852f36e
--- a/misc/loc_gen.txt	Thu Nov 01 19:12:22 2012 -0400
+++ b/misc/loc_gen.txt	Fri Nov 02 16:26:51 2012 -0400
@@ -1,10 +1,10 @@
 # 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
+grep -F 'loc("' */*/*.lua | sed 's/")/")\n/g' | sed 's/.*loc("/loc("/;s/").*/")/' | grep loc | sort | uniq  > loc.txt
 # 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
-for i in *.lua;do rm temphead temptail templua;cat $i | grep -Ev "}|{" | grep -Ev "^[[:space:]]*$" | sort > templua;echo "locale = {" > temphead;echo "    }" > temptail;cat temphead templua temptail > $i;done
+for i in *.lua;do rm temphead temptail templua;cat $i | grep -Ev "}|{" | grep -Ev "^[[:space:]]*$" | sort | uniq > templua;echo "locale = {" > temphead;echo "    }" > temptail;cat temphead templua temptail > $i;done
 # drop unused - run in Locale
-cat stub.lua | grep '"] =' | while read f;do PHRASE=$(echo "$f" | sed 's/[^[]*\["//;s/"] =.*//;s/"/\\"/g');CNT=$(grep -Frc "loc(\"$PHRASE\")" ../*/*/*.lua ../*/*/*/*.lua | grep -v ":0" | wc -l);if(($CNT==0));then echo "|$PHRASE|";sed -i "s/.*\[\"$PHRASE\"].*//" *.lua;fi;done
+cat stub.lua | grep '"] =' | while read f;do PHRASE=$(echo "$f" | sed 's/[^[]*\["//;s/"] =.*//;s/"/\\"/g');CNT=$(grep -Frc "loc(\"$PHRASE\")" ../*/*/*.lua ../*/*/*/*.lua | grep -v ":0" | wc -l);if(($CNT==0));then echo "|$PHRASE|";PHRASE=$(echo "$PHRASE" | sed 's/\\/\\\\/g;s/\[/\\[/g;s/\]/\\]/g;s/\//\\\//g');sed -i "s/.*\[\"$PHRASE\"\].*//" *.lua;fi;done