Documentation
¶
Overview ¶
Package localeutil 提供一些本地化的工具
Index ¶
- func DetectUserLanguageTag() (language.Tag, error)
- func Error(key Key, val ...interface{}) error
- func LoadMessage(b *catalog.Builder, data []byte, unmarshal UnmarshalFunc) error
- func LoadMessageFromFS(b *catalog.Builder, fsys fs.FS, path string, unmarshal UnmarshalFunc) error
- func LoadMessageFromFSGlob(b *catalog.Builder, fsys fs.FS, glob string, unmarshal UnmarshalFunc) error
- type Key
- type LocaleStringer
- type Printer
- type UnmarshalFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectUserLanguageTag ¶ added in v0.7.0
DetectUserLanguageTag 检测当前用户的本地化信息
使用 LANG 环境变量中的值,windows 在 LANG 环境变量不存在的情况下,调用 GetUserDefaultLocaleName 函数获取。
func LoadMessage ¶ added in v0.12.4
func LoadMessage(b *catalog.Builder, data []byte, unmarshal UnmarshalFunc) error
LoadMessage 解析 data 并写入 b
func LoadMessageFromFS ¶ added in v0.2.0
LoadMessageFromFS 从文件系统中加载文件并写入 b
unmarshal 用于解析从 path 加载的文件;
func LoadMessageFromFSGlob ¶ added in v0.9.0
func LoadMessageFromFSGlob(b *catalog.Builder, fsys fs.FS, glob string, unmarshal UnmarshalFunc) error
LoadMessageFromFSGlob 从文件系统中加载多个文件并写入 b
Types ¶
type LocaleStringer ¶ added in v0.5.0
LocaleStringer 本地化字符串的接口中
func Phrase ¶ added in v0.4.0
func Phrase(key Key, val ...interface{}) LocaleStringer
Phrase 返回一段未翻译的语言片段
key 和 val 参数与 golang.org/x/text/message.Printer.Sprintf 的参数相同。 如果 val 也实现了 LocaleStringer 接口,则会先调用 val 的 LocaleString 方法再传递给 Sprintf。
type UnmarshalFunc ¶ added in v0.9.0
type UnmarshalFunc = message.UnmarshalFunc
UnmarshalFunc 解析文本内容至对象的方法
Click to show internal directories.
Click to hide internal directories.