iso639/iso_639-1.go

408 lines
9.3 KiB
Go
Raw Normal View History

2023-10-01 08:51:38 +02:00
package iso639
import (
"fmt"
)
var iso639_1CodeToName = map[string]string{
"aa": "Afar",
"ab": "Abkhazian",
"ae": "Avestan",
"af": "Afrikaans",
"ak": "Akan",
"am": "Amharic",
"an": "Aragonese",
"ar": "Arabic",
"as": "Assamese",
"av": "Avaric",
"ay": "Aymara",
"az": "Azerbaijani",
"ba": "Bashkir",
"be": "Belarusian",
"bg": "Bulgarian",
"bi": "Bislama",
"bm": "Bambara",
"bn": "Bengali",
"bo": "Tibetan",
"br": "Breton",
"bs": "Bosnian",
"ca": "Catalan",
"ce": "Chechen",
"ch": "Chamorro",
"co": "Corsican",
"cr": "Cree",
"cs": "Czech",
"cu": "Church Slavonic",
"cv": "Chuvash",
"cy": "Welsh",
"da": "Danish",
"de": "German",
"dv": "Divehi",
"dz": "Dzongkha",
"ee": "Ewe",
"el": "Greek",
"en": "English",
"eo": "Esperanto",
"es": "Spanish",
"et": "Estonian",
"eu": "Basque",
"fa": "Persian",
"ff": "Fulah",
"fi": "Finnish",
"fj": "Fijian",
"fo": "Faroese",
"fr": "French",
"fy": "Western Frisian",
"ga": "Irish",
"gd": "Gaelic",
"gl": "Galician",
"gn": "Guarani",
"gu": "Gujarati",
"gv": "Manx",
"ha": "Hausa",
"he": "Hebrew",
"hi": "Hindi",
"ho": "Hiri Motu",
"hr": "Croatian",
"ht": "Haitian",
"hu": "Hungarian",
"hy": "Armenian",
"hz": "Herero",
"ia": "Interlingua",
"id": "Indonesian",
"ie": "Interlingue",
"ig": "Igbo",
"ii": "Sichuan Yi",
"ik": "Inupiaq",
"io": "Ido",
"is": "Icelandic",
"it": "Italian",
"iu": "Inuktitut",
"ja": "Japanese",
"jv": "Javanese",
"ka": "Georgian",
"kg": "Kongo",
"ki": "Kikuyu",
"kj": "Kuanyama",
"kk": "Kazakh",
"kl": "Kalaallisut",
"km": "Central Khmer",
"kn": "Kannada",
"ko": "Korean",
"kr": "Kanuri",
"ks": "Kashmiri",
"ku": "Kurdish",
"kv": "Komi",
"kw": "Cornish",
"ky": "Kirghiz",
"la": "Latin",
"lb": "Luxembourgish",
"lg": "Ganda",
"li": "Limburgan",
"ln": "Lingala",
"lo": "Lao",
"lt": "Lithuanian",
"lu": "Luba-Katanga",
"lv": "Latvian",
"mg": "Malagasy",
"mh": "Marshallese",
"mi": "Maori",
"mk": "Macedonian",
"ml": "Malayalam",
"mn": "Mongolian",
"mr": "Marathi",
"ms": "Malay",
"mt": "Maltese",
"my": "Burmese",
"na": "Nauru",
"nb": "Norwegian Bokmål",
"nd": "North Ndebele",
"ne": "Nepali",
"ng": "Ndonga",
"nl": "Dutch",
"nn": "Norwegian Nynorsk",
"no": "Norwegian",
"nr": "South Ndebele",
"nv": "Navajo",
"ny": "Chichewa",
"oc": "Occitan",
"oj": "Ojibwa",
"om": "Oromo",
"or": "Oriya",
"os": "Ossetian",
"pa": "Punjabi",
"pi": "Pali",
"pl": "Polish",
"ps": "Pashto",
"pt": "Portuguese",
"qu": "Quechua",
"rm": "Romansh",
"rn": "Rundi",
"ro": "Romanian",
"ru": "Russian",
"rw": "Kinyarwanda",
"sa": "Sanskrit",
"sc": "Sardinian",
"sd": "Sindhi",
"se": "Northern Sami",
"sg": "Sango",
"si": "Sinhala",
"sk": "Slovak",
"sl": "Slovenian",
"sm": "Samoan",
"sn": "Shona",
"so": "Somali",
"sq": "Albanian",
"sr": "Serbian",
"ss": "Swati",
"st": "Southern Sotho",
"su": "Sundanese",
"sv": "Swedish",
"sw": "Swahili",
"ta": "Tamil",
"te": "Telugu",
"tg": "Tajik",
"th": "Thai",
"ti": "Tigrinya",
"tk": "Turkmen",
"tl": "Tagalog",
"tn": "Tswana",
"to": "Tonga",
"tr": "Turkish",
"ts": "Tsonga",
"tt": "Tatar",
"tw": "Twi",
"ty": "Tahitian",
"ug": "Uighur",
"uk": "Ukrainian",
"ur": "Urdu",
"uz": "Uzbek",
"ve": "Venda",
"vi": "Vietnamese",
"vo": "Volapück",
"wa": "Walloon",
"wo": "Wolof",
"xh": "Xhosa",
"yi": "Yiddish",
"yo": "Yoruba",
"za": "Zhuang",
"zh": "Chinese",
"zu": "Zulu",
}
var iso639_1NameToCode = map[string]string{
"Abkhazian": "ab",
"Afar": "aa",
"Afrikaans": "af",
"Akan": "ak",
"Albanian": "sq",
"Amharic": "am",
"Arabic": "ar",
"Aragonese": "an",
"Armenian": "hy",
"Assamese": "as",
"Avaric": "av",
"Avestan": "ae",
"Aymara": "ay",
"Azerbaijani": "az",
"Bambara": "bm",
"Bashkir": "ba",
"Basque": "eu",
"Belarusian": "be",
"Bengali": "bn",
"Bislama": "bi",
"Bosnian": "bs",
"Breton": "br",
"Bulgarian": "bg",
"Burmese": "my",
"Catalan": "ca",
"Central Khmer": "km",
"Chamorro": "ch",
"Chechen": "ce",
"Chichewa": "ny",
"Chinese": "zh",
"Church Slavonic": "cu",
"Chuvash": "cv",
"Cornish": "kw",
"Corsican": "co",
"Cree": "cr",
"Croatian": "hr",
"Czech": "cs",
"Danish": "da",
"Divehi": "dv",
"Dutch": "nl",
"Dzongkha": "dz",
"English": "en",
"Esperanto": "eo",
"Estonian": "et",
"Ewe": "ee",
"Faroese": "fo",
"Fijian": "fj",
"Finnish": "fi",
"French": "fr",
"Fulah": "ff",
"Gaelic": "gd",
"Galician": "gl",
"Ganda": "lg",
"Georgian": "ka",
"German": "de",
"Greek": "el",
"Guarani": "gn",
"Gujarati": "gu",
"Haitian": "ht",
"Hausa": "ha",
"Hebrew": "he",
"Herero": "hz",
"Hindi": "hi",
"Hiri Motu": "ho",
"Hungarian": "hu",
"Icelandic": "is",
"Ido": "io",
"Igbo": "ig",
"Indonesian": "id",
"Interlingua": "ia",
"Interlingue": "ie",
"Inuktitut": "iu",
"Inupiaq": "ik",
"Irish": "ga",
"Italian": "it",
"Japanese": "ja",
"Javanese": "jv",
"Kalaallisut": "kl",
"Kannada": "kn",
"Kanuri": "kr",
"Kashmiri": "ks",
"Kazakh": "kk",
"Kikuyu": "ki",
"Kinyarwanda": "rw",
"Kirghiz": "ky",
"Komi": "kv",
"Kongo": "kg",
"Korean": "ko",
"Kuanyama": "kj",
"Kurdish": "ku",
"Lao": "lo",
"Latin": "la",
"Latvian": "lv",
"Limburgan": "li",
"Lingala": "ln",
"Lithuanian": "lt",
"Luba-Katanga": "lu",
"Luxembourgish": "lb",
"Macedonian": "mk",
"Malagasy": "mg",
"Malay": "ms",
"Malayalam": "ml",
"Maltese": "mt",
"Manx": "gv",
"Maori": "mi",
"Marathi": "mr",
"Marshallese": "mh",
"Mongolian": "mn",
"Nauru": "na",
"Navajo": "nv",
"Ndonga": "ng",
"Nepali": "ne",
"North Ndebele": "nd",
"Northern Sami": "se",
"Norwegian Bokmål": "nb",
"Norwegian Nynorsk": "nn",
"Norwegian": "no",
"Occitan": "oc",
"Ojibwa": "oj",
"Oriya": "or",
"Oromo": "om",
"Ossetian": "os",
"Pali": "pi",
"Pashto": "ps",
"Persian": "fa",
"Polish": "pl",
"Portuguese": "pt",
"Punjabi": "pa",
"Quechua": "qu",
"Romanian": "ro",
"Romansh": "rm",
"Rundi": "rn",
"Russian": "ru",
"Samoan": "sm",
"Sango": "sg",
"Sanskrit": "sa",
"Sardinian": "sc",
"Serbian": "sr",
"Shona": "sn",
"Sichuan Yi": "ii",
"Sindhi": "sd",
"Sinhala": "si",
"Slovak": "sk",
"Slovenian": "sl",
"Somali": "so",
"South Ndebele": "nr",
"Southern Sotho": "st",
"Spanish": "es",
"Sundanese": "su",
"Swahili": "sw",
"Swati": "ss",
"Swedish": "sv",
"Tagalog": "tl",
"Tahitian": "ty",
"Tajik": "tg",
"Tamil": "ta",
"Tatar": "tt",
"Telugu": "te",
"Thai": "th",
"Tibetan": "bo",
"Tigrinya": "ti",
"Tonga": "to",
"Tsonga": "ts",
"Tswana": "tn",
"Turkish": "tr",
"Turkmen": "tk",
"Twi": "tw",
"Uighur": "ug",
"Ukrainian": "uk",
"Urdu": "ur",
"Uzbek": "uz",
"Venda": "ve",
"Vietnamese": "vi",
"Volapück": "vo",
"Walloon": "wa",
"Welsh": "cy",
"Western Frisian": "fy",
"Wolof": "wo",
"Xhosa": "xh",
"Yiddish": "yi",
"Yoruba": "yo",
"Zhuang": "za",
"Zulu": "zu",
}
// GetAllISO639_1Codes returns all ISO 639-1 codes
func GetAllISO639_1Codes() []string {
return getAllKeysOfMap(iso639_1CodeToName)
}
// GetAllISO639_1Names returns all ISO 639-1 language names
func GetAllISO639_1Names() []string {
return getAllKeysOfMap(iso639_1NameToCode)
}
// GetISO639_1CodeForLanguageName tries to match a language name to an ISO 639-1 code
func GetISO639_1CodeForLanguageName(s string) (string, error) {
code, languageNameExists := iso639_1NameToCode[s]
if !languageNameExists {
return "", fmt.Errorf("no ISO 639-1 code found for language name: %s", s)
}
return code, nil
}
// GetLanguageNameForISO639_1Code tries to match an ISO 639-1 code to a language name
func GetLanguageNameForISO639_1Code(s string) (string, error) {
languageName, codeExists := iso639_1CodeToName[s]
if !codeExists {
return "", fmt.Errorf("no language name found for ISO 639-1 code: %s", s)
}
return languageName, nil
}