maix.i18n
maix.i18n module
You can use
maix.i18n
to access this module with MaixPy
This module is generated from MaixCDK
Module
No module
Enum
Variable
locales
item | doc |
---|---|
brief | i18n locales list |
value | { "en", "zh", "zh-tw", "ja" } |
readonly | False |
C++ defination code:
static std::vector<std::string> locales = {
"en",
"zh",
"zh-tw",
"ja"
}
names
item | doc |
---|---|
brief | i18n language names list |
value | { "English", "简体中文", "繁體中文", "日本語" } |
readonly | True |
C++ defination code:
const static std::vector<std::string> names = {
"English",
"简体中文",
"繁體中文",
"日本語"
}
Function
get_locale
def get_locale(self) -> str
item | doc |
---|---|
brief | Get system config of locale. |
return | language locale, e.g. en, zh, zh_CN, zh_TW, etc. |
C++ defination code:
string get_locale()
get_language_name
item | doc |
---|---|
brief | Get system config of language name. |
return | language name, e.g. English, 简体中文, 繁體中文, etc. |
C++ defination code:
string get_language_name()
Class
Trans
item | doc |
---|---|
brief | Translate helper class. |
C++ defination code:
class Trans
__init__
def __init__(self, locales_dict: dict[str, dict[str, str]]) -> None
item | doc |
---|---|
type | func |
brief | Translate helper class constructor.\nBy default locale is get by i18n.get_locale() function which set by system settings.\nBut you can also manually set by set_locale function temporarily. |
param | locales_dict: locales dict, e.g. {"zh": {"Confirm": "确认", "OK": "好的"}, "en": {"Confirm": "Confirm", "OK": "OK"}} |
static | False |
C++ defination code:
Trans(const std::map<string, const std::map<string, string>> &locales_dict)
tr
def tr(self, key: str, locale: str = '') -> str
item | doc |
---|---|
type | func |
brief | Translate string by key. |
param | key: string key, e.g. "Confirm" locale: locale name, if not assign, use default locale set by system settings or set_locale function. |
return | translated string, if find translation, return it, or return key, e.g. "确认", "Confirm", etc. |
static | False |
C++ defination code:
string tr(const string &key, const string locale = "")
set_locale
def set_locale(self, locale: str) -> None
item | doc |
---|---|
type | func |
brief | Set locale temporarily, will not affect system settings. |
param | locale: locale name, e.g. "zh", "en", etc. @see maix.i18n.locales |
static | False |
C++ defination code:
void set_locale(const string &locale)
get_locale
def get_locale(self) -> str
item | doc |
---|---|
type | func |
brief | Get current locale. |
return | locale name, e.g. "zh", "en", etc. @see maix.i18n.locales |
static | False |
C++ defination code:
string get_locale()