|
MetaImGUI 1.0.0
ImGui Application Template for C++20
|
Simple localization/internationalization system. More...
#include <Localization.h>
Public Member Functions | |
| Localization (const Localization &)=delete | |
| Localization & | operator= (const Localization &)=delete |
| Localization (Localization &&)=delete | |
| Localization & | operator= (Localization &&)=delete |
| void | SetLanguage (const std::string &languageCode) |
| Set current language. | |
| std::string | GetCurrentLanguage () const |
| Get current language code. | |
| std::vector< std::string > | GetAvailableLanguages () const |
| Get list of available languages. | |
| std::string | Tr (const std::string &key) const |
| Get translated string. | |
| void | AddTranslation (const std::string &languageCode, const std::string &key, const std::string &value) |
| Add translation for a language. | |
| bool | LoadTranslations (const std::string &filepath) |
| Load translations from JSON file. | |
Static Public Member Functions | |
| static Localization & | Instance () |
| Get singleton instance. | |
Simple localization/internationalization system.
Provides translation services for UI strings using key-value pairs. Supports multiple languages with fallback to English.
IMPORTANT: All translations MUST come from resources/translations/translations.json DO NOT add built-in translations here. This is the single source of truth.
Definition at line 36 of file Localization.h.
|
delete |
|
delete |
| void MetaImGUI::Localization::AddTranslation | ( | const std::string & | languageCode, |
| const std::string & | key, | ||
| const std::string & | value | ||
| ) |
Add translation for a language.
| languageCode | Language code |
| key | Translation key |
| value | Translated string |
Definition at line 104 of file Localization.cpp.
Referenced by LoadTranslations().
| std::vector< std::string > MetaImGUI::Localization::GetAvailableLanguages | ( | ) | const |
Get list of available languages.
Definition at line 70 of file Localization.cpp.
| std::string MetaImGUI::Localization::GetCurrentLanguage | ( | ) | const |
Get current language code.
Definition at line 66 of file Localization.cpp.
|
static |
Get singleton instance.
Definition at line 52 of file Localization.cpp.
Referenced by MetaImGUI::Application::Initialize(), MetaImGUI::UIRenderer::RenderAboutWindow(), MetaImGUI::UIRenderer::RenderMainWindow(), MetaImGUI::UIRenderer::RenderMenuBar(), and MetaImGUI::Application::Shutdown().
| bool MetaImGUI::Localization::LoadTranslations | ( | const std::string & | filepath | ) |
Load translations from JSON file.
| filepath | Path to JSON translation file |
Definition at line 108 of file Localization.cpp.
References AddTranslation(), LOG_ERROR, and LOG_INFO.
Referenced by MetaImGUI::Application::Initialize().
|
delete |
|
delete |
| void MetaImGUI::Localization::SetLanguage | ( | const std::string & | languageCode | ) |
Set current language.
| languageCode | ISO 639-1 language code (e.g., "en", "es", "fr") |
Definition at line 57 of file Localization.cpp.
References LOG_ERROR, and LOG_INFO.
Referenced by MetaImGUI::Application::Initialize().
| std::string MetaImGUI::Localization::Tr | ( | const std::string & | key | ) | const |
Get translated string.
| key | Translation key |
Definition at line 79 of file Localization.cpp.