translatehelper

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Translator

type Translator struct {
	DefaultLang string // must be one of TranslatorBundle's key
	Localizers  map[string]*i18n.Localizer
}

func NewTranslator

func NewTranslator(defaultLang string, translatorBundles []TranslatorBundle) (translator Translator, err error)

func (*Translator) TranslateMessage

func (t *Translator) TranslateMessage(messageID, language string) (translatedMsg string)

func (*Translator) TranslateMessageWithVars

func (t *Translator) TranslateMessageWithVars(messageID string, vars map[string]string, language string) (translatedMsg string)

type TranslatorBundle

type TranslatorBundle struct {
	Key           string // e.x: en, zh...
	FilePath      string // file path include file name
	LangTag       language.Tag
	Format        string             // e.x: json
	UnmarshalFunc i18n.UnmarshalFunc // e.x: json.Unmarshal
}

Jump to

Keyboard shortcuts

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