weidu when the LANGUAGE tag is used and is given a list of languages. Those languages are assigned a numerical value starting with 0 and going as high as there are languages in the list. but the order of languages is different per mod since some do not have translations in other languages or the modder listed them in a different order.
OK, so we need a list of languages that each mod support, and the numbers of theses languages, and hope that modders doesn't change the order of the languages between versions... heavy work to do.
You can extract language mapping with weidu.
weidu --nogame --list-languages setup-mod.tp2Since there is no canonical names for languages in weidu you should also map language names (works for Linux)
weidu --nogame --list-languages setup-mod.tp2 | \ grep -E "^[0-9]+:" | tr "A-Z" "a-z" | \ sed -r -f fixlang.txt