11#include <QVariantList>
32 QObject* parent =
nullptr);
38 return currentLanguage_;
51 return availableLanguages_;
73 void refreshAvailableLanguages();
74 bool isLanguageAvailable(
const QString& languageCode)
const;
75 QString normalizeLanguageCode(
const QString& languageCode)
const;
76 QString translationFileName(
const QString& languageCode)
const;
77 bool translationFileExists(
const QString& languageCode)
const;
78 bool applyCurrentLanguage(
const QString& languageCode);
79 bool loadTranslation(
const QString& languageCode);
81 void persistLanguage(
const QString& languageCode);
82 QString persistedLanguage()
const;
84 QApplication* application_ =
nullptr;
85 QQmlEngine* engine_ =
nullptr;
86 QTranslator translator_;
87 QVariantList availableLanguages_;
88 QString currentLanguage_;
void setCurrentLanguage(const QString &languageCode)
Switch the active UI language if the requested translation is available.
QVariantList availableLanguages() const
Return the available language options for the UI.
void availableLanguagesChanged()
Emitted when the available language list changes.
QVariantList availableLanguages
LanguageService(QApplication *application, QQmlEngine *engine, QObject *parent=nullptr)
Create a language service bound to the application and QML engine.
void currentLanguageChanged()
Emitted when the active language changes.
Q_INVOKABLE bool applyLanguage(const QString &languageCode)
Applies a language code from QML.