i18n

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package i18n 提供了一个简单的国际化(i18n)支持库

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTranslation

func AddTranslation(key, translation string) error

AddTranslation 为当前语言添加或更新翻译,并保存到文件

func FormatTranslation

func FormatTranslation(key string, args ...interface{}) string

FormatTranslation 格式化带参数的翻译

func GetCurrentLang

func GetCurrentLang() string

GetCurrentLang 返回当前语言

func InitGlobal

func InitGlobal(lang string, customDir ...string) error

InitGlobal 初始化全局 i18n 实例 lang: 初始语言 customDir: 可选的自定义翻译文件目录

func LoadTranslationsFromBytes

func LoadTranslationsFromBytes(lang string, data []byte) error

LoadTranslationsFromBytes 从字节数组加载翻译

func SetLang

func SetLang(lang string) error

SetLang 更改当前语言

func T

func T(key string) string

T 翻译给定的键

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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