[libcalamares] Use newly-generated table of language names

This commit is contained in:
Adriaan de Groot 2022-07-02 23:10:06 +02:00
parent f53f83be56
commit d7e35d2ad2
4 changed files with 9 additions and 7 deletions

View File

@ -10,6 +10,7 @@
#include "CalamaresApplication.h" #include "CalamaresApplication.h"
#include "CalamaresConfig.h" #include "CalamaresConfig.h"
#include "CalamaresTranslations.h"
#include "CalamaresVersionX.h" #include "CalamaresVersionX.h"
#include "CalamaresWindow.h" #include "CalamaresWindow.h"
#include "progresstree/ProgressTreeView.h" #include "progresstree/ProgressTreeView.h"
@ -67,7 +68,7 @@ CalamaresApplication::init()
{ {
Logger::setupLogfile(); Logger::setupLogfile();
cDebug() << "Calamares version:" << CALAMARES_VERSION; 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() ) if ( !Calamares::Settings::instance() )
{ {

View File

@ -13,6 +13,7 @@
#include "locale/TranslatableConfiguration.h" #include "locale/TranslatableConfiguration.h"
#include "locale/TranslationsModel.h" #include "locale/TranslationsModel.h"
#include "CalamaresTranslations.h"
#include "CalamaresVersion.h" #include "CalamaresVersion.h"
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "utils/Logger.h" #include "utils/Logger.h"
@ -153,12 +154,11 @@ someLanguages()
void void
LocaleTests::testTranslatableLanguages() LocaleTests::testTranslatableLanguages()
{ {
QStringList availableLanguages = QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';' ); cDebug() << "Translation languages:" << Calamares::Locale::availableLanguages;
cDebug() << "Translation languages:" << availableLanguages;
for ( const auto& language : someLanguages() ) for ( const auto& language : someLanguages() )
{ {
// Could be QVERIFY, but then we don't see what language code fails // 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 );
} }
} }

View File

@ -13,7 +13,7 @@
#include "Lookup.h" #include "Lookup.h"
#include "CalamaresVersion.h" // For the list of translations #include "CalamaresTranslations.h" // For the list of translations
namespace CalamaresUtils namespace CalamaresUtils
{ {
@ -139,8 +139,7 @@ TranslationsModel::find( const Translation::Id& id ) const
TranslationsModel* TranslationsModel*
availableTranslations() availableTranslations()
{ {
static TranslationsModel* model static TranslationsModel* model = new TranslationsModel( Calamares::Locale::availableLanguages );
= new TranslationsModel( QStringLiteral( CALAMARES_TRANSLATION_LANGUAGES ).split( ';' ) );
return model; return model;
} }

View File

@ -75,6 +75,8 @@ private:
* *
* The translations are set when Calamares is compiled; the list * The translations are set when Calamares is compiled; the list
* is provided by CMake via the CALAMARES_TRANSLATION_LANGUAGES * 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. * #define.
* *
* This model is a singleton and can be shared. * This model is a singleton and can be shared.