translation

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultTranslatorFunc

func SetDefaultTranslatorFunc(fn TranslateFunc)

SetDefaultTranslatorFunc sets the default translation function.

Types

type BaseTranslatableRule

type BaseTranslatableRule struct {
	Translate TranslateFunc
	Locale    string
}

BaseTranslatableRule is a semi-abstract struct that do the basic translation functionality.

func (*BaseTranslatableRule) AddLocale

func (b *BaseTranslatableRule) AddLocale(locale string)

AddLocale adds the default locale for translation.

func (*BaseTranslatableRule) AddTranslationFunction

func (b *BaseTranslatableRule) AddTranslationFunction(fn TranslateFunc)

AddTranslationFunction adds the translation function to the base.

type TranslatableRule

type TranslatableRule interface {
	AddLocale(locale string)
	AddTranslationFunction(fn TranslateFunc)
}

TranslatableRule is an interface for rules that translate the validation error messages.

type TranslateFunc

type TranslateFunc func(local, key string, params ...map[string]string) string

TranslateFunc is a function type that translate the given key in given locale.

func GetDefaultTranslatorFunc

func GetDefaultTranslatorFunc() TranslateFunc

GetDefaultTranslatorFunc returns the default translation function.

Jump to

Keyboard shortcuts

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