summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2020-04-01 19:24:03 +0300
committerJan-Marek Glogowski <glogow@fbihome.de>2020-04-02 12:58:03 +0200
commitb9ba707ad95889db8e3dd04766aadc5d5c95cfaf (patch)
treee33cb48fa206fc86719a43702eb02c5c7e1ef6a8 /solenv
parent84b884135ee419fe7abfefa7b4b651a649cf9ad9 (diff)
Always treat desktop-translate files as utf-8.
Fixes a regression from commit d2c23609083d7b3e5267b1e4c923476cbc509d00 ("tdf#130911: convert desktop-translate from Perl to Python."), which breaks gallery generation on some Windows machines. Python tries to decode the utf-8 files with cp1252 on some machines and that fails with a UnicodeDecodeError exception. Change-Id: Ic82e5e3b2c21fc4b4bc32944ae7112bff14ccba1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91505 Tested-by: Jan-Marek Glogowski <glogow@fbihome.de> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'solenv')
-rw-r--r--solenv/bin/desktop-translate.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/solenv/bin/desktop-translate.py b/solenv/bin/desktop-translate.py
index e0dbc3078082..3ae49ae576ee 100644
--- a/solenv/bin/desktop-translate.py
+++ b/solenv/bin/desktop-translate.py
@@ -22,7 +22,7 @@
# l10ntools/source/localize.cxx
#
-import os, sys, argparse
+import os, sys, argparse, io
parser = argparse.ArgumentParser()
parser.add_argument('-p', dest='productname', default='LibreOffice')
@@ -50,7 +50,7 @@ else:
templates = {}
# open input file
-source = open(o.ifile)
+source = io.open(o.ifile, encoding='utf-8')
template = None
@@ -99,7 +99,7 @@ for template in templates:
# open the template file - ignore sections for which no
# templates exist
try:
- template_file = open(outfilename)
+ template_file = io.open(outfilename, encoding='utf-8')
except Exception:
# string files processed one by one
if o.ext == 'str':
@@ -109,7 +109,7 @@ for template in templates:
# open output file
tmpfilename = '{}.tmp'.format(outfilename)
- outfile = open(tmpfilename, 'w')
+ outfile = io.open(tmpfilename, 'w', encoding='utf-8')
# emit the template to the output file
for line in template_file:
@@ -125,9 +125,9 @@ for template in templates:
# print "value is $value\n";
if value:
if o.ext == "desktop" or o.ext == "str":
- outfile.write("""{}[{}]={}\n""".format(outkey, locale, value))
+ outfile.write(u"""{}[{}]={}\n""".format(outkey, locale, value))
else:
- outfile.write("""\t[{}]{}={}\n""".format(locale, outkey, value))
+ outfile.write(u"""\t[{}]{}={}\n""".format(locale, outkey, value))
template_file.close()