localize

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 8 Imported by: 55

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Files    embed.FS
	Language *language.Tag
	Path     string
	Format   string
}

Config is a type which helps to get the information to initialize the localizer

type GoI18n

type GoI18n struct {
	Localizer *i18n.Localizer
	// contains filtered or unexported fields
}

GoI18n is a type which stores the details to create bundle

func (*GoI18n) LocalizeByID

func (i *GoI18n) LocalizeByID(messageId string, template ...*TemplateEntry) string

LocalizeByID helps in localizing by passing id present in local file pass dynamic value using template entries

func (*GoI18n) MustLocalizeFile

func (i *GoI18n) MustLocalizeFile(files fs.FS, path string) (err error)

read the message file from the file system

type Localizer

type Localizer interface {
	// LocalizeById takes ID
	LocalizeByID(messageId string, template ...*TemplateEntry) string
}

Localizer is an Interface for localizing messages from locals

func New

func New(cfg *Config) (Localizer, error)

type TemplateEntry

type TemplateEntry struct {
	Key   string
	Value interface{}
}

TemplateEntry is a type which defines variable interpolation key:value pairs which are used to pass dynamic values to the template

func NewEntry

func NewEntry(key string, val interface{}) *TemplateEntry

NewEntry returns a new template entry which is a type for interpolating a string

Jump to

Keyboard shortcuts

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