language

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package language exposes the shared language-tag validation to frontends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base

func Base(value string) string

Base is Canonical without any script or region subtag: the ISO 639-1 primary ("pt" for every spelling of Portuguese). "" when unknown.

func Canonical

func Canonical(value string) string

Canonical folds any accepted spelling of a language — ISO 639-1 ("pt"), ISO 639-2 ("por"), BCP 47 with any region casing ("pt-BR", "pt_br", "PT-br"), a display name ("Portuguese", "Português") or a parser name ("portuguese-brazil") — to one canonical BCP 47 tag, preserving a known region where the tag carries one: "pt", "por", "Portuguese" and "Português" fold to "pt", while "pt-BR", "pt_br" and "Brazilian Portuguese" keep "pt-BR". The primary subtag is lower-cased and script/region are title-cased ("es-419", "fr-CA", "zh-Hant-TW"). An unknown value returns "".

func Valid

func Valid(value string) bool

Valid reports whether value is an accepted BCP 47 language tag.

Types

This section is empty.

Jump to

Keyboard shortcuts

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