Skip to content

Instantly share code, notes, and snippets.

@liesislukas
Created November 30, 2020 15:11
Show Gist options
  • Save liesislukas/6f3a0102b4d2ca7138f1c7c746247d9a to your computer and use it in GitHub Desktop.
Save liesislukas/6f3a0102b4d2ca7138f1c7c746247d9a to your computer and use it in GitHub Desktop.
country and locale list country code to name, locale code to language
/* eslint-disable max-lines */
const isoCountries = {
'AF': 'Afghanistan',
'AX': 'Aland Islands',
'AL': 'Albania',
'DZ': 'Algeria',
'AS': 'American Samoa',
'AD': 'Andorra',
'AO': 'Angola',
'AI': 'Anguilla',
'AQ': 'Antarctica',
'AG': 'Antigua And Barbuda',
'AR': 'Argentina',
'AM': 'Armenia',
'AW': 'Aruba',
'AU': 'Australia',
'AT': 'Austria',
'AZ': 'Azerbaijan',
'BS': 'Bahamas',
'BH': 'Bahrain',
'BD': 'Bangladesh',
'BB': 'Barbados',
'BY': 'Belarus',
'BE': 'Belgium',
'BZ': 'Belize',
'BJ': 'Benin',
'BM': 'Bermuda',
'BT': 'Bhutan',
'BO': 'Bolivia',
'BA': 'Bosnia And Herzegovina',
'BW': 'Botswana',
'BV': 'Bouvet Island',
'BR': 'Brazil',
'IO': 'British Indian Ocean Territory',
'BN': 'Brunei Darussalam',
'BG': 'Bulgaria',
'BF': 'Burkina Faso',
'BI': 'Burundi',
'KH': 'Cambodia',
'CM': 'Cameroon',
'CA': 'Canada',
'CV': 'Cape Verde',
'KY': 'Cayman Islands',
'CF': 'Central African Republic',
'TD': 'Chad',
'CL': 'Chile',
'CN': 'China',
'CX': 'Christmas Island',
'CC': 'Cocos (Keeling) Islands',
'CO': 'Colombia',
'KM': 'Comoros',
'CG': 'Congo',
'CD': 'Congo, Democratic Republic',
'CK': 'Cook Islands',
'CR': 'Costa Rica',
'CI': 'Cote D\'Ivoire',
'HR': 'Croatia',
'CU': 'Cuba',
'CY': 'Cyprus',
'CZ': 'Czech Republic',
'DK': 'Denmark',
'DJ': 'Djibouti',
'DM': 'Dominica',
'DO': 'Dominican Republic',
'EC': 'Ecuador',
'EG': 'Egypt',
'SV': 'El Salvador',
'GQ': 'Equatorial Guinea',
'ER': 'Eritrea',
'EE': 'Estonia',
'ET': 'Ethiopia',
'FK': 'Falkland Islands (Malvinas)',
'FO': 'Faroe Islands',
'FJ': 'Fiji',
'FI': 'Finland',
'FR': 'France',
'GF': 'French Guiana',
'PF': 'French Polynesia',
'TF': 'French Southern Territories',
'GA': 'Gabon',
'GM': 'Gambia',
'GE': 'Georgia',
'DE': 'Germany',
'GH': 'Ghana',
'GI': 'Gibraltar',
'GR': 'Greece',
'GL': 'Greenland',
'GD': 'Grenada',
'GP': 'Guadeloupe',
'GU': 'Guam',
'GT': 'Guatemala',
'GG': 'Guernsey',
'GN': 'Guinea',
'GW': 'Guinea-Bissau',
'GY': 'Guyana',
'HT': 'Haiti',
'HM': 'Heard Island & Mcdonald Islands',
'VA': 'Holy See (Vatican City State)',
'HN': 'Honduras',
'HK': 'Hong Kong',
'HU': 'Hungary',
'IS': 'Iceland',
'IN': 'India',
'ID': 'Indonesia',
'IR': 'Iran, Islamic Republic Of',
'IQ': 'Iraq',
'IE': 'Ireland',
'IM': 'Isle Of Man',
'IL': 'Israel',
'IT': 'Italy',
'JM': 'Jamaica',
'JP': 'Japan',
'JE': 'Jersey',
'JO': 'Jordan',
'KZ': 'Kazakhstan',
'KE': 'Kenya',
'KI': 'Kiribati',
'KR': 'Korea',
'KW': 'Kuwait',
'KG': 'Kyrgyzstan',
'LA': 'Lao People\'s Democratic Republic',
'LV': 'Latvia',
'LB': 'Lebanon',
'LS': 'Lesotho',
'LR': 'Liberia',
'LY': 'Libyan Arab Jamahiriya',
'LI': 'Liechtenstein',
'LT': 'Lithuania',
'LU': 'Luxembourg',
'MO': 'Macao',
'MK': 'Macedonia',
'MG': 'Madagascar',
'MW': 'Malawi',
'MY': 'Malaysia',
'MV': 'Maldives',
'ML': 'Mali',
'MT': 'Malta',
'MH': 'Marshall Islands',
'MQ': 'Martinique',
'MR': 'Mauritania',
'MU': 'Mauritius',
'YT': 'Mayotte',
'MX': 'Mexico',
'FM': 'Micronesia, Federated States Of',
'MD': 'Moldova',
'MC': 'Monaco',
'MN': 'Mongolia',
'ME': 'Montenegro',
'MS': 'Montserrat',
'MA': 'Morocco',
'MZ': 'Mozambique',
'MM': 'Myanmar',
'NA': 'Namibia',
'NR': 'Nauru',
'NP': 'Nepal',
'NL': 'Netherlands',
'AN': 'Netherlands Antilles',
'NC': 'New Caledonia',
'NZ': 'New Zealand',
'NI': 'Nicaragua',
'NE': 'Niger',
'NG': 'Nigeria',
'NU': 'Niue',
'NF': 'Norfolk Island',
'MP': 'Northern Mariana Islands',
'NO': 'Norway',
'OM': 'Oman',
'PK': 'Pakistan',
'PW': 'Palau',
'PS': 'Palestinian Territory, Occupied',
'PA': 'Panama',
'PG': 'Papua New Guinea',
'PY': 'Paraguay',
'PE': 'Peru',
'PH': 'Philippines',
'PN': 'Pitcairn',
'PL': 'Poland',
'PT': 'Portugal',
'PR': 'Puerto Rico',
'QA': 'Qatar',
'RE': 'Reunion',
'RO': 'Romania',
'RU': 'Russian Federation',
'RW': 'Rwanda',
'BL': 'Saint Barthelemy',
'SH': 'Saint Helena',
'KN': 'Saint Kitts And Nevis',
'LC': 'Saint Lucia',
'MF': 'Saint Martin',
'PM': 'Saint Pierre And Miquelon',
'VC': 'Saint Vincent And Grenadines',
'WS': 'Samoa',
'SM': 'San Marino',
'ST': 'Sao Tome And Principe',
'SA': 'Saudi Arabia',
'SN': 'Senegal',
'RS': 'Serbia',
'SC': 'Seychelles',
'SL': 'Sierra Leone',
'SG': 'Singapore',
'SK': 'Slovakia',
'SI': 'Slovenia',
'SB': 'Solomon Islands',
'SO': 'Somalia',
'ZA': 'South Africa',
'GS': 'South Georgia And Sandwich Isl.',
'ES': 'Spain',
'LK': 'Sri Lanka',
'SD': 'Sudan',
'SR': 'Suriname',
'SJ': 'Svalbard And Jan Mayen',
'SZ': 'Swaziland',
'SE': 'Sweden',
'CH': 'Switzerland',
'SY': 'Syrian Arab Republic',
'TW': 'Taiwan',
'TJ': 'Tajikistan',
'TZ': 'Tanzania',
'TH': 'Thailand',
'TL': 'Timor-Leste',
'TG': 'Togo',
'TK': 'Tokelau',
'TO': 'Tonga',
'TT': 'Trinidad And Tobago',
'TN': 'Tunisia',
'TR': 'Turkey',
'TM': 'Turkmenistan',
'TC': 'Turks And Caicos Islands',
'TV': 'Tuvalu',
'UG': 'Uganda',
'UA': 'Ukraine',
'AE': 'United Arab Emirates',
'GB': 'United Kingdom',
'US': 'United States',
'UM': 'United States Outlying Islands',
'UY': 'Uruguay',
'UZ': 'Uzbekistan',
'VU': 'Vanuatu',
'VE': 'Venezuela',
'VN': 'Viet Nam',
'VG': 'Virgin Islands, British',
'VI': 'Virgin Islands, U.S.',
'WF': 'Wallis And Futuna',
'EH': 'Western Sahara',
'YE': 'Yemen',
'ZM': 'Zambia',
'ZW': 'Zimbabwe',
};
const localeToLanguage = {
'aa': 'Afar',
'ab': 'Abkhaz',
'ae': 'Avestan',
'af': 'Afrikaans',
'ak': 'Akan',
'am': 'Amharic',
'an': 'Aragonese',
'ar': 'Arabic',
'ar-ae': 'Arabic - United Arab Emirates',
'ar-bh': 'Arabic - Bahrain',
'ar-dz': 'Arabic - Algeria',
'ar-eg': 'Arabic - Egypt',
'ar-iq': 'Arabic - Iraq',
'ar-jo': 'Arabic - Jordan',
'ar-kw': 'Arabic - Kuwait',
'ar-lb': 'Arabic - Lebanon',
'ar-ly': 'Arabic - Libya',
'ar-ma': 'Arabic - Morocco',
'ar-om': 'Arabic - Oman',
'ar-qa': 'Arabic - Qatar',
'ar-sa': 'Arabic - Saudi Arabia',
'ar-sy': 'Arabic - Syria',
'ar-tn': 'Arabic - Tunisia',
'ar-ye': 'Arabic - Yemen',
'as': 'Assamese',
'av': 'Avaric',
'ay': 'Aymara',
'az': 'Azerbaijani',
'az-az': 'Azeri',
'ba': 'Bashkir',
'be': 'Belarusian',
'bg': 'Bulgarian',
'bh': 'Bihari',
'bi': 'Bislama',
'bm': 'Bambara',
'bn': 'Bengali, Bangla',
'bo': 'Tibetan Standard, Tibetan, Central',
'br': 'Breton',
'bs': 'Bosnian',
'ca': 'Catalan',
'ce': 'Chechen',
'ch': 'Chamorro',
'co': 'Corsican',
'cr': 'Cree',
'cs': 'Czech',
'cu': 'Old Church Slavonic, Church Slavonic,Old Bulgarian',
'cv': 'Chuvash',
'cy': 'Welsh',
'da': 'Danish',
'de': 'German',
'de-at': 'German - Austria',
'de-ch': 'German - Switzerland',
'de-de': 'German - Germany',
'de-li': 'German - Liechtenstein',
'de-lu': 'German - Luxembourg',
'dv': 'Divehi, Dhivehi, Maldivian',
'dz': 'Dzongkha',
'ee': 'Ewe',
'el': 'Greek - Modern',
'en': 'English',
'en-au': 'English - Australia',
'en-bz': 'English - Belize',
'en-ca': 'English - Canada',
'en-cb': 'English - Caribbean',
'en-gb': 'English - Great Britain',
'en-ie': 'English - Ireland',
'en-il': 'English - Israel',
'en-in': 'English - India',
'en-jm': 'English - Jamaica',
'en-nz': 'English - New Zealand',
'en-ph': 'English - Phillippines',
'en-sg': 'English - Singapore',
'en-tt': 'English - Trinidad',
'en-us': 'English - United States',
'en-za': 'English - Southern Africa',
'eo': 'Esperanto',
'es': 'Spanish',
'es-ar': 'Spanish - Argentina',
'es-bo': 'Spanish - Bolivia',
'es-cl': 'Spanish - Chile',
'es-co': 'Spanish - Colombia',
'es-cr': 'Spanish - Costa Rica',
'es-do': 'Spanish - Dominican Republic',
'es-ec': 'Spanish - Ecuador',
'es-es': 'Spanish - Spain (Traditional)',
'es-gt': 'Spanish - Guatemala',
'es-hn': 'Spanish - Honduras',
'es-mx': 'Spanish - Mexico',
'es-ni': 'Spanish - Nicaragua',
'es-pa': 'Spanish - Panama',
'es-pe': 'Spanish - Peru',
'es-pr': 'Spanish - Puerto Rico',
'es-py': 'Spanish - Paraguay',
'es-sv': 'Spanish - El Salvador',
'es-us': 'Spanish - United States',
'es-uy': 'Spanish - Uruguay',
'es-ve': 'Spanish - Venezuela',
'et': 'Estonian',
'eu': 'Basque',
'fa': 'Persian - Farsi',
'ff': 'Fula, Fulah, Pulaar, Pular',
'fi': 'Finnish',
'fil': 'Filipino',
'fj': 'Fijian',
'fo': 'Faroese',
'fr': 'French',
'fr-be': 'French - Belgium',
'fr-ca': 'French - Canada',
'fr-ch': 'French - Switzerland',
'fr-fr': 'French - France',
'fr-lu': 'French - Luxembourg',
'fy': 'Western Frisian',
'ga': 'Irish',
'gd': 'Scottish Gaelic, Gaelic',
'gd-ie': 'Gaelic - Ireland',
'gl': 'Galician',
'gn': 'Guaraní',
'gom-deva': 'Konkani Devanagari',
'gom-latn': 'Konkani Latin',
'gu': 'Gujarati',
'gv': 'Manx',
'ha': 'Hausa',
'he': 'Hebrew - Modern',
'hi': 'Hindi',
'ho': 'Hiri Motu',
'hr': 'Croatian',
'ht': 'Haitian, Haitian Creole',
'hu': 'Hungarian',
'hy': 'Armenian',
'hy-am': 'Armenian',
'hz': 'Herero',
'ia': 'Interlingua',
'id': 'Indonesian',
'ie': 'Interlingue',
'ig': 'Igbo',
'ii': 'Nuosu',
'ik': 'Inupiaq',
'io': 'Ido',
'is': 'Icelandic',
'it': 'Italian',
'it-ch': 'Italian - Switzerland',
'it-it': 'Italian - Italy',
'iu': 'Inuktitut',
'ja': 'Japanese',
'jv': 'Javanese',
'ka': 'Georgian',
'kg': 'Kongo',
'ki': 'Kikuyu, Gikuyu',
'kj': 'Kwanyama, Kuanyama',
'kk': 'Kazakh',
'kl': 'Kalaallisut, Greenlandic',
'km': 'Khmer',
'kn': 'Kannada',
'ko': 'Korean',
'kr': 'Kanuri',
'ks': 'Kashmiri',
'ku': 'Kurdish',
'kv': 'Komi',
'kw': 'Cornish',
'ky': 'Kyrgyz',
'la': 'Latin',
'lb': 'Luxembourgish, Letzeburgesch',
'lg': 'Ganda',
'li': 'Limburgish, Limburgan, Limburger',
'ln': 'Lingala',
'lo': 'Lao',
'lt': 'Lithuanian',
'lu': 'Luba-Katanga',
'lv': 'Latvian',
'me': 'Montenegrin',
'mg': 'Malagasy',
'mh': 'Marshallese',
'mi': 'Māori',
'mk': 'Macedonian',
'ml': 'Malayalam',
'mn': 'Mongolian',
'mr': 'Marathi - Marāṭhī',
'ms': 'Malay',
'ms-bn': 'Malay - Brunei',
'ms-my': 'Malay - Malaysia',
'mt': 'Maltese',
'my': 'Burmese',
'na': 'Nauruan',
'nb': 'Norwegian Bokmål',
'nd': 'Northern Ndebele',
'ne': 'Nepali',
'ng': 'Ndonga',
'nl': 'Dutch',
'nl-be': 'Dutch - Belgium',
'nl-nl': 'Dutch - Netherlands',
'nn': 'Norwegian Nynorsk',
'no': 'Norwegian',
'no-no': 'Norwegian',
'nr': 'Southern Ndebele',
'nv': 'Navajo, Navaho',
'ny': 'Chichewa, Chewa, Nyanja',
'oc': 'Occitan',
'oc-lnc': 'Occitan - Lengadocian',
'oj': 'Ojibwe, Ojibwa',
'om': 'Oromo',
'or': 'Oriya',
'os': 'Ossetian, Ossetic',
'pa': 'Panjabi, Punjabi',
'pa-in': 'Punjabi - India',
'pi': 'Pāli',
'pl': 'Polish',
'ps': 'Pashto, Pushto',
'pt': 'Portuguese',
'pt-br': 'Portuguese - Brazil',
'pt-pt': 'Portuguese - Portugal',
'qu': 'Quechua',
'rm': 'Romansh',
'rn': 'Kirundi',
'ro': 'Romanian',
'ro-mo': 'Romanian - Moldova',
'ru': 'Russian',
'ru-mo': 'Russian - Moldova',
'rw': 'Kinyarwanda',
'sa': 'Sanskrit - Saṁskṛta',
'sc': 'Sardinian',
'sd': 'Sindhi',
'se': 'Northern Sami',
'sg': 'Sango',
'si': 'Sinhala, Sinhalese',
'sk': 'Slovak',
'sl': 'Slovene',
'sm': 'Samoan',
'sn': 'Shona',
'so': 'Somali',
'sq': 'Albanian',
'sr': 'Serbian',
'sr-cyrl': 'Serbian Cyrillic',
'sr-sp': 'Serbian',
'ss': 'Swati',
'st': 'Southern Sotho',
'su': 'Sundanese',
'sv': 'Swedish',
'sv-fi': 'Swedish - Finland',
'sv-se': 'Swedish - Sweden',
'sw': 'Swahili',
'ta': 'Tamil',
'te': 'Telugu',
'tet': 'Tetun Dili - East Timor',
'tg': 'Tajik',
'th': 'Thai',
'ti': 'Tigrinya',
'tk': 'Turkmen',
'tl': 'Tagalog',
'tl-ph': 'Tagalog - Philippines',
'tlh': 'Klingon',
'tn': 'Tswana',
'to': 'Tonga - Tonga Islands',
'tr': 'Turkish',
'ts': 'Tsonga',
'tt': 'Tatar',
'tw': 'Twi',
'ty': 'Tahitian',
'tzl': 'Talossan',
'tzm': 'Central Atlas Tamazight',
'tzm-latn': 'Central Atlas Tamazight - Latin',
'ug': 'Uyghur',
'ug-cn': 'Uyghur - China',
'uk': 'Ukrainian',
'ur': 'Urdu',
'uz': 'Uzbek',
'uz-latin': 'Uzbek - Latin',
'uz-latn': 'Uzbek Latin',
'uz-uz': 'Uzbek',
've': 'Venda',
'vi': 'Vietnamese',
'vo': 'Volapük',
'wa': 'Walloon',
'wo': 'Wolof',
'x-pseudo': 'Pseudo',
'xh': 'Xhosa',
'yi': 'Yiddish',
'yo': 'Yoruba',
'za': 'Zhuang, Chuang',
'zh': 'Chinese',
'zh-cn': 'Chinese - China',
'zh-hk': 'Chinese - Hong Kong SAR',
'zh-mo': 'Chinese - Macau SAR',
'zh-sg': 'Chinese - Singapore',
'zh-tw': 'Chinese - Taiwan',
'zu': 'Zulu',
};
const countryCodeToName = (countryCode) => {
countryCode = countryCode ? countryCode.toUpperCase() : countryCode;
return isoCountries[countryCode] || countryCode;
};
const localeCodeToLanguage = (locale) => {
locale = locale ? locale.toLowerCase() : locale;
return localeToLanguage[locale] || locale;
};
export {
countryCodeToName,
localeCodeToLanguage,
};
export default isoCountries;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment