[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 "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() )
{

View File

@ -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 );
}
}

View File

@ -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;
}

View File

@ -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.