Commit Graph

63 Commits

Author SHA1 Message Date
Edward Welbourne
32f1bf0cac Update QLocale::Country doc for new territories
Neglected in 44b6757fe5
Noted the need for this in a relevant script's instructions.

Change-Id: If69666f1799acebd434034c80b91056cb8777488
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-08-16 10:10:43 +00:00
Edward Welbourne
cd0a76a150 Tidy up generation of aliases in locale-related enums
Replace lines of formatted output with dictionaries from which that
output can be generated efficiently (in sorted order).  Tidy up the
python code, in the process.

Change-Id: Ifb74eb69342646c5dbabc3247b3a8ddef602e934
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-08-16 10:10:04 +00:00
Edward Welbourne
d363113745 Normalise spacing in Language, Country and Script names
The scripts that generate the C++ enum names clean out spaces, so
there's no need for enumdata.py to use the squished names; instead,
include spaces where they belong and use them in the relevant names
where they show up.

Change-Id: I7261c87d69e654bc2e89f44d7ebbc06bfb403c58
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-08-16 10:09:56 +00:00
Edward Welbourne
44b6757fe5 Add support for numbered territories in CLDR
The CLDR data contains eight locales with numeric territory codes, 001
for World, 150 for Europe and 419 for Latin America.  The last was
already known in our enumdata.py, but as "Latin America and The
Caribbean", which is not supported by the CLDR, so I've amended it
while adding the other two.  This gives us support for Esperanto and
Yiddish (among others).

[ChangeLog][QtCore][QLocale] Added support for World and Europe as
(numeric) "country" codes ("territory" in CLDR terms), thereby
enabling support for Yiddish and Esperanto, among other locales using
such codes.

Task-number: QTBUG-57802
Change-Id: Ibb1180fb720743a3a0589527649d10f3c9cd123d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-08-13 16:17:53 +00:00
Edward Welbourne
042d41e23e Rework CLDR parser to filter out unsupportable number systems
In the process, also have it only scan number systems once, caching
the result, rather than scanning all of them for each locale.  This
means we only see the new warning messages once, too.

Task-number: QTBUG-69324
Change-Id: Ia0695a0ba6159b50748a61e9949ad5bd07e4c4c3
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2018-07-16 15:22:56 +00:00
Edward Welbourne
74a20fda52 Add a note to the CLDR-munging scripts about updating the attribution
Change-Id: I9de320d10ddd8947f3f6cf29636e42f08f814a28
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2018-02-17 22:22:33 +00:00
Edward Welbourne
424d9e9e56 Add byte-based units to CLDR data
Scan CLDR for {,kilo,mega,giga,tera,peta,exa}byte forms and their IEC
equivalents, providing SI and IEC defaults when missing (which all of
IEC are) in addition to the usual numeric data.  Extrapolate from any
present data (e.g. French's ko, Mo, Go, To imply Po, Eo and, for IEC,
Kio, Mio, etc.), since CLDR only goes up to tera.  Propagate this data
to QLocale's database ready for use by QLocale::formattedDataSize().

Change-Id: Ie6ee978948c68be9f71ab784a128cbfae3d80ee1
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2017-06-13 11:28:09 +00:00
Edward Welbourne
267edbec19 Clean up in CLDR scripts for QLocale
Use python more fluently; DRY - use functions to avoid repetition; use
dict-comprehensions; use os.path.join() in preference to arithmetic
with path strings; use elsif to avoid the need for a local variable;
set() can take a generator directly, no need to go via a list; don't
end lines in semicolon (this is python).  Test isdir() once instead of
exists() twice on the same name.

Just, generally, use python's feature-set.

Change-Id: Ib114aa016f70b3be09e968d9cfc069b057f49d41
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-09 08:24:55 +00:00
Edward Welbourne
6a4875f0d1 Replace three functions with one simpler function
load{Language,Script,Country}Map() were all structurally very similar,
so replace them with a single loadMap() that takes a second argument
to say *which* map to load.  At the same time, use a dict
comprehension to simplify constructing the result.

