Author: Adam <git@apiote.tk>
add check_translation script
i18n/check_translation | 42 ++++++++++++++++++++++++++++++++++++++++++
diff --git a/i18n/check_translation b/i18n/check_translation new file mode 100755 index 0000000000000000000000000000000000000000..56d02d26d4be7d9664233e45f68f831c2a73db39 --- /dev/null +++ b/i18n/check_translation @@ -0,0 +1,42 @@ +#!/bin/sh + +if [ "$1" = '' ] +then + echo "usage check_translation <file>" + exit 1 +fi + +if [ ! -f "$1" ] +then + echo "Translation $1 does not exist" + exit 1 +fi + +default_all=$(grep -c '=' < default.toml) +default_untranslatable=$(grep -c '^#untranslatable' < default.toml) +default=$(( default_all - default_untranslatable )) + +translated_all=$(grep -c '=' < "$1") +translated_untranslatable=$(grep -c '^#untranslatable' < "$1") +translated=$(( translated_all - translated_untranslatable )) + +left=$(( default - translated )) + +if [ "$translated_untranslatable" -ne 0 ] +then + echo "Untranslatable strings in $1" + status=1 +fi + +percent=$((translated * 100 / default)) +echo "$percent% translated" + +if [ $left -gt 0 ] +then + echo "There are $left strings left to translate" +elif [ $left -eq 0 ] +then + echo "All strings translated" +fi + +exit $status