I18n
in
本地化 I18n 默认加载 en-WW.lang 语言包
! 需要Redis支持, 未安装/配置Redis高并发时会遇到CPU/内存瓶颈 ! Requires Redis support, CPU/memory bottlenecks will be encountered when Redis is not installed / configured with high concurrency
Table of Contents
$dictionary | 语言包字典 | array |
---|---|---|
$dictionaryLoaded | 语言包已加载 | bool |
$Redis | 缓存数据库 | ASRedis |
$RedisEnabled | 缓存数据库已启用 | bool |
$lang | 当前语言 | string |
$customDirectory | 自定义路径 | string |
__construct() | mixed | |
shared() | 单例 | I18n |
setLang() | 设置本地化语言 setLang | void |
setCustomPath() | 自定义语言包路径 setCustomPath | void |
checkDictionary() | 检查语言包是否加载 checkDictionary | void |
loadDictionary() | 加载语言包 loadDictionary | void |
supplementWith() | 通过路径自动加载额外本地化文件 supplementWith | void |
cacheToRedis() | 缓存到Redis服务器 cacheToRedis | void |
translate() | 进行文本的本地化处理 Translate text with code | string |
transcoding() | 对内容进行域内转码 Transcode in scope | string |
currentLang() | string |
Properties
$dictionary
语言包字典
private
array
$dictionary
$dictionaryLoaded
语言包已加载
private
bool
$dictionaryLoaded
= false
$Redis
缓存数据库
private
ASRedis
$Redis
$RedisEnabled
缓存数据库已启用
private
bool
$RedisEnabled
= false
$lang
当前语言
private
string
$lang
= "en-WW"
$customDirectory
自定义路径
private
string
$customDirectory
Methods
__construct()
public
__construct(
[ $lang :
string
= "en-WW" ]
)
: mixed
Parameters
- $lang : string = "en-WW"
Return values
mixedshared()
单例
public
static shared(
[ $lang :
string
= "en-WW" ]
)
: I18n
Parameters
- $lang : string = "en-WW"
Return values
I18nsetLang()
设置本地化语言 setLang
public
setLang(
$lang :
string
)
: void
Parameters
- $lang : string
setCustomPath()
自定义语言包路径 setCustomPath
public
setCustomPath(
$fullDirectPath :
string
)
: void
Parameters
- $fullDirectPath : string
checkDictionary()
检查语言包是否加载 checkDictionary
public
checkDictionary(
)
: void
loadDictionary()
加载语言包 loadDictionary
public
loadDictionary(
[ $refresh :
bool
= false ]
)
: void
Parameters
- $refresh : bool = false
强制刷新
supplementWith()
通过路径自动加载额外本地化文件 supplementWith
public
supplementWith(
$directory :
string
[, $refresh :
bool
= false ]
)
: void
Parameters
- $directory : string
- $refresh : bool = false
cacheToRedis()
缓存到Redis服务器 cacheToRedis
private
cacheToRedis(
$fileID :
string
)
: void
Parameters
- $fileID : string
translate()
进行文本的本地化处理 Translate text with code
public
translate(
$code :
string
)
: string
Parameters
- $code : string
Return values
stringtranscoding()
对内容进行域内转码 Transcode in scope
public
transcoding(
$code :
string
, $inScope :
string
)
: string
Parameters
- $code : string
- $inScope : string
Return values
stringcurrentLang()
public
currentLang(
)
: string