https://github.com/ttab/langos
Langos validates a language (ISO 639-1) region (ISO 3166-1 alpha-2) combinations in the format "language[-region]".
https://github.com/ttab/langos
Last synced: about 1 month ago
JSON representation
Langos validates a language (ISO 639-1) region (ISO 3166-1 alpha-2) combinations in the format "language[-region]".
- Host: GitHub
- URL: https://github.com/ttab/langos
- Owner: ttab
- License: mit
- Created: 2023-10-02T08:57:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-16T14:32:05.000Z (over 2 years ago)
- Last Synced: 2025-03-04T19:44:04.308Z (over 1 year ago)
- Language: Go
- Size: 177 KB
- Stars: 1
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Langos
[][godev]
[][actions]
Langos validates a language (ISO 639-1) region (ISO 3166-1 alpha-2) combinations in the format "language[-region]" and returns basic information about the language and region.
Example:
``` go
func ExampleGetLanguage() {
info, err := langos.GetLanguage("en-gb")
if err != nil {
panic(err)
}
knownCombo := langos.IsKnownCombination(info.Code)
fmt.Printf("code: %s\n", info.Code)
fmt.Printf("language: %s - %s\n", info.Language, info.LanguageName)
fmt.Printf("region: %s - %s\n", info.Region, info.RegionName)
fmt.Printf("is known combination: %v", knownCombo)
// Output:
// code: en-GB
// language: en - English
// region: GB - United Kingdom
// is known combination: true
}
```
## Data sources
Langos uses the languages and regions defined in the [IANA language subtag registry](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) together with the the [list of known language and region codes](http://www.sean-crist.com/professional/pages/language_region_codes/index.html) compiled by Sean Christ.
[godev]: https://pkg.go.dev/github.com/ttab/langos
[actions]: https://github.com/ttab/langos/actions