summaryrefslogtreecommitdiffstats
path: root/util/locale_database/cldr2qlocalexml.py
diff options
context:
space:
mode:
authorSoroush Rabiei <soroush@ametisco.ir>2017-01-14 20:23:31 +0330
committerEdward Welbourne <edward.welbourne@qt.io>2019-08-20 13:41:21 +0200
commitaa8393c94fea01a4806b204fd3aa343a4e90666b (patch)
tree071cf0bd8934b094d4e0208a25c11f439acb8173 /util/locale_database/cldr2qlocalexml.py
parent8f083bade0ba33d4be8a2d3ed1b5ce005aab6d8d (diff)
Add support for calendars beside Gregorian
Add QCalendarBackend as a base class for calendar implementations and QCalendar as a facade via which to access it. QDate's implicit implementation of the Gregorian calendar becomes QGregorianCalendar and QDate methods now support choice of calendar. Convert QLocale's CLDR data for month names to a locale-data component of each supported calendar and relevant QLocale methods now support choice of calendar. Adapt Python scripts for locale data generation to extract month name data from CLDR (keeping on version v35.1) into the new calendar-locale files. The locale data for the Gregorian calendar is held in a Roman calendar base, for sharing with other calendars. Add tests for basic uses of the new API. [ChangeLog][QtCore][QCalendar] Added QCalendar to support diverse calendars, supported by implementing QCalendarBackend. [ChangeLog][QtCore][QDate] Allow choice of calendar in various operations, with Gregorian remaining the default. Done-with: Lars Knoll <lars.knoll@qt.io> Done-with: Edward Welbourne <edward.welbourne@qt.io> Fixes: QTBUG-17110 Fixes: QTBUG-950 Change-Id: I9d6278f394269a183aee8156e990cec4d5198ab8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'util/locale_database/cldr2qlocalexml.py')
-rwxr-xr-xutil/locale_database/cldr2qlocalexml.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/util/locale_database/cldr2qlocalexml.py b/util/locale_database/cldr2qlocalexml.py
index 1982e3ba27..4bc735976b 100755
--- a/util/locale_database/cldr2qlocalexml.py
+++ b/util/locale_database/cldr2qlocalexml.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python2
+# coding=utf8
#############################################################################
##
-## Copyright (C) 2017 The Qt Company Ltd.
+## Copyright (C) 2018 The Qt Company Ltd.
## Contact: https://www.qt.io/licensing/
##
## This file is part of the test suite of the Qt Toolkit.
@@ -62,6 +63,8 @@ from xpathlite import DraftResolution, findAlias, findEntry, findTagsInFile
from dateconverter import convert_date
from localexml import Locale
+# TODO: make calendars a command-line option
+calendars = ['gregorian'] # 'persian', 'islamic', 'hebrew'
findEntryInFile = xpathlite._findEntryInFile
def wrappedwarn(prefix, tokens):
return sys.stderr.write(
@@ -395,12 +398,12 @@ def _generateLocaleInfo(path, language_code, script_code, country_code, variant_
('narrow', 'format', 'narrow'),
)
- # Month data:
- for cal in ('gregorian',): # We shall want to add to this
+ # Month names for 12-month calendars:
+ for cal in calendars:
stem = 'dates/calendars/calendar[' + cal + ']/months/'
for (key, mode, size) in namings:
prop = 'monthContext[' + mode + ']/monthWidth[' + size + ']/'
- result[key + 'Months'] = ';'.join(
+ result[key + 'Months_' + cal] = ';'.join(
findEntry(path, stem + prop + "month[%d]" % i)
for i in range(1, 13)) + ';'
@@ -686,9 +689,9 @@ if skips:
wrappedwarn('skipping likelySubtags (for unknown language codes): ', skips)
print " <localeList>"
-Locale.C().toXml()
+Locale.C(calendars).toXml(calendars)
for key in locale_keys:
- locale_database[key].toXml()
+ locale_database[key].toXml(calendars)
print " </localeList>"
print "</localeDatabase>"