Skip to content

Localization

Manages language translations for the application.

#include "Localization/Localization.h"

Public Functions

Name
Localization &instance()<br>Gets the singleton instance of the Localization class.
Localization(const Localization & ) =delete<br>Deleted copy constructor to enforce singleton pattern.
std::vector< AppLanguage >getAvailableLanguages()<br>Retrieves the list of available languages.
boolloadFromFile(const std::string & filename)<br>Loads translations from a file.
boolloadLanguage(const std::string & langName)<br>Loads a language by name.
boolloadLanguage(int langID)<br>Loads a language by its ID.
Localization &operator=(const Localization & ) =delete<br>Deleted assignment operator to enforce singleton pattern.
const std::string &translate(const std::string & key) const<br>Translates a given key.

Public Attributes

Name
intcurrentLanguageID <br>ID of the currently selected language.

Public Functions Documentation

function instance

cpp
static Localization & instance()
static Localization & instance()

Gets the singleton instance of the Localization class.

Return: Reference to the Localization instance.

function Localization

cpp
Localization(
    const Localization & 
) =delete
Localization(
    const Localization & 
) =delete

Deleted copy constructor to enforce singleton pattern.

function getAvailableLanguages

cpp
std::vector< AppLanguage > getAvailableLanguages()
std::vector< AppLanguage > getAvailableLanguages()

Retrieves the list of available languages.

Return: A vector containing available language options.

function loadFromFile

cpp
bool loadFromFile(
    const std::string & filename
)
bool loadFromFile(
    const std::string & filename
)

Loads translations from a file.

Parameters:

  • filename Path to the translation file.

Return: True if the file was successfully loaded, false otherwise.

function loadLanguage

cpp
bool loadLanguage(
    const std::string & langName
)
bool loadLanguage(
    const std::string & langName
)

Loads a language by name.

Parameters:

  • langName Name of the language to load.

Return: True if the language was successfully loaded, false otherwise.

function loadLanguage

cpp
bool loadLanguage(
    int langID
)
bool loadLanguage(
    int langID
)

Loads a language by its ID.

Parameters:

  • langID ID of the language to load.

Return: True if the language was successfully loaded, false otherwise.

function operator=

cpp
Localization & operator=(
    const Localization & 
) =delete
Localization & operator=(
    const Localization & 
) =delete

Deleted assignment operator to enforce singleton pattern.

function translate

cpp
const std::string & translate(
    const std::string & key
) const
const std::string & translate(
    const std::string & key
) const

Translates a given key.

Parameters:

  • key The key to be translated.

Return: Translated string corresponding to the key.

Public Attributes Documentation

variable currentLanguageID

cpp
int currentLanguageID = 0;
int currentLanguageID = 0;

ID of the currently selected language.


Updated on 2025-05-31 at 12:55:30 +0000