diff --git a/Makefile b/Makefile index f0d1dc1d..064185ea 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,7 @@ check-translations: @-$(foreach lang,$(languages), \ msgcmp resources/language/resource.language.$(lang)/strings.po resources/language/resource.language.en_gb/strings.po; \ ) + @tests/check_for_unused_translations.py check-addon: clean @echo -e "$(white)=$(blue) Starting sanity addon tests$(reset)" diff --git a/tests/check_for_unused_translations.py b/tests/check_for_unused_translations.py new file mode 100755 index 00000000..3122bb08 --- /dev/null +++ b/tests/check_for_unused_translations.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" Quick and dirty way to check if all translations might be used. """ + +# pylint: disable=invalid-name,superfluous-parens + +import subprocess +import sys + +import polib + +error = 0 + +# Load all python code from git +code = subprocess.check_output(['git', 'grep', '', '--', 'resources/*.py', 'resources/settings.xml']).decode('utf-8') + +# Load po file +po = polib.pofile('resources/language/resource.language.en_gb/strings.po') +for entry in po: + # Extract msgctxt + msgctxt = entry.msgctxt.lstrip('#') + + if msgctxt not in code: + print('No usage found for translation:') + print(entry) + error = 1 + +sys.exit(error)