From 38403338da1ee858fb9fd53b206500c8cd7bce0b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 10 May 2017 11:47:38 +0200 Subject: [PATCH] remove xmlns tools:ignore from translations XML namespaces are a massive pain to deal with in, and they are totally unneeded in the translation files. xmlns:tools is only needed in the source file to ignore some lint warnings. --- app/src/main/res/values-kn/strings.xml | 10 +++++----- tools/remove-unused-and-blank-translations.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/values-kn/strings.xml b/app/src/main/res/values-kn/strings.xml index ea8e0a014..cb719008f 100644 --- a/app/src/main/res/values-kn/strings.xml +++ b/app/src/main/res/values-kn/strings.xml @@ -1,5 +1,5 @@ -ಎಫ್-ಡ್ರಾಯ್ಡ್ +ಎಫ್-ಡ್ರಾಯ್ಡ್ ಆವೃತ್ತಿ ಅನುಸ್ಥಾಪಿಸು @@ -31,10 +31,10 @@ ನನ್ನ ಹತ್ತಿರವಿರುವ ಜನರನ್ನು ಹುಡುಕು ಅನುಸ್ಥಾಪಿಸಲಾಗುತ್ತಿದೆ… ಅನುಸ್ಥಾಪಿಸು - ಸಮಯ - ಸುರಕ್ಷತೆ - ಕ್ರೀಡೆ & ಆರೋಗ್ಯ - ಆಟಗಳು + ಸಮಯ + ಸುರಕ್ಷತೆ + ಕ್ರೀಡೆ & ಆರೋಗ್ಯ + ಆಟಗಳು ವೈ-ಫೈ ಭಾಷೆ ಹೆಸರು diff --git a/tools/remove-unused-and-blank-translations.py b/tools/remove-unused-and-blank-translations.py index 3ef71036d..811305bfa 100755 --- a/tools/remove-unused-and-blank-translations.py +++ b/tools/remove-unused-and-blank-translations.py @@ -26,8 +26,14 @@ for d in sorted(glob.glob(os.path.join(resdir, 'values-*'))): header = '' with open(str_path, 'r') as f: header = f.readline() - tree = ElementTree.parse(str_path) - root = tree.getroot() + + # handling XML namespaces in Python is painful, just remove them, they + # should not be in the translation files anyway + with open(str_path, 'rb') as fp: + contents = fp.read() + contents = contents.replace(b' tools:ignore="UnusedResources"', b'') \ + .replace(b' xmlns:tools="http://schemas.android.com/tools"', b'') + root = ElementTree.fromstring(contents) for e in root.findall('.//string'): name = e.attrib['name']