i18n

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithAcceptLanguage

func ContextWithAcceptLanguage(ctx context.Context, accept string) context.Context

ContextWithAcceptLanguage store accept language into context.

func Get

func Get(ctx context.Context, id string, opts ...Option) (string, error)

Get localized message by languages.

func Languages

func Languages() []string

Languages returns all languages loaded.

func Load

func Load(fs fs.ReadDirFS) error

Load all message files in dir.

func MustGet

func MustGet(ctx context.Context, id string, options ...Option) string

MustGet get localized message by languages, ignore error. If an error occurs, returns the id.

Types

type Option

type Option func(o *options)

Option to get localized messages.

func WithCount

func WithCount(count any) Option

WithCount set plural count.

func WithData

func WithData(data any) Option

WithData set template data.

func WithDataMap

func WithDataMap(kvs ...string) Option

WithDataMap set template data.

func WithLanguages

func WithLanguages(languages ...string) Option

WithLanguages set plural count.

Jump to

Keyboard shortcuts

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