Clarify what QSystemLocale::fallbackLocale() is used for
Change-Id: I8f073f996505ccb42020b32fd76520ecef54e628 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
13ae47d980
commit
f218d89522
@ -707,7 +707,7 @@ static void updateSystemPrivate()
|
|||||||
sys_locale->query(QSystemLocale::LocaleChanged);
|
sys_locale->query(QSystemLocale::LocaleChanged);
|
||||||
|
|
||||||
// Populate global with fallback as basis:
|
// Populate global with fallback as basis:
|
||||||
globalLocaleData = locale_data[sys_locale->fallbackUiLocaleIndex()];
|
globalLocaleData = locale_data[sys_locale->fallbackLocaleIndex()];
|
||||||
|
|
||||||
QVariant res = sys_locale->query(QSystemLocale::LanguageId);
|
QVariant res = sys_locale->query(QSystemLocale::LanguageId);
|
||||||
if (!res.isNull()) {
|
if (!res.isNull()) {
|
||||||
@ -4240,7 +4240,7 @@ QStringList QLocale::uiLanguages() const
|
|||||||
for (const auto &entry : uiLanguages)
|
for (const auto &entry : uiLanguages)
|
||||||
locales.append(QLocale(entry));
|
locales.append(QLocale(entry));
|
||||||
if (locales.isEmpty())
|
if (locales.isEmpty())
|
||||||
locales.append(systemLocale()->fallbackUiLocale());
|
locales.append(systemLocale()->fallbackLocale());
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -1112,13 +1112,6 @@
|
|||||||
\sa FormatType
|
\sa FormatType
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn QLocale QSystemLocale::fallbackUiLocale() const
|
|
||||||
|
|
||||||
\since 4.6
|
|
||||||
Returns the fallback locale obtained from the system.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
|
\fn QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
|
||||||
|
|
||||||
@ -1129,6 +1122,17 @@
|
|||||||
\sa QSystemLocale::QueryType
|
\sa QSystemLocale::QueryType
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QLocale QSystemLocale::fallbackLocale() const
|
||||||
|
|
||||||
|
\since 4.6
|
||||||
|
|
||||||
|
Returns the locale used if the system locale is not able to answer a query.
|
||||||
|
|
||||||
|
Must be a QLocale instance based on the built-in CLDR data, and should
|
||||||
|
match what the system locale is using as closely as that data supports.
|
||||||
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class QSystemLocale::CurrencyToStringArgument
|
\class QSystemLocale::CurrencyToStringArgument
|
||||||
\inmodule QtCore
|
\inmodule QtCore
|
||||||
|
@ -418,7 +418,7 @@ static QVariant macQuoteString(QSystemLocale::QueryType type, QStringView str)
|
|||||||
|
|
||||||
#ifndef QT_NO_SYSTEMLOCALE
|
#ifndef QT_NO_SYSTEMLOCALE
|
||||||
|
|
||||||
QLocale QSystemLocale::fallbackUiLocale() const
|
QLocale QSystemLocale::fallbackLocale() const
|
||||||
{
|
{
|
||||||
return QLocale(getMacLocaleName());
|
return QLocale(getMacLocaleName());
|
||||||
}
|
}
|
||||||
|
@ -127,9 +127,9 @@ public:
|
|||||||
StandaloneMonthNameShort // QString, in: int
|
StandaloneMonthNameShort // QString, in: int
|
||||||
};
|
};
|
||||||
virtual QVariant query(QueryType type, QVariant in = QVariant()) const;
|
virtual QVariant query(QueryType type, QVariant in = QVariant()) const;
|
||||||
virtual QLocale fallbackUiLocale() const;
|
|
||||||
|
|
||||||
inline uint fallbackUiLocaleIndex() const;
|
virtual QLocale fallbackLocale() const;
|
||||||
|
inline uint fallbackLocaleIndex() const;
|
||||||
private:
|
private:
|
||||||
QSystemLocale(bool);
|
QSystemLocale(bool);
|
||||||
friend class QSystemLocaleSingleton;
|
friend class QSystemLocaleSingleton;
|
||||||
@ -428,7 +428,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifndef QT_NO_SYSTEMLOCALE
|
#ifndef QT_NO_SYSTEMLOCALE
|
||||||
uint QSystemLocale::fallbackUiLocaleIndex() const { return fallbackUiLocale().d->m_index; }
|
uint QSystemLocale::fallbackLocaleIndex() const { return fallbackLocale().d->m_index; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@ -133,7 +133,7 @@ static bool contradicts(const QString &maybe, const QString &known)
|
|||||||
return !(maybeId.acceptLanguage(knownId.language_id) && maybeId.acceptScriptCountry(knownId));
|
return !(maybeId.acceptLanguage(knownId.language_id) && maybeId.acceptScriptCountry(knownId));
|
||||||
}
|
}
|
||||||
|
|
||||||
QLocale QSystemLocale::fallbackUiLocale() const
|
QLocale QSystemLocale::fallbackLocale() const
|
||||||
{
|
{
|
||||||
// See man 7 locale for precedence - LC_ALL beats LC_MESSAGES beats LANG:
|
// See man 7 locale for precedence - LC_ALL beats LC_MESSAGES beats LANG:
|
||||||
QString lang = qEnvironmentVariable("LC_ALL");
|
QString lang = qEnvironmentVariable("LC_ALL");
|
||||||
|
@ -702,7 +702,7 @@ QString QSystemLocalePrivate::winToQtFormat(QStringView sys_fmt)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QLocale QSystemLocale::fallbackUiLocale() const
|
QLocale QSystemLocale::fallbackLocale() const
|
||||||
{
|
{
|
||||||
return QLocale(QString::fromLatin1(getWinLocaleName()));
|
return QLocale(QString::fromLatin1(getWinLocaleName()));
|
||||||
}
|
}
|
||||||
@ -762,8 +762,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
|
|||||||
if (type == LanguageId)
|
if (type == LanguageId)
|
||||||
return lid.language_id;
|
return lid.language_id;
|
||||||
if (type == ScriptId)
|
if (type == ScriptId)
|
||||||
return lid.script_id ? lid.script_id : ushort(fallbackUiLocale().script());
|
return lid.script_id ? lid.script_id : ushort(fallbackLocale().script());
|
||||||
return lid.country_id ? lid.country_id : ushort(fallbackUiLocale().country());
|
return lid.country_id ? lid.country_id : ushort(fallbackLocale().country());
|
||||||
}
|
}
|
||||||
case MeasurementSystem:
|
case MeasurementSystem:
|
||||||
return d->measurementSystem();
|
return d->measurementSystem();
|
||||||
|
@ -187,7 +187,7 @@ QVariant QAndroidSystemLocale::query(QueryType type, QVariant in) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QLocale QAndroidSystemLocale::fallbackUiLocale() const
|
QLocale QAndroidSystemLocale::fallbackLocale() const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&m_lock);
|
QReadLocker locker(&m_lock);
|
||||||
return m_locale;
|
return m_locale;
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
QAndroidSystemLocale();
|
QAndroidSystemLocale();
|
||||||
|
|
||||||
QVariant query(QueryType type, QVariant in) const override;
|
QVariant query(QueryType type, QVariant in) const override;
|
||||||
QLocale fallbackUiLocale() const override;
|
QLocale fallbackLocale() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void getLocaleFromJava() const;
|
void getLocaleFromJava() const;
|
||||||
|
@ -3056,7 +3056,7 @@ public:
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QLocale fallbackUiLocale() const override
|
QLocale fallbackLocale() const override
|
||||||
{
|
{
|
||||||
return m_locale;
|
return m_locale;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user