summaryrefslogtreecommitdiffstats
path: root/packaging/wix
diff options
context:
space:
mode:
authorEduard Braun <eduard.braun2@gmx.de>2017-01-16 22:21:35 +0000
committerEduard Braun <eduard.braun2@gmx.de>2017-01-16 22:21:35 +0000
commit1c722f4ebbf5384a48668a0d9d7f4201280b76c1 (patch)
tree045a5dd0d1ad87d90b7e33e40d009f7c65d25e14 /packaging/wix
parentExtensions: run_command.py - inform user about output to stderr even if error... (diff)
downloadinkscape-1c722f4ebbf5384a48668a0d9d7f4201280b76c1.tar.gz
inkscape-1c722f4ebbf5384a48668a0d9d7f4201280b76c1.zip
Packaging: Sort translations by name in Windows .exe and .msi installers (before they were sorted by language code)
This commit also adds functionality to automatically parse localized language names from the Inkscape .po file for the NSIS (.exe) installer Python scripts for Windows packaging are now Python 2/3 compatible and should always handle unicode characters properly. Fixed bugs: - https://launchpad.net/bugs/1654460 (bzr r15418)
Diffstat (limited to 'packaging/wix')
-rw-r--r--packaging/wix/files.py16
-rw-r--r--packaging/wix/helpers.py6
2 files changed, 18 insertions, 4 deletions
diff --git a/packaging/wix/files.py b/packaging/wix/files.py
index 7034021ac..9bf5f393e 100644
--- a/packaging/wix/files.py
+++ b/packaging/wix/files.py
@@ -1,13 +1,22 @@
#!/usr/bin/python
from __future__ import print_function
+from __future__ import unicode_literals # make all literals unicode strings by default (even in Python 2)
import os
import re
import uuid
+from io import open # needed for support of encoding parameter in Python 2
from helpers import get_inkscape_dist_dir, get_inkscape_locales_and_names
+# basestring is not available in Python 3
+try:
+ basestring
+except NameError:
+ basestring = (str,bytes)
+
+
directory_ids = {}
file_ids = {}
@@ -88,7 +97,7 @@ inkscape_dist_dir = get_inkscape_dist_dir()
# get locales currently supported by Inkscape (dict of the form {'de': 'German (de)'})
locales = get_inkscape_locales_and_names()
-with open('files.wxs', 'w') as wxs:
+with open('files.wxs', 'w', encoding='utf-8') as wxs:
wxs.write("<!-- do not edit, this file is created by files.py tool any changes will be lost -->\n")
wxs.write("<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\n")
wxs.write(indent(1) + "<?include version.wxi?>\n")
@@ -125,8 +134,9 @@ with open('files.wxs', 'w') as wxs:
# create a FeatureGroup for translations
wxs.write(indent(2) + "<FeatureGroup Id='Translations'>\n")
- for lang_code in sorted(locales):
- wxs.write(indent(3) + "<Feature Id='Translation_" + valid_id(lang_code) + "' Level='1' Title='" + locales[lang_code] + "' AllowAdvertise='no'>\n")
+ sorted_locales = sorted( ((v,k) for k,v in locales.items()) ) # sort by language name (instead of language code)
+ for lang_name, lang_code in sorted_locales:
+ wxs.write(indent(3) + "<Feature Id='Translation_" + valid_id(lang_code) + "' Level='1' Title='" + lang_name + "' AllowAdvertise='no'>\n")
wxs.write(indent(4) + "<ComponentGroupRef Id='Translation_" + valid_id(lang_code) + "' />\n")
wxs.write(indent(3) + "</Feature>\n")
wxs.write(indent(2) + "</FeatureGroup>\n")
diff --git a/packaging/wix/helpers.py b/packaging/wix/helpers.py
index 7bd706398..4e8ef4547 100644
--- a/packaging/wix/helpers.py
+++ b/packaging/wix/helpers.py
@@ -1,10 +1,12 @@
#!/usr/bin/python
from __future__ import print_function
+from __future__ import unicode_literals # make all literals unicode strings by default (even in Python 2)
import os
import re
import sys
+from io import open # needed for support of encoding parameter in Python 2
# check where to look for the Inkscape files to bundle
@@ -35,13 +37,15 @@ def get_inkscape_locales():
# get the list of available Inkscape UI translations (by parsing inkscape-preferences.cpp)
+# (note that this is also used in /packaging/win32/languages/_language_lists.py, don't break it!)
def get_inkscape_locales_and_names():
re_languages = re.compile(r'Glib::ustring languages\[\] = \{(.+?)\};', re.DOTALL)
re_langValues = re.compile(r'Glib::ustring langValues\[\] = \{(.+?)\};', re.DOTALL)
re_quotes = re.compile(r'"(.*?)"')
# get the raw array contents from inkscape-preferences.cpp
- with open('..\\..\\src\\ui\\dialog\\inkscape-preferences.cpp', 'r') as f:
+ filepath = os.path.join(os.path.dirname(__file__), '../../src/ui/dialog/inkscape-preferences.cpp')
+ with open(filepath, 'r', encoding='utf-8') as f:
languages = re.search(re_languages, f.read())
f.seek(0)
langValues = re.search(re_langValues, f.read())