ddnet/scripts/languages
2024-08-25 00:40:12 +02:00
..
analyze.py [WIP] Require Python 3.6 (f-strings) and fix pylints 2022-07-27 09:37:24 +02:00
copy_fix.py Fix performance regression in copy_fix.py 2024-05-19 19:47:12 +02:00
find_unchanged.py Add pylint 2020-12-09 10:40:28 +01:00
readme.txt Fix misspellings 2022-10-25 13:51:56 -03:00
twlang.py Validate language files for and non-matching formatters 2024-08-25 00:40:12 +02:00
update_all.py [WIP] Require Python 3.6 (f-strings) and fix pylints 2022-07-27 09:37:24 +02:00
validate.py Validate language files for and non-matching formatters 2024-08-25 00:40:12 +02:00

Teeworlds language scripts by timakro

These scripts can help you to improve the language files. This is a short tutorial
about how to use the scripts.


You can start by analyzing the current languages using analyze.py
$ ./analyze.py

analyze.py outputs several columns. The column 'total' is the number of
translations in the file. 'empty' is the number of untranslated phrases in the
file. The 2nd and 3rd columns are calculated by looking into the source. The script
searches through the source for all phrases. 'missing' is the number of phrases in
the source but not in the file. 'unused' is the number of phrases in the file but
not in the source.


To update a language you should first copy it using the copy_fix.py script.
$ ./copy_fix.py ../spanish.txt newspanish.txt --delete-unused --append-missing

Then you can start to modify newspanish.txt. Search in the file for the following
line and remove it:
##### generated by copy_fix.py, please translate this #####

Every phrase below this line should be empty. Now you can fill in the translations
you know. It's also okay to write just the same phrase as in english for words like
'Hookcollision' or 'Screenshot'. If you don't know how to translate something just
remove it.

That's all, you improved the translation. If you want you can add your name at the
start of the file. Now you can move the file back to its original location.
$ mv newspanish.txt ../spanish.txt


Often people know better phrases for translations where the english phrase was just
copied. To find these you can use find_unchanged.py
$ ./find_unchanged.py ../spanish.txt

To update all languages:

$ ./update_all.py

To get a statistic of how complete the translation is:

$ for i in data/languages/*.txt; do COVERED=$(cat $i|grep "^== "|grep -v "^== $"|wc -l); TOTAL=$(cat $i|grep "^== "|wc -l); [ "${i:t}" != "license.txt" ] && [ "${i:t}" != "index.txt" ] && echo "$(($COVERED*100/$TOTAL))% ${i:r:t}"; done | sort -n -r