Change-Id: Ie43a71156010277200543a8937056efd35251955
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-09 08:24:40 +00:00
Edward Welbourne
e93af7dafd Turn a next-node function into an iterator over nodes
This simplifies a duplicated iteration pattern in the calling code.
It also frees the first-node function to raise an Error (which the
iterator now catches) if it finds no node, where it used to return
False (instead of a node, so other code using it would raise confusing
errors from trying to use False as a node, where now it'll get a clear
Error about a missing node).  There were also no callers passing an
empty name, so the test for matching nodes (here moved to its own
short function) didn't need to handle that as a special case.

Change-Id: Ife6cad8943cf5dc2c6ed68429d4a217cb9bea446
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-09 08:24:33 +00:00
Edward Welbourne
ad1cec5a5e Simplify cldr2qlocalexml.integrateWeekData()
It had a separate variable for each of three lists for each day of the
week; and used each list only once.  Iterate the days of the week for
each lookup, discarding it once used.

Change-Id: I32c8bd5bfcbb99f0a8697d374e63112761f18dbb
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-09 08:24:22 +00:00
Edward Welbourne
03a1675eac Reduce code duplication in writing of string data for locales
Each StringData object got its own block, of common form, to output
its C array; give each object a name so that we can automate this as
an iteration over StringData objects.  One (endonyms_data) gains a
blank line that the others all had but it lacked.

Change-Id: I96c014728a58343c82304c5117b474fee980d9c7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-09 08:24:15 +00:00
Edward Welbourne
ebb0212133 Rework locale serialization and parsing with less repetition
... because copy-and-paste is worth discouraging.  Moved code that
writes and digests our Q Local XML form of the data into a common
class, localexml.Locale, for use by the scripts that write and read
it.  Hopefully, it'll be easier to keep what's written and read in
sync hereafter.

Inlined some trivial functions in the process; and only create a
day-number mapping dictionary once, instead of once per use.  Also
made it easier to see which attributes get which special handling (and
documented this); and revised an assertion to be more helpful.

Change-Id: I711b6a193a4ad94b5ff714c025f2732cd1a965a7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-09 08:24:08 +00:00
Edward Welbourne
3a569573b2 Clean up the output code for the big table of CLDR data
Include headers for all fields (several were missing).
Make field widths explicit to headers can line up with content.
Use the same format for the (common part of the) all-zeros line.
Document and lay-out headers and format string, to make them easier to
keep in sync.  Make a pair of comments clearer.

Re-ran the script to regenerate the table: the result is best viewed
with git show -w, to ignore the spacing changes (or git show -b to
notice only the one harmless discrepancy exposed in old all-zeros
data).  Aside from spacing, locale_data[] has gained some missing
columns in its header comment, which now lines headings up properly
above actual data.

Change-Id: I44242f38391353f2ec8e144cb7e8b54b0a359341
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2017-06-08 13:37:38 +00:00
Edward Welbourne
9df60df12a Made the "do not edit generated code" notice clearer
Say where to find the scripts and make clear what to update to get
changes.

Change-Id: I424b7fdf846f7141c6df81eef90eb1ca0378bcf8
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-08 13:37:21 +00:00
Edward Welbourne
2c04d1dab5 Give reasons when skipping files
Change-Id: I397d17ad252363dd0d7d9b4f53b7d105075da306
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-08 13:37:14 +00:00
Edward Welbourne
08cfd02312 Use python more competently in CLDR/qLocaleXML scripts
Make the python2 dependency explicit (sooner or later, python3 shall
be the default /bin/env python), make time-zone script executable (it
had a shebang).  Use triple-quoted strings, or single quotes, to avoid
extra backslashes, remove some simply spurious backslashes.  Use
generators rather than map or filter with lambdas and iterate rather
than duplicating code.  Clarify some comments.

Regenerated headers: this upates the date of generation, cuts back a
double-blank-line to single and skips a spurious trailing
comma-newline on an array's data.

