From ac80feccd8acc211d951d230bc6bdd592203d34c Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sun, 19 Nov 2017 12:26:21 +0000 Subject: [PATCH] Open .tmpl files as utf-8 when extracting translation strings Write them as utf-8 too... --- translation_pot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translation_pot.py b/translation_pot.py index 69a87aed..7def90a9 100755 --- a/translation_pot.py +++ b/translation_pot.py @@ -40,7 +40,7 @@ pattern = re.compile(r'<\?\s*(?:FORMAT|(PLURAL))\s+(?:CTX="([^"]+?)"\s+)?"([^"]+ for tmpl_dir in args.tmpl_dirs: for fname in glob.iglob(tmpl_dir + '/*.tmpl'): fbase = fname[len(args.strip_prefix):] - with open(fname) as f: + with open(fname, 'rt', encoding='utf8') as f: for linenum, line in enumerate(f): for x in pattern.finditer(line): text, plural, context = x.group(3), x.group(4), x.group(2) @@ -56,7 +56,7 @@ for tmpl_dir in args.tmpl_dirs: tmpl.append('msgstr ""') tmpl.append('') if tmpl: - with open(tmpl_pot, 'w') as f: + with open(tmpl_pot, 'wt', encoding='utf8') as f: print('msgid ""', file=f) print('msgstr ""', file=f) print(r'"Content-Type: text/plain; charset=UTF-8\n"', file=f)