Documentation ¶
Overview ¶
Package langreg is a library for validating ISO 639-1 language and ISO 1366-1_alpa-2 region codes.
ISO 639-1 language codes are two charcters long and use only lowercase ASCII character a-z. E.g.:
"en", "es", "ru"
ISO 1366-1_alpa-2 region codes are two charcters long and use only uppercase ASCII character A-Z. E.g.:
"US", "UK", "ZA"
When combined as a composite language and region code, they are concatented with an underscore. E.g.:
"en_US", "en_ZA", "fr_FR"
Any codes not meeting these formatting requirement will fail validation.
Index ¶
- func IsValidLangRegCode(s string) bool
- func IsValidLanguageCode(s string) bool
- func IsValidRegionCode(s string) bool
- func LangCodeInfo(s string) (english, native string, err error)
- func LangEnglishName(s string) (string, error)
- func LangNativeName(s string) (string, error)
- func RegionCodeInfo(s string) (region string, err error)
- func RegionName(s string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidLangRegCode ¶
IsValidLangRegCode returns true if the string s is a valid ISO 639-1 language and ISO1366-1_alpa-2 region code separated by an underscore. E.g. "en_US".
func IsValidLanguageCode ¶
IsValidLanguageCode returns true if s is a valid ISO 639-1 language code
func IsValidRegionCode ¶
IsValidRegionCode returns true if s is a valid ISO1366-1_alpa-2 region code.
func LangCodeInfo ¶
LangCodeInfo returns the English and native language in its script for a given string, and an error if any. If there are more than one official names for the language (either English or native), they are separated by a semi-colon (;) Language codes should always be lowercase, and this is enforced.
func LangEnglishName ¶
LangEnglishName returns the English name(s) corresponding to the language code s. If there are multiple names, they are separated by a `;`.
func LangNativeName ¶
LangNativeName returns the native name(s) corresponding to the language code s in the native script(s). If there are multiple names, they are separated by a `;`.
func RegionCodeInfo ¶
RegionCodeInfo returns the English regional name that corresponds to the ISO 3166-1 alpha-2 region codes. Region codes should always be uppercase, and this is enforced. E.g. "US" is valid, but "us" is not.
func RegionName ¶
RegionName returns the English name of the ISO1366-1_alpa-2 region code s.
Types ¶
This section is empty.