MG/Translations maintenance

One-liners
Here are some POSIX shell one-liners to help with maintenance of translation files.

Remove BOM off all files
sed -i '1 s/^\xef\xbb\xbf//' data/glest_game/data/lang/*.lng data/glest_game/data/lang/hint/*.lng data/glest_game/scenarios/*/*.lng data/glest_game/tutorials/*/*.lng

Extract all keys to a file
cat data/glest_game/data/lang/*.lng data/glest_game/data/lang/hint/*.lng data/glest_game/scenarios/*/*.lng data/glest_game/tutorials/*/*.lng | awk -F= '/^[^;#]/ {print $1}' | sort | uniq | grep -Ev '^\W*$' > /tmp/all_keys.txt

List unreferenced keys
List keys which are not referenced anywhere in the source code and thus may be leftovers in the translation files.

while read key; do grep -Eq '(lang\.get\("'"$key"'"\)|hasString\("'$key'"\)|setDisplayText\('"'$key'"'\))' `find source/ -type f -name '*.cpp' -o -name '*.h'`; if [ "$?x" = '1x' ]; then echo "Key [$key] could not be found in the source code."; fi; done < /tmp/all_keys.txt Beware of false positives:
 * Keys which end in numbers / counters are usually not found on the source code as is
 * ... (to be added)