language

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Language

type Language struct {
	// BCP47 language tag
	Tag language.Tag
	// Normalized string
	// of BCP47 tag.
	TagStr string
	// Human-readable
	// language name(s).
	DisplayStr string
}

Language models a BCP47 language tag along with helper strings for the tag.

func Parse

func Parse(lang string) (*Language, error)

Parse parses and nicely formats the input language BCP47 tag, returning a Language with ready-to-use display and tag strings.

func ParseTag

func ParseTag(tag language.Tag) *Language

ParseTag parses and nicely formats the input language BCP47 tag, returning a Language with ready-to-use display and tag strings.

func (*Language) MarshalText

func (l *Language) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler{}.

func (*Language) UnmarshalText

func (l *Language) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler{}.

type Languages

type Languages []*Language

func InitLangs

func InitLangs(tagStrs []string) (Languages, error)

InitLangs parses languages from the given slice of tags, and sets the `namer` display.Namer for the instance.

This function should only be called once, since setting the namer is not thread safe.

func (Languages) DisplayStrs

func (l Languages) DisplayStrs() []string

func (Languages) TagStrs

func (l Languages) TagStrs() []string

func (Languages) Tags

func (l Languages) Tags() []language.Tag

Jump to

Keyboard shortcuts

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