translator

package
v0.0.0-...-4be01c1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func I18n

func I18n(s string) string

Allows extractions of language keys

func Stringfy

func Stringfy(s TranslatableStringer) string

func TransformTranslation

func TransformTranslation(s string) string

Given a string supported by gettext, transform it into something consumable by go-text NOTE: right now what we are looking for it just to prevent go-text of interpreting % by duplicating it, meaning "literal percent". TODO: this function will need to be smarter in order to support positional arguments and pluralization. Please see gitlab issue #245 for more info.

func Translate

func Translate(t Translator, c TranslatableStringer) (string, error)

Types

type DummyTranslator

type DummyTranslator struct{}

func (DummyTranslator) PrettyFormatTime

func (DummyTranslator) PrettyFormatTime(time time.Time) string

func (DummyTranslator) Translate

func (DummyTranslator) Translate(f string, args ...interface{}) (string, error)

type TranslatableStringer

type TranslatableStringer interface {
	TplString() string
	Args() []interface{}
}

type Translator

type Translator interface {
	Translate(string, ...interface{}) (string, error)
	PrettyFormatTime(time.Time) string
}

type Translators

type Translators interface {
	Translator(language.Tag) Translator
	Matcher() language.Matcher
}

func New

func New(catalog catalog.Catalog) Translators

Jump to

Keyboard shortcuts

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