package iso639 import ( "fmt" ) var iso639_2BCodeToName = map[string]string{ "aar": "Afar", "abk": "Abkhazian", "afr": "Afrikaans", "aka": "Akan", "alb": "Albanian", "amh": "Amharic", "ara": "Arabic", "arg": "Aragonese", "arm": "Armenian", "asm": "Assamese", "ava": "Avaric", "ave": "Avestan", "aym": "Aymara", "aze": "Azerbaijani", "bak": "Bashkir", "bam": "Bambara", "baq": "Basque", "bel": "Belarusian", "ben": "Bengali", "bis": "Bislama", "bos": "Bosnian", "bre": "Breton", "bul": "Bulgarian", "bur": "Burmese", "cat": "Catalan", "cha": "Chamorro", "che": "Chechen", "chi": "Chinese", "chu": "Church Slavonic", "chv": "Chuvash", "cor": "Cornish", "cos": "Corsican", "cre": "Cree", "cze": "Czech", "dan": "Danish", "div": "Divehi", "dut": "Dutch", "dzo": "Dzongkha", "eng": "English", "epo": "Esperanto", "est": "Estonian", "ewe": "Ewe", "fao": "Faroese", "fij": "Fijian", "fin": "Finnish", "fre": "French", "fry": "Western Frisian", "ful": "Fulah", "geo": "Georgian", "ger": "German", "gla": "Gaelic", "gle": "Irish", "glg": "Galician", "glv": "Manx", "gre": "Greek", "grn": "Guarani", "guj": "Gujarati", "hat": "Haitian", "hau": "Hausa", "heb": "Hebrew", "her": "Herero", "hin": "Hindi", "hmo": "Hiri Motu", "hrv": "Croatian", "hun": "Hungarian", "ibo": "Igbo", "ice": "Icelandic", "ido": "Ido", "iii": "Sichuan Yi", "iku": "Inuktitut", "ile": "Interlingue", "ina": "Interlingua", "ind": "Indonesian", "ipk": "Inupiaq", "ita": "Italian", "jav": "Javanese", "jpn": "Japanese", "kal": "Kalaallisut", "kan": "Kannada", "kas": "Kashmiri", "kau": "Kanuri", "kaz": "Kazakh", "khm": "Central Khmer", "kik": "Kikuyu", "kin": "Kinyarwanda", "kir": "Kirghiz", "kom": "Komi", "kon": "Kongo", "kor": "Korean", "kua": "Kuanyama", "kur": "Kurdish", "lao": "Lao", "lat": "Latin", "lav": "Latvian", "lim": "Limburgan", "lin": "Lingala", "lit": "Lithuanian", "ltz": "Luxembourgish", "lub": "Luba-Katanga", "lug": "Ganda", "mac": "Macedonian", "mah": "Marshallese", "mal": "Malayalam", "mao": "Maori", "mar": "Marathi", "may": "Malay", "mlg": "Malagasy", "mlt": "Maltese", "mon": "Mongolian", "nau": "Nauru", "nav": "Navajo", "nbl": "South Ndebele", "nde": "North Ndebele", "ndo": "Ndonga", "nep": "Nepali", "nno": "Norwegian Nynorsk", "nob": "Norwegian Bokmål", "nor": "Norwegian", "nya": "Chichewa", "oci": "Occitan", "oji": "Ojibwa", "ori": "Oriya", "orm": "Oromo", "oss": "Ossetian", "pan": "Punjabi", "per": "Persian", "pli": "Pali", "pol": "Polish", "por": "Portuguese", "pus": "Pashto", "que": "Quechua", "roh": "Romansh", "rum": "Romanian", "run": "Rundi", "rus": "Russian", "sag": "Sango", "san": "Sanskrit", "sin": "Sinhala", "slo": "Slovak", "slv": "Slovenian", "sme": "Northern Sami", "smo": "Samoan", "sna": "Shona", "snd": "Sindhi", "som": "Somali", "sot": "Southern Sotho", "spa": "Spanish", "srd": "Sardinian", "srp": "Serbian", "ssw": "Swati", "sun": "Sundanese", "swa": "Swahili", "swe": "Swedish", "tah": "Tahitian", "tam": "Tamil", "tat": "Tatar", "tel": "Telugu", "tgk": "Tajik", "tgl": "Tagalog", "tha": "Thai", "tib": "Tibetan", "tir": "Tigrinya", "ton": "Tonga", "tsn": "Tswana", "tso": "Tsonga", "tuk": "Turkmen", "tur": "Turkish", "twi": "Twi", "uig": "Uighur", "ukr": "Ukrainian", "urd": "Urdu", "uzb": "Uzbek", "ven": "Venda", "vie": "Vietnamese", "vol": "Volapück", "wel": "Welsh", "wln": "Walloon", "wol": "Wolof", "xho": "Xhosa", "yid": "Yiddish", "yor": "Yoruba", "zha": "Zhuang", "zul": "Zulu", } var iso639_2BNameToCode = map[string]string{ "Abkhazian": "abk", "Afar": "aar", "Afrikaans": "afr", "Akan": "aka", "Albanian": "alb", "Amharic": "amh", "Arabic": "ara", "Aragonese": "arg", "Armenian": "arm", "Assamese": "asm", "Avaric": "ava", "Avestan": "ave", "Aymara": "aym", "Azerbaijani": "aze", "Bambara": "bam", "Bashkir": "bak", "Basque": "baq", "Belarusian": "bel", "Bengali": "ben", "Bislama": "bis", "Bosnian": "bos", "Breton": "bre", "Bulgarian": "bul", "Burmese": "bur", "Catalan": "cat", "Central Khmer": "khm", "Chamorro": "cha", "Chechen": "che", "Chichewa": "nya", "Chinese": "chi", "Church Slavonic": "chu", "Chuvash": "chv", "Cornish": "cor", "Corsican": "cos", "Cree": "cre", "Croatian": "hrv", "Czech": "cze", "Danish": "dan", "Divehi": "div", "Dutch": "dut", "Dzongkha": "dzo", "English": "eng", "Esperanto": "epo", "Estonian": "est", "Ewe": "ewe", "Faroese": "fao", "Fijian": "fij", "Finnish": "fin", "French": "fre", "Fulah": "ful", "Gaelic": "gla", "Galician": "glg", "Ganda": "lug", "Georgian": "geo", "German": "ger", "Greek": "gre", "Guarani": "grn", "Gujarati": "guj", "Haitian": "hat", "Hausa": "hau", "Hebrew": "heb", "Herero": "her", "Hindi": "hin", "Hiri Motu": "hmo", "Hungarian": "hun", "Icelandic": "ice", "Ido": "ido", "Igbo": "ibo", "Indonesian": "ind", "Interlingua": "ina", "Interlingue": "ile", "Inuktitut": "iku", "Inupiaq": "ipk", "Irish": "gle", "Italian": "ita", "Japanese": "jpn", "Javanese": "jav", "Kalaallisut": "kal", "Kannada": "kan", "Kanuri": "kau", "Kashmiri": "kas", "Kazakh": "kaz", "Kikuyu": "kik", "Kinyarwanda": "kin", "Kirghiz": "kir", "Komi": "kom", "Kongo": "kon", "Korean": "kor", "Kuanyama": "kua", "Kurdish": "kur", "Lao": "lao", "Latin": "lat", "Latvian": "lav", "Limburgan": "lim", "Lingala": "lin", "Lithuanian": "lit", "Luba-Katanga": "lub", "Luxembourgish": "ltz", "Macedonian": "mac", "Malagasy": "mlg", "Malay": "may", "Malayalam": "mal", "Maltese": "mlt", "Manx": "glv", "Maori": "mao", "Marathi": "mar", "Marshallese": "mah", "Mongolian": "mon", "Nauru": "nau", "Navajo": "nav", "Ndonga": "ndo", "Nepali": "nep", "North Ndebele": "nde", "Northern Sami": "sme", "Norwegian Bokmål": "nob", "Norwegian Nynorsk": "nno", "Norwegian": "nor", "Occitan": "oci", "Ojibwa": "oji", "Oriya": "ori", "Oromo": "orm", "Ossetian": "oss", "Pali": "pli", "Pashto": "pus", "Persian": "per", "Polish": "pol", "Portuguese": "por", "Punjabi": "pan", "Quechua": "que", "Romanian": "rum", "Romansh": "roh", "Rundi": "run", "Russian": "rus", "Samoan": "smo", "Sango": "sag", "Sanskrit": "san", "Sardinian": "srd", "Serbian": "srp", "Shona": "sna", "Sichuan Yi": "iii", "Sindhi": "snd", "Sinhala": "sin", "Slovak": "slo", "Slovenian": "slv", "Somali": "som", "South Ndebele": "nbl", "Southern Sotho": "sot", "Spanish": "spa", "Sundanese": "sun", "Swahili": "swa", "Swati": "ssw", "Swedish": "swe", "Tagalog": "tgl", "Tahitian": "tah", "Tajik": "tgk", "Tamil": "tam", "Tatar": "tat", "Telugu": "tel", "Thai": "tha", "Tibetan": "tib", "Tigrinya": "tir", "Tonga": "ton", "Tsonga": "tso", "Tswana": "tsn", "Turkish": "tur", "Turkmen": "tuk", "Twi": "twi", "Uighur": "uig", "Ukrainian": "ukr", "Urdu": "urd", "Uzbek": "uzb", "Venda": "ven", "Vietnamese": "vie", "Volapück": "vol", "Walloon": "wln", "Welsh": "wel", "Western Frisian": "fry", "Wolof": "wol", "Xhosa": "xho", "Yiddish": "yid", "Yoruba": "yor", "Zhuang": "zha", "Zulu": "zul", } // GetAllISO639_2BCodes returns all ISO 639-2/B codes func GetAllISO639_2BCodes() []string { return getAllKeysOfMap(iso639_2BCodeToName) } // GetAllISO639_2BNames returns all ISO 639-2/B language names func GetAllISO639_2BNames() []string { return getAllKeysOfMap(iso639_2BNameToCode) } // GetISO639_2BCodeForLanguageName tries to match a language name to an ISO 639-2/B code func GetISO639_2BCodeForLanguageName(s string) (string, error) { code, languageNameExists := iso639_2BNameToCode[s] if !languageNameExists { return "", fmt.Errorf("no ISO 639-2/B code found for language name: %s", s) } return code, nil } // GetLanguageNameForISO639_2BCode tries to match an ISO 639-2/B code to a language name func GetLanguageNameForISO639_2BCode(s string) (string, error) { languageName, codeExists := iso639_2BCodeToName[s] if !codeExists { return "", fmt.Errorf("no language name found for ISO 639-2/B code: %s", s) } return languageName, nil }