l18n

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package l18n handles everything language-related for Mycorrhiza.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Localizer

type Localizer struct {
	Locale         string
	FallbackLocale string
	Localizations  map[string]string
}

func FromRequest

func FromRequest(r *http.Request) *Localizer

FromRequest takes a HTTP request and picks the most appropriate localizer with English as the fallback language.

func New

func New(locale string, fallbackLocale string) *Localizer

New creates a new Localizer with locales set. This operation is cheap.

func (Localizer) Get

func (t Localizer) Get(key string, replacements ...*Replacements) string

Get returns a localized string for the provided key with optional replacements executed on the string.

func (Localizer) GetPlural

func (t Localizer) GetPlural(key string, n int, replacements ...*Replacements) string

GetPlural returns a localized string respecting locale-specific plural rules. Technically, it replaces %s token with +form subkey and proceeds as usual.

func (Localizer) GetPlural64

func (t Localizer) GetPlural64(key string, n int64, replacements ...*Replacements) string

GetPlural64 is ditto for int64

func (Localizer) GetWithLocale

func (t Localizer) GetWithLocale(locale, key string, replacements ...*Replacements) string

GetWithLocale returns a localized string for the provided key in a specific locale with optional replacements executed on the string.

type Replacements

type Replacements map[string]interface{}

Jump to

Keyboard shortcuts

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