From d7e35d2ad253e40c7de8089899022808935c5fde Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 2 Jul 2022 23:10:06 +0200 Subject: [PATCH] [libcalamares] Use newly-generated table of language names --- src/calamares/CalamaresApplication.cpp | 3 ++- src/libcalamares/locale/Tests.cpp | 6 +++--- src/libcalamares/locale/TranslationsModel.cpp | 5 ++--- src/libcalamares/locale/TranslationsModel.h | 2 ++ 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index c06e13aa3..979ee8cfe 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -10,6 +10,7 @@ #include "CalamaresApplication.h" #include "CalamaresConfig.h" +#include "CalamaresTranslations.h" #include "CalamaresVersionX.h" #include "CalamaresWindow.h" #include "progresstree/ProgressTreeView.h" @@ -67,7 +68,7 @@ CalamaresApplication::init() { Logger::setupLogfile(); cDebug() << "Calamares version:" << CALAMARES_VERSION; - cDebug() << Logger::SubEntry << "languages:" << QString( CALAMARES_TRANSLATION_LANGUAGES ).replace( ";", ", " ); + cDebug() << Logger::SubEntry << "languages:" << Calamares::Locale::availableLanguages; if ( !Calamares::Settings::instance() ) { diff --git a/src/libcalamares/locale/Tests.cpp b/src/libcalamares/locale/Tests.cpp index f234c1596..fa8ea3342 100644 --- a/src/libcalamares/locale/Tests.cpp +++ b/src/libcalamares/locale/Tests.cpp @@ -13,6 +13,7 @@ #include "locale/TranslatableConfiguration.h" #include "locale/TranslationsModel.h" +#include "CalamaresTranslations.h" #include "CalamaresVersion.h" #include "GlobalStorage.h" #include "utils/Logger.h" @@ -153,12 +154,11 @@ someLanguages() void LocaleTests::testTranslatableLanguages() { - QStringList availableLanguages = QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';' ); - cDebug() << "Translation languages:" << availableLanguages; + cDebug() << "Translation languages:" << Calamares::Locale::availableLanguages; for ( const auto& language : someLanguages() ) { // Could be QVERIFY, but then we don't see what language code fails - QCOMPARE( availableLanguages.contains( language ) ? language : QString(), language ); + QCOMPARE( Calamares::Locale::availableLanguages.contains( language ) ? language : QString(), language ); } } diff --git a/src/libcalamares/locale/TranslationsModel.cpp b/src/libcalamares/locale/TranslationsModel.cpp index 0ffa6f9c5..e8cc5130e 100644 --- a/src/libcalamares/locale/TranslationsModel.cpp +++ b/src/libcalamares/locale/TranslationsModel.cpp @@ -13,7 +13,7 @@ #include "Lookup.h" -#include "CalamaresVersion.h" // For the list of translations +#include "CalamaresTranslations.h" // For the list of translations namespace CalamaresUtils { @@ -139,8 +139,7 @@ TranslationsModel::find( const Translation::Id& id ) const TranslationsModel* availableTranslations() { - static TranslationsModel* model - = new TranslationsModel( QStringLiteral( CALAMARES_TRANSLATION_LANGUAGES ).split( ';' ) ); + static TranslationsModel* model = new TranslationsModel( Calamares::Locale::availableLanguages ); return model; } diff --git a/src/libcalamares/locale/TranslationsModel.h b/src/libcalamares/locale/TranslationsModel.h index 3cd7c61dc..f95b756a8 100644 --- a/src/libcalamares/locale/TranslationsModel.h +++ b/src/libcalamares/locale/TranslationsModel.h @@ -75,6 +75,8 @@ private: * * The translations are set when Calamares is compiled; the list * is provided by CMake via the CALAMARES_TRANSLATION_LANGUAGES + * CMake variable (top-level CMakeLists.txt in Calamares) and + * compiled into the CalamaresTranslations.h internal header. * #define. * * This model is a singleton and can be shared.