Change-Id: I54439f0dec132865991fe5147d509cea0f9419a0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-08 13:37:06 +00:00
Edward Welbourne
72900b3d88 Fix CLDR C++ generation to name "Han with Bopomofo" properly
We were using "Han With Bopomofo" (capitalized With) so that an enum
member in qlocale.h would be suitably camel-case; however, this lead
to spurious changes in qlocale_data_p.h where it names the script.
Use the correct (lower-case with) form and arrange for the enum
members to be generated with first letter of each word upper-case (but
not with each word capitalize()d; some words in there are already
camel-case, so .capitalize()ing would lower-case the later sub-words
in these).

Change-Id: I974c89dd40814eaf3bd538f06b9b4ebf17492f20
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-08 13:37:01 +00:00
Edward Welbourne
99dd95f3c2 Document how to use the CLDR-related scripts
Say where to find the data, how to unpack it and how to run the
scripts to update our source tree from it.

Change-Id: I5b680090bb5850f29c1e7d61efd1d450856b9949
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-08 13:36:48 +00:00
Konstantin Ritt
eb26f2b19b Re-generate QLocale data from CLDR v29
* A bunch of fixes and additions to the locale data
* Add new scripts from Unicode 8.0 and 9.0
* Map some potentially useful languages and territories

[ChangeLog][QtCore] QLocale data updated to CLDR v29

Change-Id: I759ccb27fe19be2722be913c5c2e6aa5f36e5c14
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-04-08 03:51:18 +00:00
Konstantin Ritt
2a0ab43f18 Re-generate TZ data from CLDR v29
Change-Id: Ibc9c58e96c72ae9886946bcf2454f32552bd51a3
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-03-30 09:43:30 +00:00
Jani Heikkinen
f776595cc1 Updated license headers
From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some
exceptions, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/

Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one
(in those files which will be under GPL 3 with exceptions)

Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-01-21 18:55:18 +00:00
Konstantin Ritt
595606fb02 Re-generate the time zones database from CLDR v.27
[ChangeLog][QtCore] QTimeZone data updated to CLDR v.27

Change-Id: Ic25229d86ac4752ed70f5a729fd33c1a837241dc
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2015-03-27 16:40:28 +00:00
Konstantin Ritt
6acb7fd61d Fix time offset for several time zones
They are in UTC-03:00, not in UTC+03:00 (just a C&P typo).

Change-Id: Ib342b65967404b8756c62953258b17421b9245af
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2015-03-27 16:40:25 +00:00
Konstantin Ritt
d8a0b97f60 Update CLDR to v27
+ A bunch of fixes in the locale data
+ New scripts from Unicode 7.0
+ New locales
- Some locales disappeared (aa_DJ, aa_ER, st_LS, ss_SZ, swc_CD, tn_BW)
- Some locales lost their contents (i.e. en_Dsrt_US)

[ChangeLog][QtCore] QLocale data updated to CLDR v.27

Change-Id: Iba8c7884f8087e577cbb25a8fc106dd7bd3ebb5d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2015-03-27 16:40:16 +00:00
Konstantin Ritt
7946b83ace [QLocaleData] Extract defaultContent locales
This adds some locales missing in the common/main/ directory, namely:
  bss_CM, cch_NG, dv_MV, gaa_GH, gez_ET, ha_Arab_NG, iu_Cans_CA, kaj_NG,
  kcg_NG, kpe_LR, ku_Latn_TR, mi_NZ, ms_Arab_MY, mn_Mong_CN, nds_DE,
  ny_MW, oc_FR, sa_IN, sid_ET, tk_Latn_TM, trv_TW, tt_RU, ug_Arab_CN,
  wa_BE, wo_Latn_SN

See http://www.unicode.org/reports/tr35/tr35-info.html#Default_Content
for more info.

