From 4c1c4c28bf5dd4330c73106f99b4cef5d138429a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 27 Feb 2019 16:50:17 +0100 Subject: [PATCH] script to convert inline Summary to translatable file https://forum.f-droid.org/t/translating-lots-of-app-summaries/ --- tools/make-summary-translatable.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 tools/make-summary-translatable.py diff --git a/tools/make-summary-translatable.py b/tools/make-summary-translatable.py new file mode 100755 index 0000000000..369618eaa9 --- /dev/null +++ b/tools/make-summary-translatable.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import glob +import os +import re +import yaml + +os.chdir(os.path.dirname(__file__) + '/../') + +for f in glob.glob('metadata/*.yml'): + with open(f) as fp: + raw = fp.read() + data = yaml.load(raw) + archive_policy = data.get('ArchivePolicy') + if 'Disabled' not in data and 'Summary' in data \ + and (archive_policy is None or not archive_policy.startswith('0 ')): + en_US_dir = f[:-4] + '/en-US/' + os.makedirs(en_US_dir, exist_ok=True) + with open(en_US_dir + '/summary.txt', 'w') as fp: + fp.write(data['Summary'].strip().rstrip() + '\n') + with open(f, 'w') as out: + out.write(re.sub(r'Summary:[^\n]+\n', r'', raw))