diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-10-13 15:08:01 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-11-08 13:00:01 +0100 |
commit | 098f43fdd2d46e15c87073aae44c5f2bd0cd8c98 (patch) | |
tree | 97a865e56229fe99d9836775a9923597e624a22a /src/corelib/text/qlocale_unix.cpp | |
parent | 38b6cf490ddbcaecf613cfc5cdb31cea26fa915e (diff) |
Use QLocaleId in place of language, script, country triples
Pass a single argument in place of three; and (prepare to) replace
QLocalePrivate::getLangAndCountry(), taking three out parameters, with
QLocaleId::fromName(). Removal of getLangAndCountry() must wait for
removal of linguist's use of it in qttools, which has to wait for this
change to land in qtbase. In the process, change findLocaleIndex()'s
return to int.
Change-Id: I9f5c44c41f2dd1598c53ed5ccb0abddc6b17d21f
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/text/qlocale_unix.cpp')
-rw-r--r-- | src/corelib/text/qlocale_unix.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/corelib/text/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp index 51b23f1559..b1edd0dd3c 100644 --- a/src/corelib/text/qlocale_unix.cpp +++ b/src/corelib/text/qlocale_unix.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -128,14 +128,9 @@ static bool contradicts(const QString &maybe, const QString &known) Belarusian. There are many more such prefixings between two- and three-letter codes.) */ - QLocale::Language langm, langk; - QLocale::Script scriptm, scriptk; - QLocale::Country landm, landk; - QLocalePrivate::getLangAndCountry(maybe, langm, scriptm, landm); - QLocalePrivate::getLangAndCountry(known, langk, scriptk, landk); - return (langm != QLocale::AnyLanguage && langm != langk) - || (scriptm != QLocale::AnyScript && scriptm != scriptk) - || (landm != QLocale::AnyCountry && landm != landk); + QLocaleId knownId = QLocaleId::fromName(known); + QLocaleId maybeId = QLocaleId::fromName(maybe); + return !(maybeId.acceptLanguage(knownId.language_id) && maybeId.acceptScriptCountry(knownId)); } QLocale QSystemLocale::fallbackUiLocale() const @@ -270,10 +265,12 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const else lst = languages.split(QLatin1Char(':')); + // Inadequate for various cases of a language that's written in more + // than one script in the same country, e.g. Sindhi in India. + // However, can clients of the UILanguage query cope if we include script ? for (int i = 0; i < lst.size(); ++i) { - const QString &name = lst.at(i); QString lang, script, cntry; - if (qt_splitLocaleName(name, lang, script, cntry)) { + if (qt_splitLocaleName(lst.at(i), lang, script, cntry)) { if (!cntry.length()) d->uiLanguages.append(lang); else |