lang

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const LanguageDefault context.RequestKey = "language-default"
View Source
const LanguagePrinter context.RequestKey = "language-printer"
View Source
const LanguageTag context.RequestKey = "language-tag"

Variables

View Source
var MessagesGoTextName = "messages.gotext.json"
View Source
var OutputGoTextName = "out.gotext.json"

Functions

func BleveSupportedAnalyzer

func BleveSupportedAnalyzer(tag language.Tag) (ok bool)

func GetPrinterFromRequest

func GetPrinterFromRequest(r *http.Request) (printer *message.Printer)

func GetTag

func GetTag(r *http.Request) (tag language.Tag)

func NewCatalogPrinter

func NewCatalogPrinter(lang string, c catalog.Catalog) (tag language.Tag, printer *message.Printer)

func NonPageRequested

func NonPageRequested(r *http.Request) (is bool)

func ParseLangPath

func ParseLangPath(p string) (tag language.Tag, modified string, ok bool)

func SortLanguageTags

func SortLanguageTags(tags []language.Tag) (sorted []language.Tag)

func SortedLanguageTagKeys

func SortedLanguageTagKeys[V interface{}](m map[language.Tag]V) (sorted []language.Tag)

func StripTranslatorComments

func StripTranslatorComments(raw string) (clean string)

func TagInTagSlices

func TagInTagSlices(needle language.Tag, haystacks ...[]language.Tag) (found bool)

func TagInTags

func TagInTags(needle language.Tag, haystack ...language.Tag) (found bool)

Types

type Catalog

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

func NewCatalog

func NewCatalog() (c *Catalog)

func (*Catalog) AddLocalesFromFS

func (c *Catalog) AddLocalesFromFS(defaultTag language.Tag, efs fs.FileSystem)

func (*Catalog) AddLocalesFromJsonBytes

func (c *Catalog) AddLocalesFromJsonBytes(tag language.Tag, src string, contents []byte)

func (*Catalog) LocaleTags

func (c *Catalog) LocaleTags() (tags []language.Tag)

func (*Catalog) LocaleTagsWithDefault

func (c *Catalog) LocaleTagsWithDefault(d language.Tag) (tags []language.Tag)

func (*Catalog) MakeGoTextCatalog

func (c *Catalog) MakeGoTextCatalog() (gtc catalog.Catalog, err error)

type Dictionaries

type Dictionaries interface {
	catalog.Dictionary

	Append(d *dictionary)
}

type DomainMode

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

func (*DomainMode) FromRequest

func (p *DomainMode) FromRequest(defaultTag language.Tag, r *http.Request) (tag language.Tag, path string, ok bool)

func (*DomainMode) Make

func (p *DomainMode) Make() Mode

func (*DomainMode) Set

func (p *DomainMode) Set(tag language.Tag, domain string) DomainModeBuilder

func (*DomainMode) ToUrl

func (p *DomainMode) ToUrl(defaultTag, tag language.Tag, path string) (translated string)

type DomainModeBuilder

type DomainModeBuilder interface {
	Set(tag language.Tag, domain string) DomainModeBuilder

	Make() Mode
}

func NewDomainMode

func NewDomainMode() (p DomainModeBuilder)

type Mode

type Mode interface {
	ToUrl(defaultTag, tag language.Tag, path string) (translated string)
	FromRequest(defaultTag language.Tag, r *http.Request) (tag language.Tag, path string, ok bool)
}

type PathMode

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

func (*PathMode) FromRequest

func (p *PathMode) FromRequest(defaultTag language.Tag, r *http.Request) (tag language.Tag, path string, ok bool)

func (*PathMode) Make

func (p *PathMode) Make() Mode

func (*PathMode) ParsePathLang

func (p *PathMode) ParsePathLang(path string) (tag language.Tag, trimmed string, ok bool)

func (*PathMode) SetDomain

func (p *PathMode) SetDomain(domain string) PathModeBuilder

func (*PathMode) ToUrl

func (p *PathMode) ToUrl(defaultTag, tag language.Tag, path string) (translated string)

type PathModeBuilder

type PathModeBuilder interface {
	SetDomain(domain string) PathModeBuilder

	Make() Mode
}

func NewPathMode

func NewPathMode() (p PathModeBuilder)

type QueryMode

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

func (*QueryMode) FromRequest

func (q *QueryMode) FromRequest(defaultTag language.Tag, r *http.Request) (tag language.Tag, path string, ok bool)

func (*QueryMode) Make

func (q *QueryMode) Make() Mode

func (*QueryMode) SetDomain

func (q *QueryMode) SetDomain(domain string) QueryModeBuilder

func (*QueryMode) SetQueryParameter

func (q *QueryMode) SetQueryParameter(name string) QueryModeBuilder

func (*QueryMode) ToUrl

func (q *QueryMode) ToUrl(defaultTag, tag language.Tag, path string) (translated string)

type QueryModeBuilder

type QueryModeBuilder interface {
	SetDomain(domain string) QueryModeBuilder
	SetQueryParameter(name string) QueryModeBuilder

	Make() Mode
}

func NewQueryMode

func NewQueryMode() (q QueryModeBuilder)

Jump to

Keyboard shortcuts

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