i18n

package
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package i18n wraps around github.com/nicksnyder/go-i18n mostly so that we don't have to deal with i18n.LocalizeConfig struct literals everywhere.

Index

Constants

View Source
const LanguageCookieName = "gossbroom-language"

Variables

View Source
var Defaults fs.FS

Defaults is an embedded filesystem containing translation defaults.

Functions

This section is empty.

Types

type Helper

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

func New

func New(r repo.Interface, config roomdb.RoomConfig) (*Helper, error)

func (Helper) ChooseTranslation

func (h Helper) ChooseTranslation(requestedTag string) string

func (Helper) FromRequest

func (h Helper) FromRequest(r *http.Request) *Localizer

FromRequest returns a new Localizer for the passed helper, using form value 'lang' and Accept-Language http header from the passed request. If a language cookie is detected, then it takes precedence over the form value & Accept-Lanuage header.

func (Helper) GetRenderFuncs

func (h Helper) GetRenderFuncs() []render.Option

func (Helper) ListLanguages

func (h Helper) ListLanguages() []TagTranslation

ListLanguages returns a slice of the room's translated languages. The entries of the slice are of the type TagTranslation, consisting of the fields Tag and Translation. Each Tag fields is a language tag (as strings), and the field Translation is the corresponding translated language name of that language tag. Example: {Tag: en, Translation: English}, {Tag: sv, Translation: Svenska} {Tag: de, Translation: Deutsch}

type Localizer

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

func (Localizer) LocalizePlurals

func (l Localizer) LocalizePlurals(messageID string, pluralCount int) template.HTML

func (Localizer) LocalizePluralsWithData

func (l Localizer) LocalizePluralsWithData(messageID string, pluralCount int, tplData map[string]string) template.HTML

func (Localizer) LocalizeSimple

func (l Localizer) LocalizeSimple(messageID string) template.HTML

func (Localizer) LocalizeWithData

func (l Localizer) LocalizeWithData(messageID string, labelsAndData ...string) template.HTML

type TagTranslation

type TagTranslation struct {
	Tag         string
	Translation string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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