yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::i18n::LanguageManager Class Reference

#include <language_manager.h>

Public Types

using LanguageChangedCallback = std::function<void(const std::string&)>
 

Public Member Functions

std::vector< std::string > GetAvailableLocales () const
 
const std::string & GetCurrentLocale () const
 
void SetLanguage (const std::string &locale)
 
void SetOnLanguageChangedCallback (LanguageChangedCallback cb)
 
const std::string * Find (const std::string &visible_key) const
 
bool LoadCatalogFromStringForTesting (const std::string &locale, const std::string &json_text)
 

Static Public Member Functions

static LanguageManagerGet ()
 

Private Member Functions

 LanguageManager ()
 
bool LoadCatalog (const std::string &locale)
 

Private Attributes

std::map< std::string, std::unordered_map< std::string, std::string > > catalogs_
 
std::string current_locale_ = "en"
 
LanguageChangedCallback on_changed_
 

Detailed Description

Definition at line 20 of file language_manager.h.

Member Typedef Documentation

◆ LanguageChangedCallback

using yaze::i18n::LanguageManager::LanguageChangedCallback = std::function<void(const std::string&)>

Definition at line 34 of file language_manager.h.

Constructor & Destructor Documentation

◆ LanguageManager()

yaze::i18n::LanguageManager::LanguageManager ( )
private

Definition at line 215 of file language_manager.cc.

References catalogs_.

Member Function Documentation

◆ Get()

◆ GetAvailableLocales()

std::vector< std::string > yaze::i18n::LanguageManager::GetAvailableLocales ( ) const

◆ GetCurrentLocale()

const std::string & yaze::i18n::LanguageManager::GetCurrentLocale ( ) const
inline

Definition at line 27 of file language_manager.h.

References current_locale_.

Referenced by yaze::editor::MenuOrchestrator::AddHelpMenuItems().

◆ SetLanguage()

void yaze::i18n::LanguageManager::SetLanguage ( const std::string & locale)

◆ SetOnLanguageChangedCallback()

void yaze::i18n::LanguageManager::SetOnLanguageChangedCallback ( LanguageChangedCallback cb)
inline

◆ Find()

const std::string * yaze::i18n::LanguageManager::Find ( const std::string & visible_key) const

◆ LoadCatalogFromStringForTesting()

bool yaze::i18n::LanguageManager::LoadCatalogFromStringForTesting ( const std::string & locale,
const std::string & json_text )

Definition at line 292 of file language_manager.cc.

References catalogs_.

◆ LoadCatalog()

bool yaze::i18n::LanguageManager::LoadCatalog ( const std::string & locale)
private

Definition at line 247 of file language_manager.cc.

References catalogs_, yaze::util::PlatformPaths::FindAsset(), and yaze::util::logf().

Referenced by SetLanguage().

Here is the call graph for this function:

Member Data Documentation

◆ catalogs_

std::map<std::string, std::unordered_map<std::string, std::string> > yaze::i18n::LanguageManager::catalogs_
private

◆ current_locale_

std::string yaze::i18n::LanguageManager::current_locale_ = "en"
private

Definition at line 58 of file language_manager.h.

Referenced by Find(), GetCurrentLocale(), and SetLanguage().

◆ on_changed_

LanguageChangedCallback yaze::i18n::LanguageManager::on_changed_
private

Definition at line 59 of file language_manager.h.

Referenced by SetLanguage(), and SetOnLanguageChangedCallback().


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