载入中...
搜索中...
未找到
eve::i18n::I18n类 参考

Game localization (i18n) module. 更多...

#include <I18n.h>

类 eve::i18n::I18n 继承关系图:
eve::Module

Public 成员函数

 Module_REG (I18n)
 
 I18n ()=default
 
 ~I18n () override=default
 
bool loadFromJson (const std::string &lang, const std::string &json)
 加载语言表(JSON 文本 / 文件)。
 
bool loadFromFile (const std::string &lang, const std::string &path)
 
void unload (const std::string &lang)
 卸载 / 清空语言表。
 
void clear ()
 
bool setLanguage (const std::string &lang)
 语言管理:当前语言 / 默认语言回退。
 
std::string getLanguage () const
 
void setDefaultLanguage (const std::string &lang)
 
std::string getDefaultLanguage () const
 
int getLanguageCount () const
 
std::string getLanguageAt (int index) const
 
bool hasLanguage (const std::string &lang) const
 
bool has (const std::string &key) const
 翻译查找:按键(点号命名空间)取字符串。
 
std::string get (const std::string &key) const
 
std::string getWithParams (const std::string &key, const std::unordered_map< std::string, std::string > &params) const
 
std::string getPlural (const std::string &key, int n) const
 
std::string getPluralWithParams (const std::string &key, int n, const std::unordered_map< std::string, std::string > &params) const
 
void setAutoReload (bool enable)
 
bool isAutoReload () const
 
int update (float dt)
 Re-read changed locale files; returns the number of reloads performed.
 
- Public 成员函数 继承自 eve::Module
virtual ~Module ()
 
virtual std::string getName () const =0
 

详细描述

Game localization (i18n) module.

Locale tables map a translation key to a string (or a set of plural forms). Keys use dot notation for namespacing, e.g. menu.start resolves the JSON path menu -> start. Lookup falls back to the default language and finally to the raw key so untranslated keys stay visible during development.

Locale JSON shape:

{
"menu": { "start": "Start", "quit": "Quit" },
"items": { "one": "{n} item", "other": "{n} items" },
"greeting": "Hello, {name}!"
}

An object whose keys are all plural categories (zero/one/two/few/many/other) is treated as a plural form table for its key. {name} placeholders are substituted from the params table; {n} is filled by getPlural.

Script: i18n <- eve.I18n();

在文件 I18n.h35 行定义.

构造及析构函数说明

◆ I18n()

eve::i18n::I18n::I18n ( )
default

◆ ~I18n()

eve::i18n::I18n::~I18n ( )
overridedefault

成员函数说明

◆ clear()

void eve::i18n::I18n::clear ( )

在文件 I18n.cpp194 行定义.

◆ get()

std::string eve::i18n::I18n::get ( const std::string &  key) const

在文件 I18n.cpp229 行定义.

被这些函数引用 getWithParams().

◆ getDefaultLanguage()

std::string eve::i18n::I18n::getDefaultLanguage ( ) const
inline

在文件 I18n.h52 行定义.

◆ getLanguage()

std::string eve::i18n::I18n::getLanguage ( ) const
inline

在文件 I18n.h50 行定义.

◆ getLanguageAt()

std::string eve::i18n::I18n::getLanguageAt ( int  index) const

在文件 I18n.cpp204 行定义.

◆ getLanguageCount()

int eve::i18n::I18n::getLanguageCount ( ) const
inline

在文件 I18n.h53 行定义.

◆ getPlural()

std::string eve::i18n::I18n::getPlural ( const std::string &  key,
int  n 
) const

在文件 I18n.cpp270 行定义.

引用了 getPluralWithParams() , 以及 n.

◆ getPluralWithParams()

std::string eve::i18n::I18n::getPluralWithParams ( const std::string &  key,
int  n,
const std::unordered_map< std::string, std::string > &  params 
) const

在文件 I18n.cpp274 行定义.

引用了 n.

被这些函数引用 getPlural().

◆ getWithParams()

std::string eve::i18n::I18n::getWithParams ( const std::string &  key,
const std::unordered_map< std::string, std::string > &  params 
) const

在文件 I18n.cpp265 行定义.

引用了 get().

◆ has()

bool eve::i18n::I18n::has ( const std::string &  key) const

翻译查找:按键(点号命名空间)取字符串。

在文件 I18n.cpp217 行定义.

◆ hasLanguage()

bool eve::i18n::I18n::hasLanguage ( const std::string &  lang) const

在文件 I18n.cpp213 行定义.

被这些函数引用 setLanguage().

◆ isAutoReload()

bool eve::i18n::I18n::isAutoReload ( ) const
inline

在文件 I18n.h68 行定义.

◆ loadFromFile()

bool eve::i18n::I18n::loadFromFile ( const std::string &  lang,
const std::string &  path 
)

在文件 I18n.cpp158 行定义.

引用了 error, eve::filesystem::FileData::getData() , 以及 eve::filesystem::FileData::getSize().

被这些函数引用 update().

◆ loadFromJson()

bool eve::i18n::I18n::loadFromJson ( const std::string &  lang,
const std::string &  json 
)

加载语言表(JSON 文本 / 文件)。

在文件 I18n.cpp147 行定义.

引用了 error.

◆ Module_REG()

eve::i18n::I18n::Module_REG ( I18n  )

◆ setAutoReload()

void eve::i18n::I18n::setAutoReload ( bool  enable)
inline

在文件 I18n.h67 行定义.

◆ setDefaultLanguage()

void eve::i18n::I18n::setDefaultLanguage ( const std::string &  lang)
inline

在文件 I18n.h51 行定义.

◆ setLanguage()

bool eve::i18n::I18n::setLanguage ( const std::string &  lang)

语言管理:当前语言 / 默认语言回退。

在文件 I18n.cpp198 行定义.

引用了 hasLanguage().

◆ unload()

void eve::i18n::I18n::unload ( const std::string &  lang)

卸载 / 清空语言表。

在文件 I18n.cpp190 行定义.

◆ update()

int eve::i18n::I18n::update ( float  dt)

Re-read changed locale files; returns the number of reloads performed.

在文件 I18n.cpp350 行定义.

引用了 dirty , 以及 loadFromFile().


该类的文档由以下文件生成: