i18nKit

package
v3.0.20 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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) error

LoadMessageFile

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

func LoadMessageFileBytes added in v3.0.20

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

LoadMessageFileBytes

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

func NewBundle

func NewBundle(defaultLanguage language.Tag, messageFilePaths ...string) (*i18n.Bundle, error)

NewBundle

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

@param defaultLanguage e.g. language.English || language.Chinese || language.SimplifiedChinese || language.TraditionalChinese @param messageFilePaths (1) 可以为nil

(2) 支持的文件类型: toml、json、yaml、properties

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