summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorSoroush Rabiei <soroush@ametisco.ir>2019-08-08 20:35:13 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2019-08-22 10:10:02 +0000
commit702664571252e4f5705e39a8258fc81a3fbf37d4 (patch)
tree01abab3715dfe2f5193dc56802c1b0d50870cc0d /util
parenta8cc4cea92bfe4c251458722cbd2e60c49024a2d (diff)
Add support for the Islamic Civil calendar
This has its own locale data, extracted from CLDR. This data may potentially be shared with other variants on the Islamic calendar, so is handled by a separate base-class, QHijriCalendar, on which such variants may base their implementations. [ChangeLog][QtCore][QCalendar] Added support for the Islamic Civil calendar, controlled by feature islamiccivilcalendar, with locale data that can be shared with other implementations, controlled by feature hijricalendar. Fixes: QTBUG-56675 Change-Id: Idf32d3da7034baa8ec5e66ef847e59a8a2f31cbd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-xutil/locale_database/cldr2qlocalexml.py2
-rw-r--r--util/locale_database/localexml.py17
-rwxr-xr-xutil/locale_database/qlocalexml2cpp.py2
3 files changed, 18 insertions, 3 deletions
diff --git a/util/locale_database/cldr2qlocalexml.py b/util/locale_database/cldr2qlocalexml.py
index b611aa7eb7..072ea9e4ed 100755
--- a/util/locale_database/cldr2qlocalexml.py
+++ b/util/locale_database/cldr2qlocalexml.py
@@ -64,7 +64,7 @@ from dateconverter import convert_date
from localexml import Locale
# TODO: make calendars a command-line option
-calendars = ['gregorian', 'persian'] # 'islamic', 'hebrew'
+calendars = ['gregorian', 'persian', 'islamic'] # 'hebrew'
findEntryInFile = xpathlite._findEntryInFile
def wrappedwarn(prefix, tokens):
return sys.stderr.write(
diff --git a/util/locale_database/localexml.py b/util/locale_database/localexml.py
index 72b1dc2acc..9b353f5122 100644
--- a/util/locale_database/localexml.py
+++ b/util/locale_database/localexml.py
@@ -225,6 +225,15 @@ class Locale:
def firstThree(i, name): return name[:3]
def initial(i, name): return name[:1]
def number(i, name): return str(i + 1)
+ def islamicShort(i, name):
+ if not name: return name
+ if name == 'Shawwal': return 'Shaw.'
+ words = name.split()
+ if words[0].startswith('Dhu'):
+ words[0] = words[0][:7] + '.'
+ elif len(words[0]) > 3:
+ words[0] = words[0][:3] + '.'
+ return ' '.join(words)
@staticmethod
def __monthNames(calendars,
known={ # Map calendar to (names, extractors...):
@@ -239,6 +248,12 @@ class Locale:
(fullName, fullName),
(firstThree, firstThree),
(number, initial)),
+ 'islamic': ((u'Muharram', u'Safar', u'Rabiʻ I', u'Rabiʻ II', u'Jumada I',
+ u'Jumada II', u'Rajab', u'Shaʻban', u'Ramadan', u'Shawwal',
+ u'Dhuʻl-Qiʻdah', u'Dhuʻl-Hijjah'),
+ (fullName, fullName),
+ (islamicShort, islamicShort),
+ (number, number)),
'hebrew': (('Tishri', 'Heshvan', 'Kislev', 'Tevet', 'Shevat', 'Adar I',
'Adar', 'Nisan', 'Iyar', 'Sivan', 'Tamuz', 'Av'),
(fullName, fullName),
@@ -258,7 +273,7 @@ class Locale:
';'.join(get[n][0](i, x) for i, x in enumerate(names)))
yield ('_'.join((camelCase(('standalone', size, 'months')), cal)),
';'.join(get[n][1](i, x) for i, x in enumerate(names)))
- del fullName, firstThree, initial, number
+ del fullName, firstThree, initial, number, islamicShort
@classmethod
def C(cls, calendars=('gregorian',),
diff --git a/util/locale_database/qlocalexml2cpp.py b/util/locale_database/qlocalexml2cpp.py
index 130c2dca73..a5ff7ebbf4 100755
--- a/util/locale_database/qlocalexml2cpp.py
+++ b/util/locale_database/qlocalexml2cpp.py
@@ -44,7 +44,7 @@ from localexml import Locale
# TODO: Make calendars a command-line parameter
# map { CLDR name: Qt file name }
-calendars = {'gregorian': 'roman', 'persian': 'jalali',} # 'islamic': 'hijri', 'hebrew': 'hebrew',
+calendars = {'gregorian': 'roman', 'persian': 'jalali', 'islamic': 'hijri',} # 'hebrew': 'hebrew',
generated_template = """
/*