diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2023-08-01 12:35:26 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2023-08-09 17:53:42 +0200 |
commit | 1ae24f8b50876659dca80c6e42c02e7d0481e961 (patch) | |
tree | 6dc23f46b5f783a50c31a8178abd04c3df9ca46b /util/locale_database/qlocalexml2cpp.py | |
parent | afd7d68244038926bd9bf49411a66fd77107bcb1 (diff) |
Use CLDR's names in QLocale::*ToName() for language, script, territory
Various comments need to continue using the enumdata.py names, as they
associate data with particular enum members, but we can now correctly
use the en.xml versions of their names when we report them, rather
than the enum-friendly names we use in the code. Since this now means
the data may stray outside plain ASCII - it'll be UTF-8-encoded - this
implies replacing the QLatin1StringView()s of the code that formerly
read this data with QString::fromUtf8().
Fixes: QTBUG-94460
Change-Id: Id3b08875a46af58c0555c3e303b0e15a19441509
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'util/locale_database/qlocalexml2cpp.py')
-rwxr-xr-x | util/locale_database/qlocalexml2cpp.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/util/locale_database/qlocalexml2cpp.py b/util/locale_database/qlocalexml2cpp.py index cfb3e2e432..b770049cca 100755 --- a/util/locale_database/qlocalexml2cpp.py +++ b/util/locale_database/qlocalexml2cpp.py @@ -20,7 +20,7 @@ from pathlib import Path from typing import Optional from qlocalexml import QLocaleXmlReader -from localetools import unicode2hex, wrap_list, Error, Transcriber, SourceFileEditor, qtbase_root +from localetools import * from iso639_3 import LanguageCodeData class LocaleKeySorter: @@ -337,7 +337,11 @@ class LocaleDataWriter (LocaleSourceEditor): for key, value in book.items(): if key == 0: continue - out(f'"{value[0]}\\0"\n') + enum, name = value[0], value[-1] + if names_clash(name, enum): + out(f'"{name}\\0" // {enum}\n') + else: + out(f'"{name}\\0"\n') # Automagically utf-8 encoded out(';\n\n') out(f'static constexpr quint16 {form}_name_index[] = {{\n') @@ -346,9 +350,8 @@ class LocaleDataWriter (LocaleSourceEditor): for key, value in book.items(): if key == 0: continue - name = value[0] - out(f'{index:6d}, // {name}\n') - index += len(name) + 1 + out(f'{index:6d}, // {value[0]}\n') + index += len(value[-1].encode('utf-8')) + 1 out('};\n\n') @staticmethod |