language

package
v0.0.0-...-72cce92 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 5 Imported by: 2

Documentation

Overview

Package language provides comprehensive language code handling and validation based on ISO 639-1 standards for Go applications.

The package includes: - ISO 639-1 two-character language code validation and normalization - Language name mapping and retrieval - Database integration (Scanner/Valuer interfaces) - JSON marshalling/unmarshalling - Support for common language codes and names

GENERATED

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code string

Code represents a language code in its normalized form as an ISO 639-1 two-character language code. Code implements the database/sql.Scanner and database/sql/driver.Valuer interfaces, and treats an empty Code string as SQL NULL value.

const (
	// Null is an empty string and will be treatet as SQL NULL.
	// language.Null.Valid() == false
	Null Code = ""

	AA Code = "aa"
	AB Code = "ab"
	AF Code = "af"
	AK Code = "ak"
	SQ Code = "sq"
	AM Code = "am"
	AR Code = "ar"
	AN Code = "an"
	HY Code = "hy"
	AS Code = "as"
	AV Code = "av"
	AE Code = "ae"
	AY Code = "ay"
	AZ Code = "az"
	BA Code = "ba"
	BM Code = "bm"
	EU Code = "eu"
	BE Code = "be"
	BN Code = "bn"
	BH Code = "bh"
	BI Code = "bi"
	BS Code = "bs"
	BR Code = "br"
	BG Code = "bg"
	MY Code = "my"
	CA Code = "ca"
	CH Code = "ch"
	CE Code = "ce"
	ZH Code = "zh"
	CU Code = "cu"
	CV Code = "cv"
	KW Code = "kw"
	CO Code = "co"
	CR Code = "cr"
	CS Code = "cs"
	DA Code = "da"
	DV Code = "dv"
	NL Code = "nl"
	DZ Code = "dz"
	EN Code = "en"
	EO Code = "eo"
	ET Code = "et"
	EE Code = "ee"
	FO Code = "fo"
	FJ Code = "fj"
	FI Code = "fi"
	FR Code = "fr"
	FY Code = "fy"
	FF Code = "ff"
	KA Code = "ka"
	DE Code = "de"
	GD Code = "gd"
	GA Code = "ga"
	GL Code = "gl"
	GV Code = "gv"
	EL Code = "el"
	GN Code = "gn"
	GU Code = "gu"
	HT Code = "ht"
	HA Code = "ha"
	HE Code = "he"
	HZ Code = "hz"
	HI Code = "hi"
	HO Code = "ho"
	HR Code = "hr"
	HU Code = "hu"
	IG Code = "ig"
	IS Code = "is"
	IO Code = "io"
	II Code = "ii"
	IU Code = "iu"
	IE Code = "ie"
	IA Code = "ia"
	ID Code = "id"
	IK Code = "ik"
	IT Code = "it"
	JV Code = "jv"
	JA Code = "ja"
	KL Code = "kl"
	KN Code = "kn"
	KS Code = "ks"
	KR Code = "kr"
	KK Code = "kk"
	KM Code = "km"
	KI Code = "ki"
	RW Code = "rw"
	KY Code = "ky"
	KV Code = "kv"
	KG Code = "kg"
	KO Code = "ko"
	KJ Code = "kj"
	KU Code = "ku"
	LO Code = "lo"
	LA Code = "la"
	LV Code = "lv"
	LI Code = "li"
	LN Code = "ln"
	LT Code = "lt"
	LB Code = "lb"
	LU Code = "lu"
	LG Code = "lg"
	MK Code = "mk"
	MH Code = "mh"
	ML Code = "ml"
	MI Code = "mi"
	MR Code = "mr"
	MS Code = "ms"
	MG Code = "mg"
	MT Code = "mt"
	MN Code = "mn"
	NA Code = "na"
	NV Code = "nv"
	NR Code = "nr"
	ND Code = "nd"
	NG Code = "ng"
	NE Code = "ne"
	NN Code = "nn"
	NB Code = "nb"
	NO Code = "no"
	NY Code = "ny"
	OC Code = "oc"
	OJ Code = "oj"
	OR Code = "or"
	OM Code = "om"
	OS Code = "os"
	PA Code = "pa"
	FA Code = "fa"
	PI Code = "pi"
	PL Code = "pl"
	PT Code = "pt"
	PS Code = "ps"
	QU Code = "qu"
	RM Code = "rm"
	RO Code = "ro"
	RN Code = "rn"
	RU Code = "ru"
	SG Code = "sg"
	SA Code = "sa"
	SI Code = "si"
	SK Code = "sk"
	SL Code = "sl"
	SE Code = "se"
	SM Code = "sm"
	SN Code = "sn"
	SD Code = "sd"
	SO Code = "so"
	ST Code = "st"
	ES Code = "es"
	SC Code = "sc"
	SR Code = "sr"
	SS Code = "ss"
	SU Code = "su"
	SW Code = "sw"
	SV Code = "sv"
	TY Code = "ty"
	TA Code = "ta"
	TT Code = "tt"
	TE Code = "te"
	TG Code = "tg"
	TL Code = "tl"
	TH Code = "th"
	BO Code = "bo"
	TI Code = "ti"
	TO Code = "to"
	TN Code = "tn"
	TS Code = "ts"
	TK Code = "tk"
	TR Code = "tr"
	TW Code = "tw"
	UG Code = "ug"
	UK Code = "uk"
	UR Code = "ur"
	UZ Code = "uz"
	VE Code = "ve"
	VI Code = "vi"
	VO Code = "vo"
	CY Code = "cy"
	WA Code = "wa"
	WO Code = "wo"
	XH Code = "xh"
	YI Code = "yi"
	YO Code = "yo"
	ZA Code = "za"
	ZU Code = "zu"
)

func (Code) JSONSchema

func (Code) JSONSchema() *jsonschema.Schema

JSONSchema returns the JSON schema definition for the Code type.

func (Code) LanguageName

func (c Code) LanguageName() string

LanguageName returns the English name of the language for the code.

func (Code) Normalized

func (c Code) Normalized() (Code, error)

Normalized returns the normalized language code or an error if invalid. TODO: normalize 3 letter codes https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes TODO: normalize BCP-47 language codes, such as "en-US" or "sr-Latn" http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.

func (*Code) Scan

func (c *Code) Scan(value any) error

Scan implements the database/sql.Scanner interface.

func (Code) String

func (c Code) String() string

String returns the normalized code if possible, else it will be returned unchanged as string. String implements the fmt.Stringer interface.

func (Code) Valid

func (c Code) Valid() bool

Valid returns true if the Code is a valid ISO 639-1 language code.

func (Code) ValidAndNormalized

func (c Code) ValidAndNormalized() bool

ValidAndNormalized returns true if the Code is valid and already normalized.

func (Code) Value

func (c Code) Value() (driver.Value, error)

Value implements the driver database/sql/driver.Valuer interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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