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. |
bool | loadFromFile(const std::string & filename)<br>Loads translations from a file. |
bool | loadLanguage(const std::string & langName)<br>Loads a language by name. |
bool | loadLanguage(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 | |
---|---|
int | currentLanguageID <br>ID of the currently selected language. |
Public Functions Documentation
function instance
static Localization & instance()
static Localization & instance()
Gets the singleton instance of the Localization class.
Return: Reference to the Localization instance.
function Localization
Localization(
const Localization &
) =delete
Localization(
const Localization &
) =delete
Deleted copy constructor to enforce singleton pattern.
function getAvailableLanguages
std::vector< AppLanguage > getAvailableLanguages()
std::vector< AppLanguage > getAvailableLanguages()
Retrieves the list of available languages.
Return: A vector containing available language options.
function loadFromFile
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
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
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=
Localization & operator=(
const Localization &
) =delete
Localization & operator=(
const Localization &
) =delete
Deleted assignment operator to enforce singleton pattern.
function translate
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
int currentLanguageID = 0;
int currentLanguageID = 0;
ID of the currently selected language.
Updated on 2025-05-31 at 12:55:30 +0000