[locale] Add FreeBSD test data for locale-mapping

This commit is contained in:
Adriaan de Groot 2022-07-19 18:48:32 +02:00
parent f7a7ad9943
commit 61a07f05ba
2 changed files with 107 additions and 14 deletions

View File

@ -390,8 +390,12 @@ LocaleTests::testKDENeonLanguageData()
const QStringList neonLocales = splitTestFileIntoLines( QStringLiteral( "locale-data-neon" ) ); const QStringList neonLocales = splitTestFileIntoLines( QStringLiteral( "locale-data-neon" ) );
cDebug() << "Loaded KDE neon locales test data" << neonLocales.front() << "to" << neonLocales.back(); cDebug() << "Loaded KDE neon locales test data" << neonLocales.front() << "to" << neonLocales.back();
QCOMPARE( neonLocales.length(), 318 ); // wc -l tells me 318 lines QCOMPARE( neonLocales.length(), 318 ); // wc -l tells me 318 lines
m_KDEneonLocales = neonLocales; m_KDEneonLocales = neonLocales;
const QStringList bsdLocales = splitTestFileIntoLines( QStringLiteral( "locale-data-freebsd" ) );
cDebug() << "Loaded FreeBSD locales test data" << bsdLocales.front() << "to" << bsdLocales.back();
QCOMPARE( bsdLocales.length(), 79 );
m_FreeBSDLocales = bsdLocales;
} }
void void
@ -399,13 +403,17 @@ LocaleTests::testLanguageMapping_data()
{ {
QTest::addColumn< QString >( "selectedLanguage" ); QTest::addColumn< QString >( "selectedLanguage" );
QTest::addColumn< QString >( "KDEneonLanguage" ); QTest::addColumn< QString >( "KDEneonLanguage" );
QTest::addColumn< QString >( "FreeBSDLanguage" );
// Tired of writing QString or QStringLiteral all the time. // Tired of writing QString or QStringLiteral all the time.
auto l = []( const char* p ) { return QString::fromUtf8( p ); }; auto l = []( const char* p ) { return QString::fromUtf8( p ); };
auto u = [](){ return QString(); };
// The KDEneon columns include the .UTF-8 from the source data // The KDEneon columns include the .UTF-8 from the source data
// The FreeBSD columns may have u() to indicate "same as KDEneon",
// that's an empty string.
// //
// Each column shows how a language -- which can be selected from the // Each row shows how a language -- which can be selected from the
// welcome page, and is inserted into GS as the language key that // welcome page, and is inserted into GS as the language key that
// Calamares knows -- should be mapped to a supported system locale. // Calamares knows -- should be mapped to a supported system locale.
// //
@ -413,16 +421,16 @@ LocaleTests::testLanguageMapping_data()
// if there are languages with a _NL variant (e.g. nl_NL and nl_BE). // if there are languages with a _NL variant (e.g. nl_NL and nl_BE).
// clang-format off // clang-format off
QTest::newRow( "en " ) << l( "en" ) << l( "en_US.UTF-8" ); QTest::newRow( "en " ) << l( "en" ) << l( "en_US.UTF-8" ) << u();
QTest::newRow( "en_GB" ) << l( "en_GB" ) << l( "en_GB.UTF-8" ); QTest::newRow( "en_GB" ) << l( "en_GB" ) << l( "en_GB.UTF-8" ) << u();
QTest::newRow( "ca " ) << l( "ca" ) << l( "ca_ES.UTF-8" ); QTest::newRow( "ca " ) << l( "ca" ) << l( "ca_ES.UTF-8" ) << u();
QTest::newRow( "ca@vl" ) << l( "ca@valencia" ) << l( "ca_ES@valencia" ); QTest::newRow( "ca@vl" ) << l( "ca@valencia" ) << l( "ca_ES@valencia" ) << u();
QTest::newRow( "sr " ) << l( "sr" ) << l( "sr_RS" ); QTest::newRow( "sr " ) << l( "sr" ) << l( "sr_RS" ) << u();
QTest::newRow( "sr@lt" ) << l( "sr@latin" ) << l( "sr_RS@latin" ); QTest::newRow( "sr@lt" ) << l( "sr@latin" ) << l( "sr_RS@latin" ) << u();
QTest::newRow( "pt_PT" ) << l( "pt_PT" ) << l( "pt_PT.UTF-8" ); QTest::newRow( "pt_PT" ) << l( "pt_PT" ) << l( "pt_PT.UTF-8" ) << u();
QTest::newRow( "pt_BR" ) << l( "pt_BR" ) << l( "pt_BR.UTF-8" ); QTest::newRow( "pt_BR" ) << l( "pt_BR" ) << l( "pt_BR.UTF-8" ) << u();
QTest::newRow( "nl " ) << l( "nl" ) << l( "nl_NL.UTF-8" ); QTest::newRow( "nl " ) << l( "nl" ) << l( "nl_NL.UTF-8" ) << u();
QTest::newRow( "zh_TW" ) << l( "zh_TW" ) << l( "zh_TW.UTF-8" ); QTest::newRow( "zh_TW" ) << l( "zh_TW" ) << l( "zh_TW.UTF-8" ) << u();
// clang-format on // clang-format on
} }
@ -431,15 +439,21 @@ void
LocaleTests::testLanguageMapping() LocaleTests::testLanguageMapping()
{ {
QVERIFY( !m_KDEneonLocales.isEmpty() ); QVERIFY( !m_KDEneonLocales.isEmpty() );
QVERIFY( !m_FreeBSDLocales.isEmpty() );
QFETCH( QString, selectedLanguage ); QFETCH( QString, selectedLanguage );
QFETCH( QString, KDEneonLanguage ); QFETCH( QString, KDEneonLanguage );
QFETCH( QString, FreeBSDLanguage );
QVERIFY( Calamares::Locale::availableLanguages().contains( selectedLanguage ) ); QVERIFY( Calamares::Locale::availableLanguages().contains( selectedLanguage ) );
const auto r = LocaleConfiguration::fromLanguageAndLocation( const auto neon = LocaleConfiguration::fromLanguageAndLocation(
( selectedLanguage ), m_KDEneonLocales, QStringLiteral( "NL" ) ); ( selectedLanguage ), m_KDEneonLocales, QStringLiteral( "NL" ) );
QCOMPARE( r.language(), KDEneonLanguage ); QCOMPARE( neon.language(), KDEneonLanguage );
const auto bsd = LocaleConfiguration::fromLanguageAndLocation(
( selectedLanguage ), m_FreeBSDLocales, QStringLiteral( "NL" ) );
QCOMPARE( bsd.language(), FreeBSDLanguage.isEmpty() ? KDEneonLanguage : FreeBSDLanguage );
} }

View File

@ -0,0 +1,79 @@
C.UTF-8
af_ZA.UTF-8
am_ET.UTF-8
ar_AE.UTF-8
ar_EG.UTF-8
ar_JO.UTF-8
ar_MA.UTF-8
ar_QA.UTF-8
ar_SA.UTF-8
be_BY.UTF-8
bg_BG.UTF-8
ca_AD.UTF-8
ca_ES.UTF-8
ca_FR.UTF-8
ca_IT.UTF-8
cs_CZ.UTF-8
da_DK.UTF-8
de_AT.UTF-8
de_CH.UTF-8
de_DE.UTF-8
el_GR.UTF-8
en_AU.UTF-8
en_CA.UTF-8
en_GB.UTF-8
en_HK.UTF-8
en_IE.UTF-8
en_NZ.UTF-8
en_PH.UTF-8
en_SG.UTF-8
en_US.UTF-8
en_ZA.UTF-8
es_AR.UTF-8
es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