summaryrefslogtreecommitdiffstats
path: root/util/locale_database/cldr2qlocalexml.py
diff options
context:
space:
mode:
Diffstat (limited to 'util/locale_database/cldr2qlocalexml.py')
-rwxr-xr-xutil/locale_database/cldr2qlocalexml.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/util/locale_database/cldr2qlocalexml.py b/util/locale_database/cldr2qlocalexml.py
index 072ea9e4ed..625f1c32c4 100755
--- a/util/locale_database/cldr2qlocalexml.py
+++ b/util/locale_database/cldr2qlocalexml.py
@@ -2,7 +2,7 @@
# coding=utf8
#############################################################################
##
-## Copyright (C) 2018 The Qt Company Ltd.
+## Copyright (C) 2020 The Qt Company Ltd.
## Contact: https://www.qt.io/licensing/
##
## This file is part of the test suite of the Qt Toolkit.
@@ -314,7 +314,7 @@ def _generateLocaleInfo(path, language_code, script_code, country_code, variant_
result['zero'] = get_number_in_system(path, "numbers/symbols/nativeZeroDigit", numbering_system)
result['minus'] = get_number_in_system(path, "numbers/symbols/minusSign", numbering_system)
result['plus'] = get_number_in_system(path, "numbers/symbols/plusSign", numbering_system)
- result['exp'] = get_number_in_system(path, "numbers/symbols/exponential", numbering_system).lower()
+ result['exp'] = get_number_in_system(path, "numbers/symbols/exponential", numbering_system)
result['quotationStart'] = findEntry(path, "delimiters/quotationStart")
result['quotationEnd'] = findEntry(path, "delimiters/quotationEnd")
result['alternateQuotationStart'] = findEntry(path, "delimiters/alternateQuotationStart")
@@ -352,13 +352,15 @@ def _generateLocaleInfo(path, language_code, script_code, country_code, variant_
result['currencySymbol'] = ''
result['currencyDisplayName'] = ''
if result['currencyIsoCode']:
- result['currencySymbol'] = findEntryDef(path, "numbers/currencies/currency[%s]/symbol" % result['currencyIsoCode'])
- result['currencyDisplayName'] = ';'.join(
- findEntryDef(path, 'numbers/currencies/currency[' + result['currencyIsoCode']
- + ']/displayName' + tail)
- for tail in ['',] + [
- '[count=%s]' % x for x in ('zero', 'one', 'two', 'few', 'many', 'other')
- ]) + ';'
+ stem = "numbers/currencies/currency[%s]/" % result['currencyIsoCode']
+ result['currencySymbol'] = findEntryDef(path, stem + 'symbol')
+ displays = tuple(findEntryDef(path, stem + 'displayName' + tail)
+ for tail in ('',) + tuple(
+ '[count=%s]' % x for x in ('zero', 'one', 'two',
+ 'few', 'many', 'other')))
+ while displays and not displays[-1]:
+ displays = displays[:-1]
+ result['currencyDisplayName'] = ';'.join(displays)
def findUnitDef(path, stem, fallback=''):
# The displayName for a quantified unit in en.xml is kByte
@@ -405,7 +407,7 @@ def _generateLocaleInfo(path, language_code, script_code, country_code, variant_
prop = 'monthContext[' + mode + ']/monthWidth[' + size + ']/'
result[key + 'Months_' + cal] = ';'.join(
findEntry(path, stem + prop + "month[%d]" % i)
- for i in range(1, 13)) + ';'
+ for i in range(1, 13))
# Day data (for Gregorian, at least):
stem = 'dates/calendars/calendar[gregorian]/days/'
@@ -414,7 +416,7 @@ def _generateLocaleInfo(path, language_code, script_code, country_code, variant_
prop = 'dayContext[' + mode + ']/dayWidth[' + size + ']/day'
result[key + 'Days'] = ';'.join(
findEntry(path, stem + prop + '[' + day + ']')
- for day in days) + ';'
+ for day in days)
return Locale(result)
@@ -582,6 +584,10 @@ for line in ldml:
if 'version cldrVersion CDATA #FIXED' in line:
cldr_version = line.split('"')[1]
+if sys.stdout.encoding != 'UTF-8' or (sys.stdout.encoding is None and sys.getdefaultencoding() != 'UTF-8'):
+ reload(sys) # Weirdly, this gets a richer sys module than the plain import got us !
+ sys.setdefaultencoding('UTF-8')
+
print "<localeDatabase>"
print " <version>" + cldr_version + "</version>"
print " <languageList>"