iso639/iso_639.go

26 lines
594 B
Go
Raw Normal View History

2023-10-01 08:51:38 +02:00
package iso639
import (
"fmt"
)
// GetLanguageNameForISO639Code tries get the language name for an ISO 639-1, ISO 639-2/B or ISO 639-2/T code
func GetLanguageNameForISO639Code(s string) (string, error) {
languageName, err := GetLanguageNameForISO639_1Code(s)
if err == nil {
return languageName, nil
}
languageName, err = GetLanguageNameForISO639_2BCode(s)
if err == nil {
return languageName, nil
}
languageName, err = GetLanguageNameForISO639_2TCode(s)
if err == nil {
return languageName, nil
}
return "", fmt.Errorf("no language name found for ISO 639 code: %s", s)
}