Maki
Formally verfied low-code orchestration
Loading...
Searching...
No Matches
LanguageManager Class Reference

Manages application language switching and translation loading. More...

#include <language_manager.h>

Inheritance diagram for LanguageManager:

Classes

struct  LanguageOption
 Represents a selectable language option. More...

Signals

void languageChanged (const QString &code)
 Emitted when the application language changes.

Public Member Functions

 LanguageManager (QObject *parent=nullptr)
 Constructs a LanguageManager instance.
QList< LanguageOption > availableLanguages () const
 Returns the list of available languages.
QString currentLanguage () const
 Returns the currently active language code.
bool setLanguage (const QString &code)
 Sets the active language.

Private Member Functions

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.

Private Attributes

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ LanguageManager()

LanguageManager::LanguageManager ( QObject * parent = nullptr)
explicit

Constructs a LanguageManager instance.

Parameters
parentThe parent QObject.

Member Function Documentation

◆ availableLanguages()

QList< LanguageManager::LanguageOption > LanguageManager::availableLanguages ( ) const

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
codeThe 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
codeThe 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
codeThe 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