Distinguish system locale from corresponding CLDR-derived one
Previously it was displayed as if it had been constructed from its language, script and territory; but it is distinct from the locale constructed in this way and may produce different results. Report the system locale as QLocale::system() with its language, script and country within /*...*/ following it, instead of as QLocale(...) with these as its parameters. Add a test of the debug output, verifying that it has the form intended. [ChangeLog][Important Behavior Changes][QLocale] Message logging now distinguishes the system locale from the corresponding locale - generated from its language, script and territory - based on CLDR data. Pick-to: 6.9 Fixes: QTBUG-133922 Change-Id: Ic6fb137821fb7bf29d0f6446a46225cadd54b82a Reviewed-by: Mate Barany <mate.barany@qt.io>
This commit is contained in:
parent
92ec27e461
commit
e323d46cda
@ -5437,10 +5437,12 @@ QString QLocale::nativeCountryName() const
|
|||||||
QDebug operator<<(QDebug dbg, const QLocale &l)
|
QDebug operator<<(QDebug dbg, const QLocale &l)
|
||||||
{
|
{
|
||||||
QDebugStateSaver saver(dbg);
|
QDebugStateSaver saver(dbg);
|
||||||
|
const bool isSys = l == QLocale::system();
|
||||||
dbg.nospace().noquote()
|
dbg.nospace().noquote()
|
||||||
<< "QLocale(" << QLocale::languageToString(l.language())
|
<< (isSys ? "QLocale::system()/* " : "QLocale(")
|
||||||
<< ", " << QLocale::scriptToString(l.script())
|
<< QLocale::languageToString(l.language()) << ", "
|
||||||
<< ", " << QLocale::territoryToString(l.territory()) << ')';
|
<< QLocale::scriptToString(l.script()) << ", "
|
||||||
|
<< QLocale::territoryToString(l.territory()) << (isSys ? " */" : ")");
|
||||||
return dbg;
|
return dbg;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -178,6 +178,7 @@ private slots:
|
|||||||
void unixLocaleName();
|
void unixLocaleName();
|
||||||
void testNames_data();
|
void testNames_data();
|
||||||
void testNames();
|
void testNames();
|
||||||
|
void debugOutput();
|
||||||
private:
|
private:
|
||||||
QString m_decimal, m_thousand, m_sdate, m_ldate, m_time;
|
QString m_decimal, m_thousand, m_sdate, m_ldate, m_time;
|
||||||
QString m_sysapp;
|
QString m_sysapp;
|
||||||
@ -3410,6 +3411,34 @@ void tst_QLocale::testNames()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QLocale::debugOutput()
|
||||||
|
{
|
||||||
|
// Test operator<<(QDebug, const QLocale &) works as intended:
|
||||||
|
QTest::failOnWarning();
|
||||||
|
{
|
||||||
|
const QLocale en(QLocale::English, QLocale::LatinScript, QLocale::UnitedStates);
|
||||||
|
QTest::ignoreMessage(QtMsgType::QtWarningMsg,
|
||||||
|
"QLocale(English, Latin, United States)");
|
||||||
|
qWarning() << en;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const auto params = [](const QLocale &loc) {
|
||||||
|
return (QLocale::languageToString(loc.language())
|
||||||
|
+ u", " + QLocale::scriptToString(loc.script())
|
||||||
|
+ u", " + QLocale::territoryToString(loc.territory())).toLatin1();
|
||||||
|
};
|
||||||
|
const QLocale sys = QLocale::system();
|
||||||
|
QTest::ignoreMessage(QtMsgType::QtWarningMsg,
|
||||||
|
("QLocale::system()/* " + params(sys) + " */").constData());
|
||||||
|
// QTBUG-133922: system and its CLDR counterpart should differ.
|
||||||
|
qWarning() << sys;
|
||||||
|
const QLocale match(sys.language(), sys.script(), sys.territory());
|
||||||
|
QTest::ignoreMessage(QtMsgType::QtWarningMsg,
|
||||||
|
("QLocale(" + params(match) + ')').constData());
|
||||||
|
qWarning() << match;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QLocale::dayName_data()
|
void tst_QLocale::dayName_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>("locale_name");
|
QTest::addColumn<QString>("locale_name");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user