OSDN Git Service

new repo
[bytom/vapor.git] / vendor / github.com / johngb / langreg / language.go
1 //go:generate go run datagen/language/genlang.go
2
3 package langreg
4
5 // IsValidLanguageCode returns true if s is a valid ISO 639-1 language code
6 func IsValidLanguageCode(s string) bool {
7         _, _, err := LangCodeInfo(s)
8         if err != nil {
9                 return false
10         }
11         return true
12 }
13
14 // LangEnglishName returns the English name(s) corresponding to the language code
15 // s.  If there are multiple names, they are separated by a `;`.
16 func LangEnglishName(s string) (string, error) {
17         en, _, err := LangCodeInfo(s)
18         return en, err
19 }
20
21 // LangNativeName returns the native name(s) corresponding to the language code s
22 // in the native script(s).  If there are multiple names, they are separated
23 // by a `;`.
24 func LangNativeName(s string) (string, error) {
25         _, nat, err := LangCodeInfo(s)
26         return nat, err
27 }