Fix separator in QLocale::uiLanguages()
Since commit 91e70f23 introduced separator to uiLanguages(), the system locale id still does not respect the separator parameter and hardcodes dash as separator. Fixing this should make the format consistent. Change-Id: I1ab8edfa49117bdc9c4353228e73c2d1e5becffc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Moody Liu <mooodyhunter@outlook.com> (cherry picked from commit 4431ffa8b90f4d089f98544e8c2eeac6cfc7abb2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e85a0951dd
commit
f05cf3f11f
@ -4750,6 +4750,11 @@ QStringList QLocale::uiLanguages(TagSeparator separator) const
|
||||
const bool isSystem = d->m_data == &systemLocaleData;
|
||||
if (isSystem) {
|
||||
uiLanguages = systemLocale()->query(QSystemLocale::UILanguages).toStringList();
|
||||
if (separator != TagSeparator::Dash) {
|
||||
// Map from default separator, Dash, used by backends:
|
||||
const QChar join = QLatin1Char(sep);
|
||||
uiLanguages = uiLanguages.replaceInStrings(u"-", QStringView(&join, 1));
|
||||
}
|
||||
// ... but we need to include likely-adjusted forms of each of those, too.
|
||||
// For now, collect up locale Ids representing the entries, for later processing:
|
||||
for (const auto &entry : std::as_const(uiLanguages))
|
||||
|
@ -4102,6 +4102,8 @@ void tst_QLocale::mySystemLocale()
|
||||
qDebug("\n\t%s", qPrintable(QLocale::system().uiLanguages().join(u"\n\t")));
|
||||
});
|
||||
QCOMPARE(QLocale::system().uiLanguages(), uiLanguages);
|
||||
QCOMPARE(QLocale::system().uiLanguages(QLocale::TagSeparator::Underscore),
|
||||
uiLanguages.replaceInStrings(u"-", u"_"));
|
||||
reporter.dismiss();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user