From ed6fe4d06a4f3594f81a5c0463952c20e2ab8605 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 9 Jan 2024 16:08:15 +0100 Subject: [PATCH] Prepare to support taking CLDR data from its github upstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We've previously used the zip-file form, but that's not been published for CLDR v44.1 - the advice on the list was to use github instead. That, however, has ↑↑↑ as a special value for fields, meaning to inherit from a prent locale. So special-case that value. I have verified that v44 from the zip file produces identical results to v44 from github, with this minor fix. As it happens v44.1 also produces identical results. Pick-to: 6.5 Change-Id: I6eb0aedda7556753cdc83bb9d76652fbb68dc669 Reviewed-by: Ievgenii Meshcheriakov (cherry picked from commit bcdd51cfae24731a73d008add23d3c1e85bbd8d0) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit c112981789f5885e5db0daa4a081fa26708bafb0) --- util/locale_database/cldr2qlocalexml.py | 26 +++++++++++++++---------- util/locale_database/ldml.py | 5 ++++- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/util/locale_database/cldr2qlocalexml.py b/util/locale_database/cldr2qlocalexml.py index d5a7fbbb5c3..b2203492e9e 100755 --- a/util/locale_database/cldr2qlocalexml.py +++ b/util/locale_database/cldr2qlocalexml.py @@ -3,16 +3,21 @@ # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 """Convert CLDR data to QLocaleXML -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 v38.1; 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 root of the download to this script as its first -command-line argument. Pass the name of the file in which to write -output as the second argument; either omit it or use '-' to select the -standard output. This file is the input needed by -``./qlocalexml2cpp.py`` +The CLDR data can be downloaded as a zip-file from CLDR_, which has a +sub-directory for each version; you need the ``core.zip`` file for +your version of choice (typically the latest), which you should then +unpack. Alternatively, you can clone the git repo from github_, which +has a tag for each release and a maint/maint-$ver branch for each +major version. Either way, the CLDR top-level directory should have a +subdirectory called common/ which contains (among other things) +subdirectories main/ and supplemental/. + +This script has had updates to cope up to v44.1; for later versions, +we may need adaptations. Pass the path of the CLDR top-level directory +to this script as its first command-line argument. Pass the name of +the file in which to write output as the second argument; either omit +it or use '-' to select the standard output. This file is the input +needed by ``./qlocalexml2cpp.py`` When you update the CLDR data, be sure to also update src/corelib/text/qt_attribution.json's entry for unicode-cldr. Check @@ -28,6 +33,7 @@ time zone names; see cldr2qtimezone.py for details. All the scripts mentioned support --help to tell you how to use them. .. _CLDR: https://unicode.org/Public/cldr/ +.. _github: https://github.com/unicode-org/cldr """ from pathlib import Path diff --git a/util/locale_database/ldml.py b/util/locale_database/ldml.py index d46cb3a27e2..2a029ce98b6 100644 --- a/util/locale_database/ldml.py +++ b/util/locale_database/ldml.py @@ -204,7 +204,10 @@ class LocaleScanner (object): for elt in self.__find(xpath): try: if draft is None or elt.draft <= draft: - return elt.dom.firstChild.nodeValue + value = elt.dom.firstChild.nodeValue + # The github version of CLDR uses '↑↑↑' to indicate "inherit" + if value != '↑↑↑': + return value except (AttributeError, KeyError): pass except Error as e: