langs

package
v0.0.0-...-a1933d6 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lang

type Lang struct {
	Name     string        `json:"name"`
	Code     string        `json:"code"`
	Variants []LangVariant `json:"variants"`
}

Lang contatins the name of a language, as well as its "top level" ISO code, and a list of possible `LangVariants` that the language can have.

func GetLangs

func GetLangs() []Lang

GetLangs returns a hardcoded list of existing languages

type LangCodes

type LangCodes struct {
	Code        string `json:"code"`
	VariantCode string `json:"variantCode"`
}

LangCodes contains the "top lever" and "sub

func GetLangCodes

func GetLangCodes(lang string) *LangCodes

GetLangCodes return a LangCodes from the ISO language code. If the string has bad format, or the ISO code is not valid, will return a nil pointer.

func (*LangCodes) Lang

func (lc *LangCodes) Lang() string

Lang returns the string representation of a LangCodes

type LangCodesAndNames

type LangCodesAndNames struct {
	Code        string `json:"code"`
	VariantCode string `json:"variantCode"`
	Name        string `json:"name"`
	VariantName string `json:"variantName"`
}

LangCodesAndNames contains all the data for a language (including its variation) flattened in a single struct

func GetLangCodesAndNames

func GetLangCodesAndNames(lang string) *LangCodesAndNames

GetLangCodesAndNames returns a LangCodesAndNames for a given lang ISO code string. If the string format is incorrect, or it does not represent a valid ISO code it will return nil.

func (*LangCodesAndNames) Lang

func (lcan *LangCodesAndNames) Lang() string

Lang returns the ISO string code for the language (and its variation, if that exists in the structure).

type LangVariant

type LangVariant struct {
	Name string `json:"name"`
	Code string `json:"code"`
}

LangVariant contains the variant name, and variant code of a language variant.

Jump to

Keyboard shortcuts

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