diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 23e1f7776..2a6ff1d88 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,7 @@ before_script: test: script: - - ./app/tools/check-string-format.py + - ./tools/check-format-strings.py - ./gradlew assemble -PdisablePreDex # always report on lint errors to the build log - sed -i -e 's,textReport .*,textReport true,' app/build.gradle diff --git a/app/tools/check-string-format.py b/tools/check-format-strings.py similarity index 100% rename from app/tools/check-string-format.py rename to tools/check-format-strings.py diff --git a/app/tools/remove-unused-trans.py b/tools/remove-unused-and-blank-translations.py similarity index 65% rename from app/tools/remove-unused-trans.py rename to tools/remove-unused-and-blank-translations.py index 7863c2774..d623d7f56 100755 --- a/app/tools/remove-unused-trans.py +++ b/tools/remove-unused-and-blank-translations.py @@ -1,19 +1,23 @@ #!/usr/bin/env python3 -# Remove extra translations +# This script removes strings from the translated files that are not useful: +# * translations for strings that are no longer used +# * empty translated strings, English is better than no text at all import glob import os import re from xml.etree import ElementTree +resdir = os.path.join(os.path.dirname(__file__), '..', 'app', 'src', 'main', 'res') + strings = set() -for e in ElementTree.parse(os.path.join('src', 'main', 'res', 'values', 'strings.xml')).getroot().findall('.//string'): +for e in ElementTree.parse(os.path.join(resdir, 'values', 'strings.xml')).getroot().findall('.//string'): name = e.attrib['name'] strings.add(name) -for d in glob.glob(os.path.join('src', 'main', 'res', 'values-*')): +for d in glob.glob(os.path.join(resdir, 'values-*')): str_path = os.path.join(d, 'strings.xml') if os.path.exists(str_path):