Manages the active UI language and the available translation options.
More...
#include <LanguageService.h>
|
| | LanguageService (QApplication *application, QQmlEngine *engine, QObject *parent=nullptr) |
| | Create a language service bound to the application and QML engine.
|
| QString | currentLanguage () const |
| | Return the active UI language code.
|
| 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.
|
| Q_INVOKABLE bool | applyLanguage (const QString &languageCode) |
| | Applies a language code from QML.
|
Manages the active UI language and the available translation options.
Definition at line 21 of file LanguageService.h.
◆ LanguageService()
| ui::LanguageService::LanguageService |
( |
QApplication * | application, |
|
|
QQmlEngine * | engine, |
|
|
QObject * | parent = nullptr ) |
|
explicit |
Create a language service bound to the application and QML engine.
Definition at line 61 of file LanguageService.cpp.
◆ applyLanguage()
| bool ui::LanguageService::applyLanguage |
( |
const QString & | languageCode | ) |
|
Applies a language code from QML.
- Parameters
-
| languageCode | Language code requested by the user. |
- Returns
- True when the language was applied or already active.
Definition at line 79 of file LanguageService.cpp.
◆ availableLanguages()
| QVariantList ui::LanguageService::availableLanguages |
( |
| ) |
const |
|
inline |
Return the available language options for the UI.
- Returns
- QML-friendly list of language option rows.
Definition at line 50 of file LanguageService.h.
◆ availableLanguagesChanged
| void ui::LanguageService::availableLanguagesChanged |
( |
| ) |
|
|
signal |
Emitted when the available language list changes.
◆ currentLanguage()
| QString ui::LanguageService::currentLanguage |
( |
| ) |
const |
|
inline |
Return the active UI language code.
- Returns
- Current language code
Definition at line 37 of file LanguageService.h.
◆ currentLanguageChanged
| void ui::LanguageService::currentLanguageChanged |
( |
| ) |
|
|
signal |
Emitted when the active language changes.
◆ setCurrentLanguage()
| void ui::LanguageService::setCurrentLanguage |
( |
const QString & | languageCode | ) |
|
Switch the active UI language if the requested translation is available.
- Parameters
-
| languageCode | Language code to set |
Definition at line 84 of file LanguageService.cpp.
◆ availableLanguages
| QVariantList ui::LanguageService::availableLanguages |
|
read |
◆ currentLanguage
| QString ui::LanguageService::currentLanguage |
|
read |
The documentation for this class was generated from the following files: