translation

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Binding = "goravel.translation"

Variables

View Source
var (
	ErrFileNotExist = errors.New("translation file does not exist")
)

Functions

This section is empty.

Types

type FileLoader

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

func NewFileLoader

func NewFileLoader(paths []string, json foundation.Json) *FileLoader

func (*FileLoader) Load

func (f *FileLoader) Load(locale string, group string) (map[string]any, error)

type MessageSelector

type MessageSelector struct{}

func NewMessageSelector

func NewMessageSelector() *MessageSelector

func (*MessageSelector) Choose

func (m *MessageSelector) Choose(message string, number int, locale string) string

Choose a translation string from an array according to a number.

type ServiceProvider

type ServiceProvider struct {
}

func (*ServiceProvider) Boot

func (translation *ServiceProvider) Boot(app foundation.Application)

func (*ServiceProvider) Register

func (translation *ServiceProvider) Register(app foundation.Application)

type Translator

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

func NewTranslator

func NewTranslator(ctx context.Context, loader translationcontract.Loader, locale string, fallback string, logger logcontract.Log) *Translator

func (*Translator) Choice

func (t *Translator) Choice(key string, number int, options ...translationcontract.Option) string

func (*Translator) CurrentLocale

func (t *Translator) CurrentLocale() string

func (*Translator) Get

func (t *Translator) Get(key string, options ...translationcontract.Option) string

func (*Translator) GetFallback

func (t *Translator) GetFallback() string

func (*Translator) Has

func (t *Translator) Has(key string, options ...translationcontract.Option) bool

func (*Translator) SetFallback

func (t *Translator) SetFallback(locale string) context.Context

func (*Translator) SetLocale

func (t *Translator) SetLocale(locale string) context.Context

Jump to

Keyboard shortcuts

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