diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-05-09 01:00:49 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-05-09 13:06:11 +0000 |
commit | e56d3b03ed92743f33eb7ca1a5aa61dbdedaf19b (patch) | |
tree | c29a80a940cca1281014732aff4237c915f32dc4 /util | |
parent | 2a79af6b5c67eba6f967c7443bf73bbe11206a62 (diff) | |
parent | 9444416a46ee0e6bb0d9d9be9a4883b388644c59 (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
src/corelib/tools/qlocale_data_p.h
(Regenerated by running the scripts in util/local_database/)
src/gui/opengl/qopengltextureuploader.cpp
Done-With: Edward Welbourne <edward.welbourne@qt.io>
Done-With: Allan Sandfeld Jensen <allan.jensen@qt.io>
Change-Id: I12df7f066ed0a25eb109f61c4b8d8dea63b683e2
Diffstat (limited to 'util')
-rwxr-xr-x | util/local_database/cldr2qlocalexml.py | 2 | ||||
-rw-r--r-- | util/local_database/localexml.py | 48 |
2 files changed, 37 insertions, 13 deletions
diff --git a/util/local_database/cldr2qlocalexml.py b/util/local_database/cldr2qlocalexml.py index bc999e1b65..4ce0a6e3b1 100755 --- a/util/local_database/cldr2qlocalexml.py +++ b/util/local_database/cldr2qlocalexml.py @@ -31,7 +31,7 @@ The CLDR data can be downloaded from CLDR_, which has a sub-directory for each version; you need the ``core.zip`` file for your version of choice (typically the latest). This script has had updates to cope up -to v29; for later versions, we may need adaptations. Unpack the +to v35; for later versions, we may need adaptations. Unpack the downloaded ``core.zip`` and check it has a common/main/ sub-directory: pass the path of that sub-directory to this script as its single command-line argument. Save its standard output (but not error) to a diff --git a/util/local_database/localexml.py b/util/local_database/localexml.py index a47fa6a5ff..e95b3aebcc 100644 --- a/util/local_database/localexml.py +++ b/util/local_database/localexml.py @@ -53,7 +53,21 @@ def ordStr(c): def fixOrdStr(c, d): return str(ord(c if len(c) == 1 else d)) +def startCount(c, text): # strspn + """First index in text where it doesn't have a character in c""" + assert text and text[0] in c + try: + return (j for j, d in enumerate(text) if d not in c).next() + except StopIteration: + return len(text) + def convertFormat(format): + """Convert date/time format-specier from CLDR to Qt + + Match up (as best we can) the differences between: + * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table + * QDateTimeParser::parseFormat() and QLocalePrivate::dateTimeToString() + """ result = "" i = 0 while i < len(format): @@ -68,20 +82,30 @@ def convertFormat(format): i += 1 else: s = format[i:] - if s.startswith("EEEE"): - result += "dddd" - i += 4 - elif s.startswith("EEE"): - result += "ddd" - i += 3 - elif s.startswith("a"): + if s.startswith('E'): # week-day + n = startCount('E', s) + if n < 3: + result += 'ddd' + elif n == 4: + result += 'dddd' + else: # 5: narrow, 6 short; but should be name, not number :-( + result += 'd' if n < 6 else 'dd' + i += n + elif s[0] in 'ab': # am/pm + # 'b' should distinguish noon/midnight, too :-( result += "AP" - i += 1 - elif s.startswith("z"): + i += startCount('ab', s) + elif s.startswith('S'): # fractions of seconds: count('S') == number of decimals to show + result += 'z' + i += startCount('S', s) + elif s.startswith('V'): # long time zone specifiers (and a deprecated short ID) + result += 't' + i += startCount('V', s) + elif s[0] in 'zv': # zone + # Should use full name, e.g. "Central European Time", if 'zzzz' :-( + # 'v' should get generic non-location format, e.g. PT for "Pacific Time", no DST indicator result += "t" - i += 1 - elif s.startswith("v"): - i += 1 + i += startCount('zv', s) else: result += format[i] i += 1 |