lang

package
v0.0.0-...-fc1a460 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTranslator

func GetTranslator(localeOpt LocaleOption) ut.Translator

get translators

func InitializeTranslator

func InitializeTranslator() error

func Is

func Is(source LocaleOption, target LocaleType) bool

func Register

func Register() fiber.Handler

default locale

func T

func T(localeOpt LocaleOption, key string, opts ...TranslateOption) string

translate key with params

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

type LocaleOption

type LocaleOption func(*Config)

func Ctx

func Ctx(ctx context.Context) LocaleOption

get locale from context

func FiberCtx

func FiberCtx(ctx *fiber.Ctx) LocaleOption

get locale from FiberCtx

func Locale

func Locale(locale LocaleType) LocaleOption

type LocaleType

type LocaleType string
const (
	LocaleEN LocaleType = "en"
	LocaleZH LocaleType = "zh"
)

type TOption

type TOption func(*Config)

type TranslateOption

type TranslateOption func(*Config)

func FallbackFunc

func FallbackFunc(fn func(key string) string) TranslateOption

default use key

func Params

func Params(params ...string) TranslateOption

Jump to

Keyboard shortcuts

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