i18n

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeMessages

func DeMessages() map[string]string

DeMessages 返回德语翻译模板映射

func EnMessages

func EnMessages() map[string]string

EnMessages 返回英文翻译模板映射

func EsMessages

func EsMessages() map[string]string

EsMessages 返回西班牙语翻译模板映射

func FrMessages

func FrMessages() map[string]string

FrMessages 返回法语翻译模板映射

func GetLocale

func GetLocale() string

GetLocale 返回当前全局语言环境

func JaMessages

func JaMessages() map[string]string

JaMessages 返回日语翻译模板映射

func KoMessages

func KoMessages() map[string]string

KoMessages 返回韩语翻译模板映射

func Lookup

func Lookup(l, key string) string

Lookup 按 locale → en 顺序查找消息模板

公开入口,locale 来自外部输入故仍需 Normalize;内部热路径走 lookupIn

func Msg

func Msg(key string, args ...map[string]string) string

Msg 根据 key 查找当前语言环境的消息模板,并用 args 替换占位符

单次快照加载即取得 locale 与消息库:原实现 GetLocale + Lookup 各取一次 RLock, 且 Lookup 会对已规范化的 locale 再跑一次 Normalize(内含 ToLower/ReplaceAll 分配)

func Normalize

func Normalize(l string) string

Normalize 规范化语言标签

func Register

func Register(l, key, template string)

Register 注册或覆盖某个语言下的单个翻译模板

func RegisterMessages

func RegisterMessages(l string, messages map[string]string)

RegisterMessages 批量注册某个语言下的翻译模板

func RuMessages

func RuMessages() map[string]string

RuMessages 返回俄语翻译模板映射

func SetLocale

func SetLocale(l string)

SetLocale 设置全局语言环境

func ZhMessages

func ZhMessages() map[string]string

ZhMessages 返回中文(简体)翻译模板映射

func ZhTWMessages

func ZhTWMessages() map[string]string

ZhTWMessages 返回繁体中文翻译模板映射

Types

This section is empty.

Jump to

Keyboard shortcuts

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