Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xecgr/c753d36735c6e629c4d1 to your computer and use it in GitHub Desktop.
Save xecgr/c753d36735c6e629c4d1 to your computer and use it in GitHub Desktop.
ISO 3166-1 alpha-2 country code to country name conversion with a simple Javascript implementation, an array and a function. It completes the English version from https://gist.github.com/maephisto/9228207
//initially crawled from https://de.wikipedia.org/wiki/ISO-3166-1-Kodierliste
//2020-03-23, reviewed by @luwe1204
isoCountries = {
"AD": "Andorra",
"AE": "Vereinigte Arabische Emirate",
"AF": "Afghanistan",
"AG": "Antigua und Barbuda",
"AI": "Anguilla",
"AL": "Albanien",
"AM": "Armenien",
"AN": "Niederländische Antillen (ehemalig)",
"AO": "Angola",
"AQ": "Antarktika",
"AR": "Argentinien",
"AS": "Amerikanisch-Samoa",
"AT": "Österreich",
"AU": "Australien",
"AW": "Aruba",
"AX": "Aland",
"AZ": "Aserbaidschan",
"BA": "Bosnien und Herzegowina",
"BB": "Barbados",
"BD": "Bangladesch",
"BE": "Belgien",
"BF": "Burkina Faso",
"BG": "Bulgarien",
"BH": "Bahrain",
"BI": "Burundi",
"BJ": "Benin",
"BL": "Saint-Barthélemy",
"BM": "Bermuda",
"BN": "Brunei Darussalam",
"BO": "Bolivien",
"BQ": "Bonaire, Sint Eustatius und Saba (Niederlande)",
"BR": "Brasilien",
"BS": "Bahamas",
"BT": "Bhutan",
"BV": "Bouvetinsel",
"BW": "Botswana",
"BY": "Belarus (Weißrussland)",
"BZ": "Belize",
"CA": "Kanada",
"CC": "Kokosinseln",
"CD": "Kongo, Demokratische Republik (ehem. Zaire)",
"CF": "Zentralafrikanische Republik",
"CG": "Republik Kongo",
"CH": "Schweiz",
"CI": "Cote d'Ivoire",
"CK": "Cookinseln",
"CL": "Chile",
"CM": "Kamerun",
"CN": "Volksrepublik China",
"CO": "Kolumbien",
"CR": "Costa Rica",
"CU": "Kuba",
"CV": "Kap Verde",
"CW": "Curacao",
"CX": "Weihnachtsinsel",
"CY": "Zypern",
"CZ": "Tschechische Republik",
"DD": "Deutsche Demokratische Republik (historisch)",
"DE": "Deutschland",
"DJ": "Dschibuti",
"DK": "Dänemark",
"DM": "Dominica",
"DO": "Dominikanische Republik",
"DZ": "Algerien",
"EC": "Ecuador",
"EE": "Estland",
"EG": "Ägypten",
"EH": "Westsahara",
"ER": "Eritrea",
"ES": "Spanien",
"ET": "Athiopien",
"FJ": "Fidschi",
"FK": "Falklandinseln",
"FM": "Mikronesien",
"FO": "Färöer",
"FR": "Frankreich",
"GA": "Gabun",
"GD": "Grenada",
"GE": "Georgien",
"GF": "Französisch-Guayana",
"GG": "Guernsey (Kanalinsel)",
"GH": "Ghana",
"GI": "Gibraltar",
"GL": "Grönland",
"GM": "Gambia",
"GN": "Guinea",
"GP": "Guadeloupe",
"GQ": "Äquatorialguinea",
"GR": "Griechenland",
"GS": "Südgeorgien und die Südlichen Sandwichinseln",
"GT": "Guatemala",
"GU": "Guam",
"GW": "Guinea-Bissau",
"GY": "Guyana",
"HK": "Hongkong",
"HM": "Heard und McDonaldinseln",
"HN": "Honduras",
"HR": "Kroatien",
"HT": "Haiti",
"HU": "Ungarn",
"ID": "Indonesien",
"IE": "Irland",
"IL": "Israel",
"IM": "Isle of Man",
"IN": "Indien",
"IO": "Britisches Territorium im Indischen Ozean",
"IQ": "Irak",
"IR": "Iran",
"IS": "Island",
"IT": "Italien",
"JE": "Jersey (Kanalinsel)",
"JM": "Jamaika",
"JO": "Jordanien",
"JP": "Japan",
"KE": "Kenia",
"KG": "Kirgisistan",
"KH": "Kambodscha",
"KI": "Kiribati",
"KM": "Komoren",
"KN": "St. Kitts und Nevis",
"KP": "Nordkorea",
"KR": "Südkorea",
"KW": "Kuwait",
"KY": "Kaimaninseln",
"KZ": "Kasachstan",
"LA": "Laos",
"LB": "Libanon",
"LC": "St. Lucia",
"LI": "Liechtenstein",
"LK": "Sri Lanka",
"LR": "Liberia",
"LS": "Lesotho",
"LT": "Litauen",
"LU": "Luxemburg",
"LV": "Lettland",
"LY": "Libyen",
"MA": "Marokko",
"MC": "Monaco",
"MD": "Moldawien (Republik Moldau)",
"ME": "Montenegro",
"MF": "Saint-Martin (franz. Teil)",
"MG": "Madagaskar",
"MH": "Marshallinseln",
"MK": "Mazedonien",
"ML": "Mali",
"MM": "Myanmar (Burma)",
"MN": "Mongolei",
"MO": "Macau",
"MP": "Nördliche Marianen",
"MQ": "Martinique",
"MR": "Mauretanien",
"MS": "Montserrat",
"MT": "Malta",
"MU": "Mauritius",
"MV": "Malediven",
"MW": "Malawi",
"MX": "Mexiko",
"MY": "Malaysia",
"MZ": "Mosambik",
"NA": "Namibia",
"NC": "Neukaledonien",
"NE": "Niger",
"NF": "Norfolkinsel",
"NG": "Nigeria",
"NI": "Nicaragua",
"NL": "Niederlande",
"NO": "Norwegen",
"NP": "Nepal",
"NR": "Nauru",
"NU": "Niue",
"NZ": "Neuseeland",
"OM": "Oman",
"PA": "Panama",
"PE": "Peru",
"PF": "Französisch-Polynesien",
"PG": "Papua-Neuguinea",
"PH": "Philippinen",
"PK": "Pakistan",
"PL": "Polen",
"PM": "St. Pierre und Miquelon",
"PN": "Pitcairninseln",
"PR": "Puerto Rico",
"PS": "Palästina",
"PT": "Portugal",
"PW": "Palau",
"PY": "Paraguay",
"QA": "Katar",
"RE": "Réunion",
"RO": "Rumanien",
"RS": "Serbien",
"RU": "Russland",
"RW": "Ruanda",
"SA": "Saudi-Arabien",
"SB": "Salomonen",
"SC": "Seychellen",
"SD": "Sudan",
"SE": "Schweden",
"SG": "Singapur",
"SH": "St. Helena",
"SI": "Slowenien",
"SJ": "Svalbard und Jan Mayen",
"SK": "Slowakei",
"SL": "Sierra Leone",
"SM": "San Marino",
"SN": "Senegal",
"SO": "Somalia",
"SR": "Suriname",
"SS": "Südsudan",
"ST": "Sao Tomé und Príncipe",
"SV": "El Salvador",
"SX": "Sint Maarten (niederl. Teil)",
"SY": "Syrien",
"SZ": "Swasiland",
"TC": "Turks- und Caicosinseln",
"TD": "Tschad",
"TF": "Französische Süd- und Antarktisgebiete",
"TG": "Togo",
"TH": "Thailand",
"TJ": "Tadschikistan",
"TK": "Tokelau",
"TM": "Turkmenistan",
"TN": "Tunesien",
"TO": "Tonga",
"TR": "Türkei",
"TT": "Trinidad und Tobago",
"TV": "Tuvalu",
"TW": "Republik China (Taiwan)",
"TZ": "Vereinigte Republik Tansania",
"UA": "Ukraine",
"UG": "Uganda",
"UM": "United States Minor Outlying Islands",
"US": "Vereinigte Staaten von Amerika",
"UY": "Uruguay",
"UZ": "Usbekistan",
"VA": "Vatikanstadt",
"VC": "St. Vincent und die Grenadinen",
"VE": "Venezuela",
"VG": "Britische Jungferninseln",
"VI": "Amerikanische Jungferninseln",
"VN": "Vietnam",
"VU": "Vanuatu",
"WF": "Wallis und Futuna",
"WS": "Samoa",
"YE": "Jemen",
"YT": "Mayotte",
"ZA": "Südafrika",
"ZM": "Sambia",
"ZW": "Simbabwe"
}
@luwe1204
Copy link

This helped a lot, but here is a corrected version by a native speaker:

var isoCountries = {
"AD": "Andorra",
"AE": "Vereinigte Arabische Emirate",
"AF": "Afghanistan",
"AG": "Antigua und Barbuda",
"AI": "Anguilla",
"AL": "Albanien",
"AM": "Armenien",
"AN": "Niederländische Antillen (ehemalig)",
"AO": "Angola",
"AQ": "Antarktika",
"AR": "Argentinien",
"AS": "Amerikanisch-Samoa",
"AT": "Österreich",
"AU": "Australien",
"AW": "Aruba",
"AX": "Aland",
"AZ": "Aserbaidschan",
"BA": "Bosnien und Herzegowina",
"BB": "Barbados",
"BD": "Bangladesch",
"BE": "Belgien",
"BF": "Burkina Faso",
"BG": "Bulgarien",
"BH": "Bahrain",
"BI": "Burundi",
"BJ": "Benin",
"BL": "Saint-Barthélemy",
"BM": "Bermuda",
"BN": "Brunei Darussalam",
"BO": "Bolivien",
"BQ": "Bonaire, Sint Eustatius und Saba (Niederlande)",
"BR": "Brasilien",
"BS": "Bahamas",
"BT": "Bhutan",
"BV": "Bouvetinsel",
"BW": "Botswana",
"BY": "Belarus (Weißrussland)",
"BZ": "Belize",
"CA": "Kanada",
"CC": "Kokosinseln",
"CD": "Kongo, Demokratische Republik (ehem. Zaire)",
"CF": "Zentralafrikanische Republik",
"CG": "Republik Kongo",
"CH": "Schweiz",
"CI": "Cote d'Ivoire",
"CK": "Cookinseln",
"CL": "Chile",
"CM": "Kamerun",
"CN": "Volksrepublik China",
"CO": "Kolumbien",
"CR": "Costa Rica",
"CU": "Kuba",
"CV": "Kap Verde",
"CW": "Curacao",
"CX": "Weihnachtsinsel",
"CY": "Zypern",
"CZ": "Tschechische Republik",
"DD": "Deutsche Demokratische Republik (historisch)",
"DE": "Deutschland",
"DJ": "Dschibuti",
"DK": "Dänemark",
"DM": "Dominica",
"DO": "Dominikanische Republik",
"DZ": "Algerien",
"EC": "Ecuador",
"EE": "Estland",
"EG": "Ägypten",
"EH": "Westsahara",
"ER": "Eritrea",
"ES": "Spanien",
"ET": "Athiopien",
"FJ": "Fidschi",
"FK": "Falklandinseln",
"FM": "Mikronesien",
"FO": "Färöer",
"FR": "Frankreich",
"GA": "Gabun",
"GD": "Grenada",
"GE": "Georgien",
"GF": "Französisch-Guayana",
"GG": "Guernsey (Kanalinsel)",
"GH": "Ghana",
"GI": "Gibraltar",
"GL": "Grönland",
"GM": "Gambia",
"GN": "Guinea",
"GP": "Guadeloupe",
"GQ": "Äquatorialguinea",
"GR": "Griechenland",
"GS": "Südgeorgien und die Südlichen Sandwichinseln",
"GT": "Guatemala",
"GU": "Guam",
"GW": "Guinea-Bissau",
"GY": "Guyana",
"HK": "Hongkong",
"HM": "Heard und McDonaldinseln",
"HN": "Honduras",
"HR": "Kroatien",
"HT": "Haiti",
"HU": "Ungarn",
"ID": "Indonesien",
"IE": "Irland",
"IL": "Israel",
"IM": "Isle of Man",
"IN": "Indien",
"IO": "Britisches Territorium im Indischen Ozean",
"IQ": "Irak",
"IR": "Iran",
"IS": "Island",
"IT": "Italien",
"JE": "Jersey (Kanalinsel)",
"JM": "Jamaika",
"JO": "Jordanien",
"JP": "Japan",
"KE": "Kenia",
"KG": "Kirgisistan",
"KH": "Kambodscha",
"KI": "Kiribati",
"KM": "Komoren",
"KN": "St. Kitts und Nevis",
"KP": "Nordkorea",
"KR": "Südkorea",
"KW": "Kuwait",
"KY": "Kaimaninseln",
"KZ": "Kasachstan",
"LA": "Laos",
"LB": "Libanon",
"LC": "St. Lucia",
"LI": "Liechtenstein",
"LK": "Sri Lanka",
"LR": "Liberia",
"LS": "Lesotho",
"LT": "Litauen",
"LU": "Luxemburg",
"LV": "Lettland",
"LY": "Libyen",
"MA": "Marokko",
"MC": "Monaco",
"MD": "Moldawien (Republik Moldau)",
"ME": "Montenegro",
"MF": "Saint-Martin (franz. Teil)",
"MG": "Madagaskar",
"MH": "Marshallinseln",
"MK": "Mazedonien",
"ML": "Mali",
"MM": "Myanmar (Burma)",
"MN": "Mongolei",
"MO": "Macau",
"MP": "Nördliche Marianen",
"MQ": "Martinique",
"MR": "Mauretanien",
"MS": "Montserrat",
"MT": "Malta",
"MU": "Mauritius",
"MV": "Malediven",
"MW": "Malawi",
"MX": "Mexiko",
"MY": "Malaysia",
"MZ": "Mosambik",
"NA": "Namibia",
"NC": "Neukaledonien",
"NE": "Niger",
"NF": "Norfolkinsel",
"NG": "Nigeria",
"NI": "Nicaragua",
"NL": "Niederlande",
"NO": "Norwegen",
"NP": "Nepal",
"NR": "Nauru",
"NU": "Niue",
"NZ": "Neuseeland",
"OM": "Oman",
"PA": "Panama",
"PE": "Peru",
"PF": "Französisch-Polynesien",
"PG": "Papua-Neuguinea",
"PH": "Philippinen",
"PK": "Pakistan",
"PL": "Polen",
"PM": "St. Pierre und Miquelon",
"PN": "Pitcairninseln",
"PR": "Puerto Rico",
"PS": "Palästina",
"PT": "Portugal",
"PW": "Palau",
"PY": "Paraguay",
"QA": "Katar",
"RE": "Réunion",
"RO": "Rumanien",
"RS": "Serbien",
"RU": "Russland",
"RW": "Ruanda",
"SA": "Saudi-Arabien",
"SB": "Salomonen",
"SC": "Seychellen",
"SD": "Sudan",
"SE": "Schweden",
"SG": "Singapur",
"SH": "St. Helena",
"SI": "Slowenien",
"SJ": "Svalbard und Jan Mayen",
"SK": "Slowakei",
"SL": "Sierra Leone",
"SM": "San Marino",
"SN": "Senegal",
"SO": "Somalia",
"SR": "Suriname",
"SS": "Südsudan",
"ST": "Sao Tomé und Príncipe",
"SV": "El Salvador",
"SX": "Sint Maarten (niederl. Teil)",
"SY": "Syrien",
"SZ": "Swasiland",
"TC": "Turks- und Caicosinseln",
"TD": "Tschad",
"TF": "Französische Süd- und Antarktisgebiete",
"TG": "Togo",
"TH": "Thailand",
"TJ": "Tadschikistan",
"TK": "Tokelau",
"TM": "Turkmenistan",
"TN": "Tunesien",
"TO": "Tonga",
"TR": "Türkei",
"TT": "Trinidad und Tobago",
"TV": "Tuvalu",
"TW": "Republik China (Taiwan)",
"TZ": "Vereinigte Republik Tansania",
"UA": "Ukraine",
"UG": "Uganda",
"UM": "United States Minor Outlying Islands",
"US": "Vereinigte Staaten von Amerika",
"UY": "Uruguay",
"UZ": "Usbekistan",
"VA": "Vatikanstadt",
"VC": "St. Vincent und die Grenadinen",
"VE": "Venezuela",
"VG": "Britische Jungferninseln",
"VI": "Amerikanische Jungferninseln",
"VN": "Vietnam",
"VU": "Vanuatu",
"WF": "Wallis und Futuna",
"WS": "Samoa",
"YE": "Jemen",
"YT": "Mayotte",
"ZA": "Südafrika",
"ZM": "Sambia",
"ZW": "Simbabwe"
};

@xecgr
Copy link
Author

xecgr commented Mar 23, 2020

commited! @luwe1204 thanks for your update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment