Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
rtp::client::TranslationManager Class Reference

Manages game translations for all UI elements. More...

#include <TranslationManager.hpp>

Collaboration diagram for rtp::client::TranslationManager:

Public Member Functions

 TranslationManager ()=default
 
bool loadLanguage (Language language)
 Load translations for a specific language.
 
std::string get (const std::string &key) const
 Get translated string for a key.
 
template<typename... Args>
std::string getf (const std::string &key, Args &&... args) const
 Get translated string with format arguments.
 
Language getCurrentLanguage () const
 

Private Member Functions

std::string getLanguageFilePath (Language lang) const
 Get file path for a given language.
 

Private Attributes

std::unordered_map< std::string, std::string > _translations
 Map of translation keys to translated strings.
 
Language _currentLanguage {Language::English}
 Currently loaded language.
 

Detailed Description

Manages game translations for all UI elements.

Definition at line 23 of file TranslationManager.hpp.

Constructor & Destructor Documentation

◆ TranslationManager()

rtp::client::TranslationManager::TranslationManager ( )
default

Member Function Documentation

◆ get()

std::string rtp::client::TranslationManager::get ( const std::string &  key) const

◆ getCurrentLanguage()

Language rtp::client::TranslationManager::getCurrentLanguage ( ) const
inline

Definition at line 54 of file TranslationManager.hpp.

References _currentLanguage.

◆ getf()

template<typename... Args>
std::string rtp::client::TranslationManager::getf ( const std::string &  key,
Args &&...  args 
) const
inline

Get translated string with format arguments.

Template Parameters
ArgsFormat argument types
Parameters
keyThe translation key
argsFormat arguments
Returns
Formatted translated string

Definition at line 49 of file TranslationManager.hpp.

References get().

◆ getLanguageFilePath()

std::string rtp::client::TranslationManager::getLanguageFilePath ( Language  lang) const
private

Get file path for a given language.

Definition at line 13 of file TranslationManager.cpp.

References rtp::client::English, rtp::client::French, rtp::client::German, rtp::client::Italian, and rtp::client::Spanish.

Referenced by loadLanguage().

◆ loadLanguage()

bool rtp::client::TranslationManager::loadLanguage ( Language  language)

Load translations for a specific language.

Parameters
languageThe language to load
Returns
true if successful, false otherwise

Definition at line 24 of file TranslationManager.cpp.

References _currentLanguage, _translations, rtp::log::error(), getLanguageFilePath(), and rtp::log::info().

Referenced by rtp::client::scenes::SettingsScene::onEnter(), rtp::client::scenes::SettingsScene::onExit(), and rtp::client::Application::setupSettingsCallbacks().

Member Data Documentation

◆ _currentLanguage

Language rtp::client::TranslationManager::_currentLanguage {Language::English}
private

Currently loaded language.

Definition at line 59 of file TranslationManager.hpp.

Referenced by getCurrentLanguage(), and loadLanguage().

◆ _translations

std::unordered_map<std::string, std::string> rtp::client::TranslationManager::_translations
private

Map of translation keys to translated strings.

Definition at line 58 of file TranslationManager.hpp.

Referenced by get(), and loadLanguage().


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