Change-Id: I6b3082d370a21da64fbd5e72ab6344e1d7a6a3c9
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2015-03-27 16:40:13 +00:00
Konstantin Ritt
241ff426eb [locale database utility] Minor code deduplication
Change-Id: Ib6917940dfc410148d88e539cad2cdf7331a940d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2015-03-23 07:08:31 +00:00
Konstantin Ritt
9c97e5c40e [locale database utility] Optimize by caching the locale lookup chain
Change-Id: I1b95b3365337753ca0ab782091fa61870b77b051
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2015-03-23 07:08:28 +00:00
Konstantin Ritt
7ae4ffa0e0 [locale database utility] Fix inheritance chain
Locales with an explicit parent locale should not inherit
the language-default locale.
For example, a correct chain for zh_Hant_MO is:
  zh_Hant_MO -> zh_Hant_HK -> zh_Hant -> root
(two fixups: zh_Hant_HK and root, so that do not inherit zh)

Fortunately, this didn't do any difference in a generated data.

Change-Id: I92e09a95bd86f8723d8fe993f57d99af6f50db5e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2015-03-23 07:08:24 +00:00
Jani Heikkinen
cb95fff1c7 Fixed license headers
Change-Id: Ibebe1318d1c2de97601aa07269705c87737083ee
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2015-02-17 18:46:09 +00:00
Jani Heikkinen
83a5694dc2 Update copyright headers
Qt copyrights are now in The Qt Company, so we could update the source
code headers accordingly. In the same go we should also fix the links to
point to qt.io.

Outdated header.LGPL removed (use header.LGPL21 instead)

Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing
combination. New header.LGPL-COMM taken in the use file which were
using old header.LGPL3 (src/plugins/platforms/android/extract.cpp)

Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license
combination

Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe
Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
2015-02-11 06:49:51 +00:00
Matti Paaso
974c210835 Update license headers and add new license files
- Renamed LICENSE.LGPL to LICENSE.LGPLv21
- Added LICENSE.LGPLv3
- Removed LICENSE.GPL

Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2
Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
2014-09-24 12:26:19 +02:00
Konstantin Ritt
adcab02d96 Update the time zones database from CLDR v.24
Change-Id: Icab298f971980982412621a48c635a05f6ef5d36
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: John Layt <jlayt@kde.org>
2014-01-13 19:02:10 +01:00
Konstantin Ritt
4f8f0f16d0 Update the internal CLDR tables up to v.24
Change-Id: I9c0b110e36dd80c6a0b7275aa13bc548419aca9c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: John Layt <jlayt@kde.org>
Reviewed-by: Mehdi Fekari <mfekari@blackberry.com>
2014-01-13 19:02:10 +01:00
John Layt
19be46414a QTimeZone - Change from Olson ID to IANA ID
Complete changes from using Olsen/Olson in the code to IANA.  Completes
a change started in 5.2 release branch on the public occurrences.

Change-Id: Ib077fcda2c77eef6f04ec28901d8d2d7210b8c72
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2014-01-11 17:23:25 +01:00
John Layt
48e2c3ac33 QTimeZone - Define new class and api
Implement the new QTimeZone class based on the Olsen Time Zone ID's.

This is the base implementation and does not include the Platform
backends which are implemented separately.

This change does include a default UTC backed to be used if no Platform
backend is available, i.e. if QT_NO_SYSTEMLOCALE is set and ICU is not
configured.  This backend also provides a default set of time zones in
the standard "UTC+00:00" offset format that are guaranteed to always
exist regardless of the Platform backend.

This change includes conversion functions between the Olsen ID's and
Windows ID's using a conversion table based on Unicode CLDR data.
This is implemented for all platforms for scenarios such as a Linux
program needing to communicate with a Windows Exchange Server using
the Windows ID.

The CLDR conversion table is included under the UNICODE license, see
http://unicode.org/copyright.html for details.

[ChangeLog][QtCore][QTimeZone] Added new QTimeZone class to support
time tone calculations using the host platform time zone database
and the Olsen time zone ID's.

Change-Id: Ibb417d08cf2663a0979d2be855d2c6ad6ad01509
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-09-22 22:21:15 +02:00
Konstantin Ritt
2af5567f3e Update QLocale locale database up to CLDR 23.1
This only added Kosovo [XK] territory and few valid locales for it.

