i18nKit

package
v3.0.903 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Associate added in v3.0.21

func Associate(bundle *i18n.Bundle, messageFile *i18n.MessageFile, languageCodes ...string) (err error)

Associate 关联其他语言代码.

@param languageCode 语言代码,(1) 可参考: i18nKit/_info.md

(2) 大小写“不敏感”

func GetMessage

func GetMessage(bundle *i18n.Bundle, messageId string, langs ...string) (string, error)

GetMessage

@param langs 可以不传,此时将使用 bundle 的默认语言

func LoadMessageFile added in v3.0.20

func LoadMessageFile(bundle *i18n.Bundle, path string) (*i18n.MessageFile, error)

LoadMessageFile

@param path 文件的路径(绝对 || 相对; 必须存在且是个文件)

func LoadMessageFileBytes added in v3.0.20

func LoadMessageFileBytes(bundle *i18n.Bundle, content []byte, path string) (*i18n.MessageFile, error)

LoadMessageFileBytes

@param path 文件名 或 文件的路径(绝对 || 相对; 可以不存在)

func NewBundle

func NewBundle(defaultLanguage language.Tag) *i18n.Bundle

NewBundle

PS: (1) 返回的 *i18n.Bundle 实例,后续可以通过 Bundle.LoadMessageFile() 或 Bundle.ParseMessageFileBytes() 继续加载message file; (2) Bundle.ParseMessageFileBytes(buf []byte, path string),传参path可以是 文件名 || 文件路径(相对或绝对,可以不存在); (3) 支持的message file类型: toml、json、yaml、properties.

@param defaultLanguage e.g. language.English || language.Chinese || language.SimplifiedChinese || language.TraditionalChinese

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL