From 78bfae24710fb2f82faaaefeda68d50ecb678ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Arnauts?= Date: Mon, 20 Apr 2020 16:09:00 +0200 Subject: [PATCH] Check for unused translations (#24) --- Makefile | 1 + .../resource.language.en_gb/strings.po | 12 -------- .../resource.language.nl_nl/strings.po | 12 -------- tests/check_for_unused_translations.py | 28 +++++++++++++++++++ 4 files changed, 29 insertions(+), 24 deletions(-) create mode 100755 tests/check_for_unused_translations.py diff --git a/Makefile b/Makefile index 296d1ff..69681d2 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,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 build @echo ">>> Running addon checks" diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index c9cb801..88fc21b 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -18,10 +18,6 @@ msgctxt "#30003" msgid "Catalogue" msgstr "" -msgctxt "#30004" -msgid "TV Shows and Movies listed by category" -msgstr "" - msgctxt "#30007" msgid "Channels" msgstr "" @@ -42,10 +38,6 @@ msgctxt "#30013" msgid "TV guide" msgstr "" -msgctxt "#30014" -msgid "Browse the TV Guide" -msgstr "" - ### SUBMENUS msgctxt "#30053" @@ -144,10 +136,6 @@ msgctxt "#30713" msgid "The requested video was not found in the guide." msgstr "" -msgctxt "#30714" -msgid "Local metadata is cleared." -msgstr "" - msgctxt "#30715" msgid "Updating metadata" msgstr "" diff --git a/resources/language/resource.language.nl_nl/strings.po b/resources/language/resource.language.nl_nl/strings.po index ca0db7d..83edf0d 100644 --- a/resources/language/resource.language.nl_nl/strings.po +++ b/resources/language/resource.language.nl_nl/strings.po @@ -19,10 +19,6 @@ msgctxt "#30003" msgid "Catalogue" msgstr "Catalogus" -msgctxt "#30004" -msgid "TV Shows and Movies listed by category" -msgstr "Programma's en films per categorie" - msgctxt "#30007" msgid "Channels" msgstr "Kanalen" @@ -43,10 +39,6 @@ msgctxt "#30013" msgid "TV guide" msgstr "Tv-gids" -msgctxt "#30014" -msgid "Browse the TV Guide" -msgstr "Doorblader de tv-gids" - ### SUBMENUS msgctxt "#30053" @@ -145,10 +137,6 @@ msgctxt "#30713" msgid "The requested video was not found in the guide." msgstr "De gevraagde video werd niet gevonden in de tv-gids." -msgctxt "#30714" -msgid "Local metadata is cleared." -msgstr "De lokale metadata is verwijderd." - msgctxt "#30715" msgid "Updating metadata" msgstr "Vernieuwen metadata" diff --git a/tests/check_for_unused_translations.py b/tests/check_for_unused_translations.py new file mode 100755 index 0000000..3122bb0 --- /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)