wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
LanguageManager Class Reference

Owns the application QTranslator instances and provides language metadata. More...

#include <LanguageManager.h>

Inheritance diagram for LanguageManager:
[legend]

Public Member Functions

QStringList availableLanguages () const
 Returns all available translation language codes, sorted, with "en" first.
QString displayName (const QString &langCode) const
 Returns the native display name for langCode (e.g. "Deutsch" for "de").
QString flagIcon (const QString &langCode) const
 Returns the flag icon resource path for langCode.
 LanguageManager (QObject *parent=nullptr)
void loadTranslation (const QString &language)
 Loads and installs the Qt translation for language.
void translationChanged ()
 Emitted after a translation has been successfully loaded (or reset to English).
 ~LanguageManager () override

Detailed Description

Owns the application QTranslator instances and provides language metadata.

Encapsulates all translation concerns: discovering available .qm files, loading/unloading QTranslator objects, and mapping language codes to display names and flag icon resource paths. Emits translationChanged() after each successful load so the UI can retranslate itself.

Definition at line 24 of file LanguageManager.h.

Constructor & Destructor Documentation

◆ LanguageManager()

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

Definition at line 39 of file LanguageManager.cpp.

◆ ~LanguageManager()

LanguageManager::~LanguageManager ( )
override

Definition at line 48 of file LanguageManager.cpp.

References Application::instance().

Member Function Documentation

◆ availableLanguages()

QStringList LanguageManager::availableLanguages ( ) const

Returns all available translation language codes, sorted, with "en" first.

Definition at line 97 of file LanguageManager.cpp.

◆ displayName()

QString LanguageManager::displayName ( const QString & langCode) const

Returns the native display name for langCode (e.g. "Deutsch" for "de").

Parameters
langCodeBCP-47 language code.

Definition at line 136 of file LanguageManager.cpp.

◆ flagIcon()

QString LanguageManager::flagIcon ( const QString & langCode) const

Returns the flag icon resource path for langCode.

Parameters
langCodeBCP-47 language code.

Definition at line 171 of file LanguageManager.cpp.

◆ loadTranslation()

void LanguageManager::loadTranslation ( const QString & language)

Loads and installs the Qt translation for language.

Falls back to English if the .qm file is missing or fails to load. Emits translationChanged() after the translators are installed.

Parameters
languageBCP-47 language code (e.g. "en", "pt_BR").

Definition at line 54 of file LanguageManager.cpp.

References Application::instance(), loadTranslation(), Settings::setLanguage(), and translationChanged().

Referenced by loadTranslation().

◆ translationChanged()

void LanguageManager::translationChanged ( )

Emitted after a translation has been successfully loaded (or reset to English).

Referenced by loadTranslation().


The documentation for this class was generated from the following files: