From dc6eccc218891dc57300bf88663b39de38ddd182 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 30 May 2017 15:50:44 +0200 Subject: [PATCH] workaround Weblate bug for languages with no plurals https://github.com/WeblateOrg/weblate/issues/520 --- tools/remove-unused-and-blank-translations.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/remove-unused-and-blank-translations.py b/tools/remove-unused-and-blank-translations.py index 31f75679d..6fafc7777 100755 --- a/tools/remove-unused-and-blank-translations.py +++ b/tools/remove-unused-and-blank-translations.py @@ -23,6 +23,15 @@ for d in sorted(glob.glob(os.path.join(resdir, 'values-*'))): if not os.path.exists(str_path): continue + with open(str_path, 'rb') as fp: + body = fp.read() + body = re.sub(b'.*.*\n', b'', body) + # Weblate is not handling plurals right https://github.com/WeblateOrg/weblate/issues/520 + if os.path.basename(d)[7:9] in ('ja', 'ko', 'zh'): + body = re.sub(b'', b'', body) + with open(str_path, 'wb') as fp: + fp.write(body) + header = '' with open(str_path, 'r') as f: header = f.readline()