Change-Id: Ia0b47041ed5cd1303b5bc233f2502a3725c74da9
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-12 23:05:59 +02:00
Konstantin Ritt
f0af3ed4e5 Update QLocale data to CLDRv23
Say hello to Interlingua and Mongolian once again.

Change-Id: I735fbc5793f34620be1f6932a251224b9ded02e3
Reviewed-by: Denis Dzyubenko <denis@ddenis.info>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-04-01 12:03:55 +02:00
Konstantin Ritt
b1c3f71a7b QLocale: Add some more languages and scripts
Change-Id: Iab23128c1567974154cdcce7412b2e1468bb8462
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-03-05 12:18:30 +01:00
Sze Howe Koh
7bb43454b8 Fix minor typos in docs, printed messages & comments
Missing apostrophes

Change-Id: I3ef5e9d494fb7a37f8e6075f24cd3a274e572c23
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
2013-01-28 18:12:41 +01:00
Sergio Ahumada
48e0c4df23 Update copyright year in Digia's license headers
Change-Id: Ic804938fc352291d011800d21e549c10acac66fb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-01-18 09:07:35 +01:00
Stephen Kelly
5a9de4c676 Always use QAIM to get the default flags.
Change-Id: I801f5c8023e3e3672fde28139a7f34f640e650f5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-28 08:43:31 +01:00
Konstantin Ritt
dec4eb7ecc [SIC] QLocale: Update some language names with their modern values
Some of them were incorrectly spelled (for a while)

Change-Id: I871968e3bbdd2172f4c4dfb6e74729c05e7e8e01
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2012-11-24 06:15:25 +01:00
Konstantin Ritt
3791d21f72 Update Qlocale data up to CLDR 22.1
Change-Id: Ie6ddfec14cb052e0b89230dc93290ff79488fb25
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-21 18:23:59 +01:00
Konstantin Ritt
4a115ab4ae Update Qlocale data up to CLDR 2.0.1
Change-Id: I4279fac57436d7009a6d61dab5936b72fd39fc14
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-21 18:23:59 +01:00
Konstantin Ritt
fe8962d3a5 Use likelySubtags to instantiate a locale id from it's short form
...just like described in http://www.unicode.org/reports/tr35/#Likely_Subtags.
This is much more effective than current "guessing" algorithm
+ makes it possible to instantiate a locale by the script or territory code only.

Change-Id: I674f8476e65b01c56960b6e83a1a346df0715274
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-21 18:23:59 +01:00
Konstantin Ritt
e7c79face6 [SIC/BIC] QLocale: update enums up to CLRD 1.9.1
This patch adds some missing codes (two-letter ones only),
removes an outdated ones, and updates some names.
The legacy language codes are handled in QLocalePrivate::codeToLanguage()
(fortunately, there are only 4 of such codes).

Change-Id: Iff50aecd1c762b6399cd151aebb955f341d366c6
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-21 18:23:59 +01:00
Konstantin Ritt
da90a3a490 QLocale: replace hard-coded default country-for-language map
...with a generated one in a way similar to what
http://www.unicode.org/reports/tr35/#Likely_Subtags suggests.
The supplemental/likelySubtags.xml contains all the required data.
This changes some default countries to a most-expected ones.

Change-Id: I920a5623601d8661a943e78197d3bcc838191483
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-19 21:18:03 +01:00
Konstantin Ritt
e4c2a5c29f Assign correct codes to QLocale::AnyCountry and AnyScript
as their meaning, in fact, is unknown (or default) country/script.

Change-Id: Id75a70d4b33c2092de414f3ac357f6bcb627ba47
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-15 13:55:00 +01:00
Konstantin Ritt
1e0e5f2d68 Add a bunch of missed scripts
Change-Id: I078bf95cb50c7ef634f9f3133ab9f9d25439e4ef
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-15 13:55:00 +01:00