Manages application language switching and translation loading.
More...
#include <language_manager.h>
|
| void | languageChanged (const QString &code) |
| | Emitted when the application language changes.
|
|
| QString | translationDir () const |
| | Returns the directory where translation files are stored.
|
| QString | qmFileForCode (const QString &code) const |
| | Returns the full path to the .qm file for a given language code.
|
|
|
QTranslator | mTranslator |
| | Qt translator used to load and apply translations.
|
|
QString | mCurrentLanguage = "en_US" |
| | Currently active language code.
|
|
QList< LanguageOption > | mAvailableLanguages |
| | List of supported languages.
|
Manages application language switching and translation loading.
This class provides functionality to:
- Retrieve available languages
- Query and change the current language
- Load and install Qt translation files (.qm)
It emits a signal whenever the active language changes.
◆ LanguageManager()
| LanguageManager::LanguageManager |
( |
QObject * | parent = nullptr | ) |
|
|
explicit |
Constructs a LanguageManager instance.
- Parameters
-
| parent | The parent QObject. |
◆ availableLanguages()
Returns the list of available languages.
- Returns
- A list of LanguageOption entries.
◆ currentLanguage()
| QString LanguageManager::currentLanguage |
( |
| ) |
const |
Returns the currently active language code.
- Returns
- The current language code.
◆ languageChanged
| void LanguageManager::languageChanged |
( |
const QString & | code | ) |
|
|
signal |
Emitted when the application language changes.
- Parameters
-
| code | The newly selected language code. |
◆ qmFileForCode()
| QString LanguageManager::qmFileForCode |
( |
const QString & | code | ) |
const |
|
private |
Returns the full path to the .qm file for a given language code.
- Parameters
-
| code | The language code (e.g., "en_US"). |
- Returns
- The path to the corresponding .qm file.
◆ setLanguage()
| bool LanguageManager::setLanguage |
( |
const QString & | code | ) |
|
Sets the active language.
Loads the corresponding translation file and installs it in the application.
- Parameters
-
| code | The language code to activate (e.g., "en_US"). |
- Returns
- True if the language was successfully changed, false otherwise.
◆ translationDir()
| QString LanguageManager::translationDir |
( |
| ) |
const |
|
private |
Returns the directory where translation files are stored.
- Returns
- The absolute or relative path to the translation directory.
The documentation for this class was generated from the following files:
- /__w/maki/maki/app/widgets/language_manager.h
- /__w/maki/maki/app/widgets/language_manager.cpp