diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index 08a5606e1..6c3eed6d1 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -78,7 +78,7 @@ CalamaresApplication::init() initQmlPath(); initBranding(); - CalamaresUtils::installTranslator( QLocale::system(), QString() ); + CalamaresUtils::installTranslator(); setQuitOnLastWindowClosed( false ); setWindowIcon( QIcon( Calamares::Branding::instance()->imagePath( Calamares::Branding::ProductIcon ) ) ); diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index d4755bde4..645a26d25 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -40,12 +40,12 @@ set( libSources # Locale-data service locale/Global.cpp - locale/Label.cpp - locale/LabelModel.cpp locale/Lookup.cpp locale/TimeZone.cpp locale/TranslatableConfiguration.cpp locale/TranslatableString.cpp + locale/Translation.cpp + locale/TranslationsModel.cpp # Modules modulesystem/Config.cpp diff --git a/src/libcalamares/locale/Tests.cpp b/src/libcalamares/locale/Tests.cpp index 05e8f610c..f234c1596 100644 --- a/src/libcalamares/locale/Tests.cpp +++ b/src/libcalamares/locale/Tests.cpp @@ -9,9 +9,9 @@ */ #include "locale/Global.h" -#include "locale/LabelModel.h" #include "locale/TimeZone.h" #include "locale/TranslatableConfiguration.h" +#include "locale/TranslationsModel.h" #include "CalamaresVersion.h" #include "GlobalStorage.h" diff --git a/src/libcalamares/locale/TranslatableConfiguration.cpp b/src/libcalamares/locale/TranslatableConfiguration.cpp index c10307aee..3a95722d1 100644 --- a/src/libcalamares/locale/TranslatableConfiguration.cpp +++ b/src/libcalamares/locale/TranslatableConfiguration.cpp @@ -10,7 +10,7 @@ #include "TranslatableConfiguration.h" -#include "LabelModel.h" +#include "TranslationsModel.h" #include "utils/Logger.h" #include "utils/Variant.h" @@ -69,6 +69,7 @@ TranslatedString::get() const QString TranslatedString::get( const QLocale& locale ) const { + // TODO: keep track of special cases like sr@latin and ca@valencia QString localeName = locale.name(); // Special case, sr@latin doesn't have the @latin reflected in the name if ( locale.language() == QLocale::Language::Serbian && locale.script() == QLocale::Script::LatinScript ) diff --git a/src/libcalamares/locale/Label.cpp b/src/libcalamares/locale/Translation.cpp similarity index 69% rename from src/libcalamares/locale/Label.cpp rename to src/libcalamares/locale/Translation.cpp index e2cfbc70a..fb8890e87 100644 --- a/src/libcalamares/locale/Label.cpp +++ b/src/libcalamares/locale/Translation.cpp @@ -9,7 +9,7 @@ * */ -#include "Label.h" +#include "Translation.h" #include @@ -25,8 +25,9 @@ * Returns a pair of nullptrs for non-special cases. */ static std::pair< QLocale*, QString* > -specialCase( const QString& localeName ) +specialCase( const CalamaresUtils::Locale::Translation::Id& locale ) { + const QString localeName = locale.name; if ( localeName == "sr@latin" ) { static QLocale loc( QLocale::Language::Serbian, QLocale::Script::LatinScript, QLocale::Country::Serbia ); @@ -46,30 +47,30 @@ namespace CalamaresUtils namespace Locale { -Label::Label( QObject* parent ) - : Label( QString(), LabelFormat::IfNeededWithCountry, parent ) +Translation::Translation( QObject* parent ) + : Translation( { QString() }, LabelFormat::IfNeededWithCountry, parent ) { } -Label::Label( const QString& locale, LabelFormat format, QObject* parent ) +Translation::Translation( const Id& localeId, LabelFormat format, QObject* parent ) : QObject( parent ) - , m_locale( Label::getLocale( locale ) ) - , m_localeId( locale.isEmpty() ? m_locale.name() : locale ) + , m_locale( getLocale( localeId ) ) + , m_localeId( localeId.name.isEmpty() ? m_locale.name() : localeId.name ) { - auto special = specialCase( locale ); + auto [ _, name ] = specialCase( localeId ); QString longFormat = QObject::tr( "%1 (%2)" ); - QString languageName = special.second ? *special.second : m_locale.nativeLanguageName(); + QString languageName = name ? *name : m_locale.nativeLanguageName(); QString englishName = m_locale.languageToString( m_locale.language() ); if ( languageName.isEmpty() ) { - languageName = QString( "* %1 (%2)" ).arg( locale, englishName ); + languageName = QString( "* %1 (%2)" ).arg( localeId.name, englishName ); } bool needsCountryName = ( format == LabelFormat::AlwaysWithCountry ) - || ( locale.contains( '_' ) && QLocale::countriesForLanguage( m_locale.language() ).count() > 1 ); + || ( localeId.name.contains( '_' ) && QLocale::countriesForLanguage( m_locale.language() ).count() > 1 ); QString countryName = ( needsCountryName ? m_locale.nativeCountryName() @@ -80,15 +81,16 @@ Label::Label( const QString& locale, LabelFormat format, QObject* parent ) } QLocale -Label::getLocale( const QString& localeName ) +Translation::getLocale( const Id& localeId ) { + const QString& localeName = localeId.name; if ( localeName.isEmpty() ) { return QLocale(); } - auto special = specialCase( localeName ); - return special.first ? *special.first : QLocale( localeName ); + auto [ locale, _ ] = specialCase( localeId ); + return locale ? *locale : QLocale( localeName ); } } // namespace Locale diff --git a/src/libcalamares/locale/Label.h b/src/libcalamares/locale/Translation.h similarity index 80% rename from src/libcalamares/locale/Label.h rename to src/libcalamares/locale/Translation.h index b0f17930a..5e5ce33ba 100644 --- a/src/libcalamares/locale/Label.h +++ b/src/libcalamares/locale/Translation.h @@ -9,8 +9,8 @@ * */ -#ifndef LOCALE_LABEL_H -#define LOCALE_LABEL_H +#ifndef LOCALE_TRANSLATION_H +#define LOCALE_TRANSLATION_H #include #include @@ -34,7 +34,7 @@ namespace Locale * - `ca@valencia` is the Catalan dialect spoken in Valencia. * There is no Qt code for it. */ -class Label : public QObject +class Translation : public QObject { Q_OBJECT @@ -46,8 +46,13 @@ public: IfNeededWithCountry }; + struct Id + { + QString name; + }; + /** @brief Empty locale. This uses the system-default locale. */ - Label( QObject* parent = nullptr ); + Translation( QObject* parent = nullptr ); /** @brief Construct from a locale name. * @@ -55,16 +60,14 @@ public: * The @p format determines whether the country name is always present * in the label (human-readable form) or only if needed for disambiguation. */ - Label( const QString& localeName, - LabelFormat format = LabelFormat::IfNeededWithCountry, - QObject* parent = nullptr ); + Translation( const Id& localeId, LabelFormat format = LabelFormat::IfNeededWithCountry, QObject* parent = nullptr ); /** @brief Define a sorting order. * * Locales are sorted by their id, which means the ISO 2-letter code + country. */ - bool operator<( const Label& other ) const { return m_localeId < other.m_localeId; } + bool operator<( const Translation& other ) const { return m_localeId < other.m_localeId; } /** @brief Is this locale English? * @@ -81,8 +84,12 @@ public: /** @brief Get the Qt locale. */ QLocale locale() const { return m_locale; } - QString name() const { return m_locale.name(); } - QString id() const { return m_localeId; } + /** @brief Gets the Calamares internal name (code) of the locale. + * + * This is a strongly-typed return to avoid it ending up all over + * the place as a QString. + */ + Id id() const { return { m_localeId }; } /// @brief Convenience accessor to the language part of the locale QLocale::Language language() const { return m_locale.language(); } @@ -94,9 +101,9 @@ public: * * This obeys special cases as described in the class documentation. */ - static QLocale getLocale( const QString& localeName ); + static QLocale getLocale( const Id& localeId ); -protected: +private: QLocale m_locale; QString m_localeId; // the locale identifier, e.g. "en_GB" QString m_label; // the native name of the locale diff --git a/src/libcalamares/locale/LabelModel.cpp b/src/libcalamares/locale/TranslationsModel.cpp similarity index 60% rename from src/libcalamares/locale/LabelModel.cpp rename to src/libcalamares/locale/TranslationsModel.cpp index 9a9be9905..25d075df4 100644 --- a/src/libcalamares/locale/LabelModel.cpp +++ b/src/libcalamares/locale/TranslationsModel.cpp @@ -9,7 +9,7 @@ * */ -#include "LabelModel.h" +#include "TranslationsModel.h" #include "Lookup.h" @@ -20,7 +20,7 @@ namespace CalamaresUtils namespace Locale { -LabelModel::LabelModel( const QStringList& locales, QObject* parent ) +TranslationsModel::TranslationsModel( const QStringList& locales, QObject* parent ) : QAbstractListModel( parent ) , m_localeIds( locales ) { @@ -29,20 +29,20 @@ LabelModel::LabelModel( const QStringList& locales, QObject* parent ) for ( const auto& l : locales ) { - m_locales.push_back( new Label( l, Label::LabelFormat::IfNeededWithCountry, this ) ); + m_locales.push_back( new Translation( { l }, Translation::LabelFormat::IfNeededWithCountry, this ) ); } } -LabelModel::~LabelModel() {} +TranslationsModel::~TranslationsModel() {} int -LabelModel::rowCount( const QModelIndex& ) const +TranslationsModel::rowCount( const QModelIndex& ) const { return m_locales.count(); } QVariant -LabelModel::data( const QModelIndex& index, int role ) const +TranslationsModel::data( const QModelIndex& index, int role ) const { if ( ( role != LabelRole ) && ( role != EnglishLabelRole ) ) { @@ -67,13 +67,13 @@ LabelModel::data( const QModelIndex& index, int role ) const } QHash< int, QByteArray > -LabelModel::roleNames() const +TranslationsModel::roleNames() const { return { { LabelRole, "label" }, { EnglishLabelRole, "englishLabel" } }; } -const Label& -LabelModel::locale( int row ) const +const Translation& +TranslationsModel::locale( int row ) const { if ( ( row < 0 ) || ( row >= m_locales.count() ) ) { @@ -88,7 +88,7 @@ LabelModel::locale( int row ) const } int -LabelModel::find( std::function< bool( const Label& ) > predicate ) const +TranslationsModel::find( std::function< bool( const Translation& ) > predicate ) const { for ( int row = 0; row < m_locales.count(); ++row ) { @@ -101,19 +101,19 @@ LabelModel::find( std::function< bool( const Label& ) > predicate ) const } int -LabelModel::find( std::function< bool( const QLocale& ) > predicate ) const +TranslationsModel::find( std::function< bool( const QLocale& ) > predicate ) const { - return find( [&]( const Label& l ) { return predicate( l.locale() ); } ); + return find( [&]( const Translation& l ) { return predicate( l.locale() ); } ); } int -LabelModel::find( const QLocale& locale ) const +TranslationsModel::find( const QLocale& locale ) const { - return find( [&]( const Label& l ) { return locale == l.locale(); } ); + return find( [&]( const Translation& l ) { return locale == l.locale(); } ); } int -LabelModel::find( const QString& countryCode ) const +TranslationsModel::find( const QString& countryCode ) const { if ( countryCode.length() != 2 ) { @@ -121,18 +121,20 @@ LabelModel::find( const QString& countryCode ) const } auto c_l = countryData( countryCode ); - int r = find( [&]( const Label& l ) { return ( l.language() == c_l.second ) && ( l.country() == c_l.first ); } ); + int r = find( + [&]( const Translation& l ) { return ( l.language() == c_l.second ) && ( l.country() == c_l.first ); } ); if ( r >= 0 ) { return r; } - return find( [&]( const Label& l ) { return l.language() == c_l.second; } ); + return find( [&]( const Translation& l ) { return l.language() == c_l.second; } ); } -LabelModel* +TranslationsModel* availableTranslations() { - static LabelModel* model = new LabelModel( QStringLiteral( CALAMARES_TRANSLATION_LANGUAGES ).split( ';' ) ); + static TranslationsModel* model + = new TranslationsModel( QStringLiteral( CALAMARES_TRANSLATION_LANGUAGES ).split( ';' ) ); return model; } diff --git a/src/libcalamares/locale/LabelModel.h b/src/libcalamares/locale/TranslationsModel.h similarity index 80% rename from src/libcalamares/locale/LabelModel.h rename to src/libcalamares/locale/TranslationsModel.h index 7e6f2dacc..b87c00027 100644 --- a/src/libcalamares/locale/LabelModel.h +++ b/src/libcalamares/locale/TranslationsModel.h @@ -9,11 +9,11 @@ * */ -#ifndef LOCALE_LABELMODEL_H -#define LOCALE_LABELMODEL_H +#ifndef LOCALE_TRANSLATIONSMODEL_H +#define LOCALE_TRANSLATIONSMODEL_H #include "DllMacro.h" -#include "Label.h" +#include "Translation.h" #include #include @@ -24,7 +24,7 @@ namespace CalamaresUtils namespace Locale { -class DLLEXPORT LabelModel : public QAbstractListModel +class DLLEXPORT TranslationsModel : public QAbstractListModel { Q_OBJECT @@ -35,8 +35,8 @@ public: EnglishLabelRole = Qt::UserRole + 1 }; - LabelModel( const QStringList& locales, QObject* parent = nullptr ); - ~LabelModel() override; + TranslationsModel( const QStringList& locales, QObject* parent = nullptr ); + ~TranslationsModel() override; int rowCount( const QModelIndex& parent ) const override; @@ -48,7 +48,7 @@ public: * This is the backing data for the model; if @p row is out-of-range, * returns a reference to en_US. */ - const Label& locale( int row ) const; + const Translation& locale( int row ) const; /// @brief Returns all of the locale Ids (e.g. en_US) put into this model. const QStringList& localeIds() const { return m_localeIds; } @@ -58,14 +58,14 @@ public: * Returns the row number of the first match, or -1 if there isn't one. */ int find( std::function< bool( const QLocale& ) > predicate ) const; - int find( std::function< bool( const Label& ) > predicate ) const; + int find( std::function< bool( const Translation& ) > predicate ) const; /// @brief Looks for an item using the same locale, -1 if there isn't one int find( const QLocale& ) const; /// @brief Looks for an item that best matches the 2-letter country code int find( const QString& countryCode ) const; private: - QVector< Label* > m_locales; + QVector< Translation* > m_locales; QStringList m_localeIds; }; @@ -79,7 +79,7 @@ private: * * NOTE: While the model is not typed const, it should be. Do not modify. */ -DLLEXPORT LabelModel* availableTranslations(); +DLLEXPORT TranslationsModel* availableTranslations(); } // namespace Locale } // namespace CalamaresUtils #endif diff --git a/src/libcalamares/utils/Retranslator.cpp b/src/libcalamares/utils/Retranslator.cpp index 2e71fc011..48b61c12a 100644 --- a/src/libcalamares/utils/Retranslator.cpp +++ b/src/libcalamares/utils/Retranslator.cpp @@ -19,6 +19,9 @@ #include #include +namespace +{ + static bool s_allowLocalTranslations = false; /** @brief Helper class for loading translations @@ -28,29 +31,8 @@ static bool s_allowLocalTranslations = false; */ struct TranslationLoader { - static QString mungeLocaleName( const QLocale& locale ) - { - QString localeName = locale.name(); - localeName.replace( "-", "_" ); - - if ( localeName == "C" ) - { - localeName = "en"; - } - - // Special case of sr@latin - // - // See top-level CMakeLists.txt about special cases for translation loading. - if ( locale.language() == QLocale::Language::Serbian && locale.script() == QLocale::Script::LatinScript ) - { - localeName = QStringLiteral( "sr@latin" ); - } - return localeName; - } - - TranslationLoader( const QLocale& locale ) - : m_locale( locale ) - , m_localeName( mungeLocaleName( locale ) ) + TranslationLoader( const QString& locale ) + : m_localeName( locale ) { } @@ -58,14 +40,13 @@ struct TranslationLoader /// @brief Loads @p translator with the specific translations of this type virtual bool tryLoad( QTranslator* translator ) = 0; - const QLocale& m_locale; QString m_localeName; }; /// @brief Loads translations for branding struct BrandingLoader : public TranslationLoader { - BrandingLoader( const QLocale& locale, const QString& prefix ) + BrandingLoader( const QString& locale, const QString& prefix ) : TranslationLoader( locale ) , m_prefix( prefix ) { @@ -106,7 +87,7 @@ BrandingLoader::tryLoad( QTranslator* translator ) { QString filenameBase( m_prefix ); filenameBase.remove( 0, m_prefix.lastIndexOf( QDir::separator() ) + 1 ); - if ( translator->load( m_locale, filenameBase, "_", brandingTranslationsDir.absolutePath() ) ) + if ( translator->load( m_localeName, filenameBase, "_", brandingTranslationsDir.absolutePath() ) ) { cDebug() << Logger::SubEntry << "Branding using locale:" << m_localeName; return true; @@ -181,6 +162,8 @@ loadSingletonTranslator( TranslationLoader&& loader, QTranslator*& translator_p } } +} // namespace + namespace CalamaresUtils { static QTranslator* s_brandingTranslator = nullptr; @@ -189,26 +172,32 @@ static QTranslator* s_tztranslator = nullptr; static QString s_translatorLocaleName; void -installTranslator( const QLocale& locale, const QString& brandingTranslationsPrefix ) +installTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const QString& brandingTranslationsPrefix ) { - loadSingletonTranslator( BrandingLoader( locale, brandingTranslationsPrefix ), s_brandingTranslator ); - loadSingletonTranslator( TZLoader( locale ), s_tztranslator ); - loadSingletonTranslator( CalamaresLoader( locale ), s_translator ); + s_translatorLocaleName = locale.name; - s_translatorLocaleName = CalamaresLoader::mungeLocaleName( locale ); + loadSingletonTranslator( BrandingLoader( locale.name, brandingTranslationsPrefix ), s_brandingTranslator ); + loadSingletonTranslator( TZLoader( locale.name ), s_tztranslator ); + loadSingletonTranslator( CalamaresLoader( locale.name ), s_translator ); } +void +installTranslator() +{ + // Just wrap it up like an Id + installTranslator( { QLocale::system().name() }, QString() ); +} -QString +CalamaresUtils::Locale::Translation::Id translatorLocaleName() { - return s_translatorLocaleName; + return { s_translatorLocaleName }; } bool -loadTranslator( const QLocale& locale, const QString& prefix, QTranslator* translator ) +loadTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const QString& prefix, QTranslator* translator ) { - return ::tryLoad( translator, prefix, locale.name() ); + return ::tryLoad( translator, prefix, locale.name ); } Retranslator::Retranslator( QObject* parent ) @@ -227,13 +216,15 @@ Retranslator::eventFilter( QObject* obj, QEvent* e ) return QObject::eventFilter( obj, e ); } -Retranslator* Retranslator::instance() +Retranslator* +Retranslator::instance() { - static Retranslator s_instance(nullptr); + static Retranslator s_instance( nullptr ); return &s_instance; } -void Retranslator::attach(QObject* o, std::function f) +void +Retranslator::attach( QObject* o, std::function< void() > f ) { connect( instance(), &Retranslator::languageChanged, o, f ); f(); diff --git a/src/libcalamares/utils/Retranslator.h b/src/libcalamares/utils/Retranslator.h index 9d8617cbd..efe12ef8a 100644 --- a/src/libcalamares/utils/Retranslator.h +++ b/src/libcalamares/utils/Retranslator.h @@ -12,8 +12,8 @@ #define UTILS_RETRANSLATOR_H #include "DllMacro.h" +#include "locale/Translation.h" -#include #include #include @@ -25,12 +25,15 @@ class QTranslator; namespace CalamaresUtils { -/** - * @brief installTranslator changes the application language. - * @param locale the new locale. +/** @brief changes the application language. + * @param locale the new locale (names as defined by Calamares). * @param brandingTranslationsPrefix the branding path prefix, from Calamares::Branding. */ -DLLEXPORT void installTranslator( const QLocale& locale, const QString& brandingTranslationsPrefix ); +DLLEXPORT void installTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const QString& brandingTranslationsPrefix ); + +/** @brief Initializes the translations with the current system settings + */ +DLLEXPORT void installTranslator(); /** @brief The name of the (locale of the) most recently installed translator * @@ -38,7 +41,7 @@ DLLEXPORT void installTranslator( const QLocale& locale, const QString& branding * QLocale passed in, because Calamares will munge some names and * may remap translations. */ -DLLEXPORT QString translatorLocaleName(); +DLLEXPORT CalamaresUtils::Locale::Translation::Id translatorLocaleName(); /** @brief Loads translations into the given @p translator * @@ -53,7 +56,7 @@ DLLEXPORT QString translatorLocaleName(); * * @returns @c true on success */ -DLLEXPORT bool loadTranslator( const QLocale& locale, const QString& prefix, QTranslator* translator ); +DLLEXPORT bool loadTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const QString& prefix, QTranslator* translator ); /** @brief Set @p allow to true to load translations from current dir. * diff --git a/src/modules/keyboard/KeyboardLayoutModel.cpp b/src/modules/keyboard/KeyboardLayoutModel.cpp index 34a1dec88..3b9ba19fe 100644 --- a/src/modules/keyboard/KeyboardLayoutModel.cpp +++ b/src/modules/keyboard/KeyboardLayoutModel.cpp @@ -27,7 +27,7 @@ retranslateKeyboardModels() { s_kbtranslator = new QTranslator; } - (void)CalamaresUtils::loadTranslator( QLocale(), QStringLiteral( "kb_" ), s_kbtranslator ); + (void)CalamaresUtils::loadTranslator( CalamaresUtils::translatorLocaleName(), QStringLiteral( "kb_" ), s_kbtranslator ); } diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp index 854d65eef..ce48edd82 100644 --- a/src/modules/locale/Config.cpp +++ b/src/modules/locale/Config.cpp @@ -15,7 +15,7 @@ #include "JobQueue.h" #include "Settings.h" #include "locale/Global.h" -#include "locale/Label.h" +#include "locale/Translation.h" #include "modulesystem/ModuleManager.h" #include "network/Manager.h" #include "utils/Logger.h" @@ -368,9 +368,9 @@ Config::currentTimezoneName() const static inline QString localeLabel( const QString& s ) { - using CalamaresUtils::Locale::Label; + using CalamaresUtils::Locale::Translation; - Label lang( s, Label::LabelFormat::AlwaysWithCountry ); + Translation lang( { s }, Translation::LabelFormat::AlwaysWithCountry ); return lang.label(); } diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index b2a49552b..94f2192c2 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -85,7 +85,7 @@ Config::retranslate() emit warningMessageChanged( m_warningMessage ); } -CalamaresUtils::Locale::LabelModel* +CalamaresUtils::Locale::TranslationsModel* Config::languagesModel() const { return m_languages; @@ -152,8 +152,6 @@ Config::initLanguages() if ( matchedLocaleIndex >= 0 ) { - QString name = m_languages->locale( matchedLocaleIndex ).name(); - cDebug() << Logger::SubEntry << "Matched with index" << matchedLocaleIndex << name; setLocaleIndex( matchedLocaleIndex ); } else @@ -188,17 +186,17 @@ Config::setLocaleIndex( int index ) m_localeIndex = index; - const auto& selectedLocale = m_languages->locale( m_localeIndex ).locale(); - cDebug() << "Index" << index << "Selected locale" << selectedLocale; + const auto& selectedTranslation = m_languages->locale( m_localeIndex ); + cDebug() << "Index" << index << "Selected locale" << selectedTranslation.id().name; - QLocale::setDefault( selectedLocale ); + QLocale::setDefault( selectedTranslation.locale() ); const auto* branding = Calamares::Branding::instance(); - CalamaresUtils::installTranslator( selectedLocale, branding ? branding->translationsDirectory() : QString() ); + CalamaresUtils::installTranslator( selectedTranslation.id(), branding ? branding->translationsDirectory() : QString() ); if ( Calamares::JobQueue::instance() && Calamares::JobQueue::instance()->globalStorage() ) { CalamaresUtils::Locale::insertGS( *Calamares::JobQueue::instance()->globalStorage(), QStringLiteral( "LANG" ), - CalamaresUtils::translatorLocaleName() ); + CalamaresUtils::translatorLocaleName().name ); } emit localeIndexChanged( m_localeIndex ); } diff --git a/src/modules/welcome/Config.h b/src/modules/welcome/Config.h index 6cce75f22..c01bdf7e3 100644 --- a/src/modules/welcome/Config.h +++ b/src/modules/welcome/Config.h @@ -11,8 +11,7 @@ #define WELCOME_CONFIG_H #include "checker/GeneralRequirements.h" - -#include "locale/LabelModel.h" +#include "locale/TranslationsModel.h" #include "modulesystem/RequirementsModel.h" #include @@ -29,7 +28,7 @@ class Config : public QObject * This is a list-model, with names and descriptions for the translations * available to Calamares. */ - Q_PROPERTY( CalamaresUtils::Locale::LabelModel* languagesModel READ languagesModel CONSTANT FINAL ) + Q_PROPERTY( CalamaresUtils::Locale::TranslationsModel* languagesModel READ languagesModel CONSTANT FINAL ) /** @brief The requirements (from modules) and their checked-status * * The model grows rows over time as each module is checked and its @@ -94,7 +93,7 @@ public: QString warningMessage() const; public slots: - CalamaresUtils::Locale::LabelModel* languagesModel() const; + CalamaresUtils::Locale::TranslationsModel* languagesModel() const; void retranslate(); ///@brief The **global** requirements model, from ModuleManager @@ -121,7 +120,7 @@ signals: private: void initLanguages(); - CalamaresUtils::Locale::LabelModel* m_languages = nullptr; + CalamaresUtils::Locale::TranslationsModel* m_languages = nullptr; std::unique_ptr< QSortFilterProxyModel > m_filtermodel; std::unique_ptr< GeneralRequirements > m_requirementsChecker; diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index 376fe1ea6..a82d873e9 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -20,7 +20,6 @@ #include "Settings.h" #include "ViewManager.h" -#include "locale/LabelModel.h" #include "modulesystem/ModuleManager.h" #include "modulesystem/RequirementsModel.h" #include "utils/CalamaresUtilsGui.h" @@ -275,5 +274,5 @@ LocaleTwoColumnDelegate::paint( QPainter* painter, const QStyleOptionViewItem& o Qt::AlignRight | Qt::AlignVCenter, option.palette, false, - index.data( CalamaresUtils::Locale::LabelModel::EnglishLabelRole ).toString() ); + index.data( CalamaresUtils::Locale::TranslationsModel::EnglishLabelRole ).toString() ); } diff --git a/src/modules/welcome/WelcomePage.h b/src/modules/welcome/WelcomePage.h index cbbc7f510..dba1f6a28 100644 --- a/src/modules/welcome/WelcomePage.h +++ b/src/modules/welcome/WelcomePage.h @@ -11,7 +11,7 @@ #ifndef WELCOMEPAGE_H #define WELCOMEPAGE_H -#include "locale/LabelModel.h" +#include "locale/TranslationsModel.h" #include #include @@ -64,7 +64,7 @@ private: Ui::WelcomePage* ui; CheckerContainer* m_checkingWidget; - CalamaresUtils::Locale::LabelModel* m_languages; + CalamaresUtils::Locale::TranslationsModel* m_languages; Config* m_conf; }; diff --git a/src/modules/welcomeq/WelcomeQmlViewStep.cpp b/src/modules/welcomeq/WelcomeQmlViewStep.cpp index 914ea4f3a..a13911b18 100644 --- a/src/modules/welcomeq/WelcomeQmlViewStep.cpp +++ b/src/modules/welcomeq/WelcomeQmlViewStep.cpp @@ -12,7 +12,7 @@ #include "checker/GeneralRequirements.h" -#include "locale/LabelModel.h" +#include "locale/TranslationsModel.h" #include "utils/Dirs.h" #include "utils/Logger.h" #include "utils/Variant.h"