# -*- coding: utf-8 -*-
from __future__ import unicode_literals

try:
    import babel
except ImportError:  # pragma: no cover
    babel = False

from django.db import models
from django.utils.translation import ugettext as _

__all__ = [
    'COUNTRIES_RAW',
    'COUNTRIES',
    'CURRENCIES',
    'LANGUAGES',
    'LANGUAGES_NATIVE',
    'LANGUAGES_ENGLISH',
    'Country'
]

"""
Countries and currencies.

Country data includes 2- and 3-letter ISO codes, continents, and full country
names. Currency data includes 3-letter ISO code and full currency name.

Country fixtures are provided but they are not in the form of initial data,
since we might want to edit the country list at some point, depending on our
needs.
"""

COUNTRIES_RAW = (
    ("AF", "AO", "AGO", 24, _("Angola, Republic of")),
    ("AF", "BF", "BFA", 854, _("Burkina Faso")),
    ("AF", "BI", "BDI", 108, _("Burundi, Republic of")),
    ("AF", "BJ", "BEN", 204, _("Benin, Republic of")),
    ("AF", "BW", "BWA", 72, _("Botswana, Republic of")),
    ("AF", "CD", "COD", 180, _("Congo, Democratic Republic of the")),
    ("AF", "CF", "CAF", 140, _("Central African Republic")),
    ("AF", "CG", "COG", 178, _("Congo, Republic of the")),
    ("AF", "CI", "CIV", 384, _("Cote d'Ivoire, Republic of")),
    ("AF", "CM", "CMR", 120, _("Cameroon, Republic of")),
    ("AF", "CV", "CPV", 132, _("Cape Verde, Republic of")),
    ("AF", "DJ", "DJI", 262, _("Djibouti, Republic of")),
    ("AF", "DZ", "DZA", 12, _("Algeria, People's Democratic Republic of")),
    ("AF", "EG", "EGY", 818, _("Egypt, Arab Republic of")),
    ("AF", "EH", "ESH", 732, _("Western Sahara")),
    ("AF", "ER", "ERI", 232, _("Eritrea, State of")),
    ("AF", "ET", "ETH", 231, _("Ethiopia, Federal Democratic Republic of")),
    ("AF", "GA", "GAB", 266, _("Gabon, Gabonese Republic")),
    ("AF", "GH", "GHA", 288, _("Ghana, Republic of")),
    ("AF", "GM", "GMB", 270, _("Gambia, Republic of the")),
    ("AF", "GN", "GIN", 324, _("Guinea, Republic of")),
    ("AF", "GQ", "GNQ", 226, _("Equatorial Guinea, Republic of")),
    ("AF", "GW", "GNB", 624, _("Guinea-Bissau, Republic of")),
    ("AF", "KE", "KEN", 404, _("Kenya, Republic of")),
    ("AF", "KM", "COM", 174, _("Comoros, Union of the")),
    ("AF", "LR", "LBR", 430, _("Liberia, Republic of")),
    ("AF", "LS", "LSO", 426, _("Lesotho, Kingdom of")),
    ("AF", "LY", "LBY", 434, _("Libyan Arab Jamahiriya")),
    ("AF", "MA", "MAR", 504, _("Morocco, Kingdom of")),
    ("AF", "MG", "MDG", 450, _("Madagascar, Republic of")),
    ("AF", "ML", "MLI", 466, _("Mali, Republic of")),
    ("AF", "MR", "MRT", 478, _("Mauritania, Islamic Republic of")),
    ("AF", "MU", "MUS", 480, _("Mauritius, Republic of")),
    ("AF", "MW", "MWI", 454, _("Malawi, Republic of")),
    ("AF", "MZ", "MOZ", 508, _("Mozambique, Republic of")),
    ("AF", "NA", "NAM", 516, _("Namibia, Republic of")),
    ("AF", "NE", "NER", 562, _("Niger, Republic of")),
    ("AF", "NG", "NGA", 566, _("Nigeria, Federal Republic of")),
    ("AF", "RE", "REU", 638, _("Reunion")),
    ("AF", "RW", "RWA", 646, _("Rwanda, Republic of")),
    ("AF", "SC", "SYC", 690, _("Seychelles, Republic of")),
    ("AF", "SD", "SDN", 736, _("Sudan, Republic of")),
    ("AF", "SH", "SHN", 654, _("Saint Helena")),
    ("AF", "SL", "SLE", 694, _("Sierra Leone, Republic of")),
    ("AF", "SN", "SEN", 686, _("Senegal, Republic of")),
    ("AF", "SO", "SOM", 706, _("Somalia, Somali Republic")),
    ("AF", "SS", "SSD", 728, _("South Sudan")),
    (
        "AF", "ST", "STP", 678,
        _("Sao Tome and Principe, Democratic Republic of")
    ),
    ("AF", "SZ", "SWZ", 748, _("Swaziland, Kingdom of")),
    ("AF", "TD", "TCD", 148, _("Chad, Republic of")),
    ("AF", "TG", "TGO", 768, _("Togo, Togolese Republic")),
    ("AF", "TN", "TUN", 788, _("Tunisia, Tunisian Republic")),
    ("AF", "TZ", "TZA", 834, _("Tanzania, United Republic of")),
    ("AF", "UG", "UGA", 800, _("Uganda, Republic of")),
    ("AF", "YT", "MYT", 175, _("Mayotte")),
    ("AF", "ZA", "ZAF", 710, _("South Africa, Republic of")),
    ("AF", "ZM", "ZMB", 894, _("Zambia, Republic of")),
    ("AF", "ZW", "ZWE", 716, _("Zimbabwe, Republic of")),
    ("AN", "AQ", "ATA", 10, _("Antarctica (the territory South of 60 deg S)")),
    ("AN", "BV", "BVT", 74, _("Bouvet Island (Bouvetoya)")),
    (
        "AN", "GS", "SGS", 239,
        _("South Georgia and the South Sandwich Islands")
    ),
    ("AN", "HM", "HMD", 334, _("Heard Island and McDonald Islands")),
    ("AN", "TF", "ATF", 260, _("French Southern Territories")),
    ("AS", "AE", "ARE", 784, _("United Arab Emirates")),
    ("AS", "AF", "AFG", 4, _("Afghanistan, Islamic Republic of")),
    ("AS", "AM", "ARM", 51, _("Armenia, Republic of")),
    ("AS", "AZ", "AZE", 31, _("Azerbaijan, Republic of")),
    ("AS", "BD", "BGD", 50, _("Bangladesh, People's Republic of")),
    ("AS", "BH", "BHR", 48, _("Bahrain, Kingdom of")),
    ("AS", "BN", "BRN", 96, _("Brunei Darussalam")),
    ("AS", "BT", "BTN", 64, _("Bhutan, Kingdom of")),
    ("AS", "CC", "CCK", 166, _("Cocos (Keeling) Islands")),
    ("AS", "CN", "CHN", 156, _("China, People's Republic of")),
    ("AS", "CX", "CXR", 162, _("Christmas Island")),
    ("AS", "GE", "GEO", 268, _("Georgia")),
    (
        "AS", "HK", "HKG", 344,
        _("Hong Kong, Special Administrative Region of China")
    ),
    ("AS", "ID", "IDN", 360, _("Indonesia, Republic of")),
    ("AS", "IL", "ISR", 376, _("Israel, State of")),
    ("AS", "IN", "IND", 356, _("India, Republic of")),
    (
        "AS", "IO", "IOT", 86,
        _("British Indian Ocean Territory (Chagos Archipelago)")
    ),
    ("AS", "IQ", "IRQ", 368, _("Iraq, Republic of")),
    ("AS", "IR", "IRN", 364, _("Iran, Islamic Republic of")),
    ("AS", "JO", "JOR", 400, _("Jordan, Hashemite Kingdom of")),
    ("AS", "JP", "JPN", 392, _("Japan")),
    ("AS", "KG", "KGZ", 417, _("Kyrgyz Republic")),
    ("AS", "KH", "KHM", 116, _("Cambodia, Kingdom of")),
    ("AS", "KP", "PRK", 408, _("Korea, Democratic People's Republic of")),
    ("AS", "KR", "KOR", 410, _("Korea, Republic of")),
    ("AS", "KW", "KWT", 414, _("Kuwait, State of")),
    ("AS", "KZ", "KAZ", 398, _("Kazakhstan, Republic of")),
    ("AS", "LA", "LAO", 418, _("Lao People's Democratic Republic")),
    ("AS", "LB", "LBN", 422, _("Lebanon, Lebanese Republic")),
    (
        "AS", "LK", "LKA", 144,
        _("Sri Lanka, Democratic Socialist Republic of")
    ),
    ("AS", "MM", "MMR", 104, _("Myanmar, Union of")),
    ("AS", "MN", "MNG", 496, _("Mongolia")),
    (
        "AS", "MO", "MAC", 446,
        _("Macao, Special Administrative Region of China")
    ),
    ("AS", "MV", "MDV", 462, _("Maldives, Republic of")),
    ("AS", "MY", "MYS", 458, _("Malaysia")),
    ("AS", "NP", "NPL", 524, _("Nepal, State of")),
    ("AS", "OM", "OMN", 512, _("Oman, Sultanate of")),
    ("AS", "PH", "PHL", 608, _("Philippines, Republic of the")),
    ("AS", "PK", "PAK", 586, _("Pakistan, Islamic Republic of")),
    ("AS", "PS", "PSE", 275, _("Palestinian Territory, Occupied")),
    ("AS", "QA", "QAT", 634, _("Qatar, State of")),
    ("AS", "SA", "SAU", 682, _("Saudi Arabia, Kingdom of")),
    ("AS", "SG", "SGP", 702, _("Singapore, Republic of")),
    ("AS", "SY", "SYR", 760, _("Syrian Arab Republic")),
    ("AS", "TH", "THA", 764, _("Thailand, Kingdom of")),
    ("AS", "TJ", "TJK", 762, _("Tajikistan, Republic of")),
    ("AS", "TL", "TLS", 626, _("Timor-Leste, Democratic Republic of")),
    ("AS", "TM", "TKM", 795, _("Turkmenistan")),
    ("AS", "TW", "TWN", 158, _("Taiwan")),
    ("AS", "UZ", "UZB", 860, _("Uzbekistan, Republic of")),
    ("AS", "VN", "VNM", 704, _("Vietnam, Socialist Republic of")),
    ("AS", "XD", None, None, _("United Nations Neutral Zone")),
    ("AS", "XE", None, None, _("Iraq-Saudi Arabia Neutral Zone")),
    ("AS", "XS", None, None, _("Spratly Islands")),
    ("AS", "XS", None, None, _("Spratly Islands")),
    ("AS", "YE", "YEM", 887, _("Yemen")),
    ("EU", "AD", "AND", 20, _("Andorra, Principality of")),
    ("EU", "AL", "ALB", 8, _("Albania, Republic of")),
    ("EU", "AT", "AUT", 40, _("Austria, Republic of")),
    ("EU", "AX", "ALA", 248, _("Åland Islands")),
    ("EU", "BA", "BIH", 70, _("Bosnia and Herzegovina")),
    ("EU", "BE", "BEL", 56, _("Belgium, Kingdom of")),
    ("EU", "BG", "BGR", 100, _("Bulgaria, Republic of")),
    ("EU", "BY", "BLR", 112, _("Belarus, Republic of")),
    ("EU", "CH", "CHE", 756, _("Switzerland, Swiss Confederation")),
    ("EU", "CY", "CYP", 196, _("Cyprus, Republic of")),
    ("EU", "CZ", "CZE", 203, _("Czech Republic")),
    ("EU", "DE", "DEU", 276, _("Germany, Federal Republic of")),
    ("EU", "DK", "DNK", 208, _("Denmark, Kingdom of")),
    ("EU", "EE", "EST", 233, _("Estonia, Republic of")),
    ("EU", "ES", "ESP", 724, _("Spain, Kingdom of")),
    ("EU", "FI", "FIN", 246, _("Finland, Republic of")),
    ("EU", "FO", "FRO", 234, _("Faroe Islands")),
    ("EU", "FR", "FRA", 250, _("France, French Republic")),
    ("EU", "GB", "GBR", 826, _("United Kingdom")),
    ("EU", "GG", "GGY", 831, _("Guernsey, Bailiwick of")),
    ("EU", "GI", "GIB", 292, _("Gibraltar")),
    ("EU", "GR", "GRC", 300, _("Greece, Hellenic Republic")),
    ("EU", "HR", "HRV", 191, _("Croatia, Republic of")),
    ("EU", "HU", "HUN", 348, _("Hungary, Republic of")),
    ("EU", "IE", "IRL", 372, _("Ireland")),
    ("EU", "IM", "IMN", 833, _("Isle of Man")),
    ("EU", "IS", "ISL", 352, _("Iceland, Republic of")),
    ("EU", "IT", "ITA", 380, _("Italy, Italian Republic")),
    ("EU", "JE", "JEY", 832, _("Jersey, Bailiwick of")),
    ("EU", "LI", "LIE", 438, _("Liechtenstein, Principality of")),
    ("EU", "LT", "LTU", 440, _("Lithuania, Republic of")),
    ("EU", "LU", "LUX", 442, _("Luxembourg, Grand Duchy of")),
    ("EU", "LV", "LVA", 428, _("Latvia, Republic of")),
    ("EU", "MC", "MCO", 492, _("Monaco, Principality of")),
    ("EU", "MD", "MDA", 498, _("Moldova, Republic of")),
    ("EU", "ME", "MNE", 499, _("Montenegro, Republic of")),
    ("EU", "MK", "MKD", 807, _("Macedonia, The Former Yugoslav Republic of")),
    ("EU", "MT", "MLT", 470, _("Malta, Republic of")),
    ("EU", "NL", "NLD", 528, _("Netherlands, Kingdom of the")),
    ("EU", "NO", "NOR", 578, _("Norway, Kingdom of")),
    ("EU", "PL", "POL", 616, _("Poland, Republic of")),
    ("EU", "PT", "PRT", 620, _("Portugal, Portuguese Republic")),
    ("EU", "RO", "ROU", 642, _("Romania")),
    ("EU", "RS", "SRB", 688, _("Serbia, Republic of")),
    ("EU", "RU", "RUS", 643, _("Russian Federation")),
    ("EU", "SE", "SWE", 752, _("Sweden, Kingdom of")),
    ("EU", "SI", "SVN", 705, _("Slovenia, Republic of")),
    ("EU", "SJ", "SJM", 744, _("Svalbard & Jan Mayen Islands")),
    ("EU", "SK", "SVK", 703, _("Slovakia (Slovak Republic)")),
    ("EU", "SM", "SMR", 674, _("San Marino, Republic of")),
    ("EU", "TR", "TUR", 792, _("Turkey, Republic of")),
    ("EU", "UA", "UKR", 804, _("Ukraine")),
    ("EU", "VA", "VAT", 336, _("Holy See (Vatican City State)")),
    ("NA", "AG", "ATG", 28, _("Antigua and Barbuda")),
    ("NA", "AI", "AIA", 660, _("Anguilla")),
    ("NA", "AN", "ANT", 530, _("Netherlands Antilles")),
    ("NA", "AW", "ABW", 533, _("Aruba")),
    ("NA", "BB", "BRB", 52, _("Barbados")),
    ("NA", "BL", "BLM", 652, _("Saint Barthelemy")),
    ("NA", "BM", "BMU", 60, _("Bermuda")),
    ("NA", "BQ", "BES", 535, _("Bonaire, Sint Eustatius and Saba")),
    ("NA", "BS", "BHS", 44, _("Bahamas, Commonwealth of the")),
    ("NA", "BZ", "BLZ", 84, _("Belize")),
    ("NA", "CA", "CAN", 124, _("Canada")),
    ("NA", "CR", "CRI", 188, _("Costa Rica, Republic of")),
    ("NA", "CU", "CUB", 192, _("Cuba, Republic of")),
    ("NA", "CW", "CUW", 531, _("Curaçao")),
    ("NA", "DM", "DMA", 212, _("Dominica, Commonwealth of")),
    ("NA", "DO", "DOM", 214, _("Dominican Republic")),
    ("NA", "GD", "GRD", 308, _("Grenada")),
    ("NA", "GL", "GRL", 304, _("Greenland")),
    ("NA", "GP", "GLP", 312, _("Guadeloupe")),
    ("NA", "GT", "GTM", 320, _("Guatemala, Republic of")),
    ("NA", "HN", "HND", 340, _("Honduras, Republic of")),
    ("NA", "HT", "HTI", 332, _("Haiti, Republic of")),
    ("NA", "JM", "JAM", 388, _("Jamaica")),
    ("NA", "KN", "KNA", 659, _("Saint Kitts and Nevis, Federation of")),
    ("NA", "KY", "CYM", 136, _("Cayman Islands")),
    ("NA", "LC", "LCA", 662, _("Saint Lucia")),
    ("NA", "MF", "MAF", 663, _("Saint Martin")),
    ("NA", "MQ", "MTQ", 474, _("Martinique")),
    ("NA", "MS", "MSR", 500, _("Montserrat")),
    ("NA", "MX", "MEX", 484, _("Mexico, United Mexican States")),
    ("NA", "NI", "NIC", 558, _("Nicaragua, Republic of")),
    ("NA", "PA", "PAN", 591, _("Panama, Republic of")),
    ("NA", "PM", "SPM", 666, _("Saint Pierre and Miquelon")),
    ("NA", "PR", "PRI", 630, _("Puerto Rico, Commonwealth of")),
    ("NA", "SV", "SLV", 222, _("El Salvador, Republic of")),
    ("NA", "SX", "SXM", 534, _("Sint Maarten (Netherlands)")),
    ("NA", "TC", "TCA", 796, _("Turks and Caicos Islands")),
    ("NA", "TT", "TTO", 780, _("Trinidad and Tobago, Republic of")),
    ("NA", "UM", "UMI", 581, _("United States Minor Outlying Islands")),
    ("NA", "US", "USA", 840, _("United States")),
    ("NA", "VC", "VCT", 670, _("Saint Vincent and the Grenadines")),
    ("NA", "VG", "VGB", 92, _("British Virgin Islands")),
    ("NA", "VI", "VIR", 850, _("United States Virgin Islands")),
    ("OC", "AS", "ASM", 16, _("American Samoa")),
    ("OC", "AU", "AUS", 36, _("Australia, Commonwealth of")),
    ("OC", "CK", "COK", 184, _("Cook Islands")),
    ("OC", "FJ", "FJI", 242, _("Fiji, Republic of the Fiji Islands")),
    ("OC", "FM", "FSM", 583, _("Micronesia, Federated States of")),
    ("OC", "GU", "GUM", 316, _("Guam")),
    ("OC", "KI", "KIR", 296, _("Kiribati, Republic of")),
    ("OC", "MH", "MHL", 584, _("Marshall Islands, Republic of the")),
    (
        "OC", "MP", "MNP", 580,
        _("Northern Mariana Islands, Commonwealth of the")
    ),
    ("OC", "NC", "NCL", 540, _("New Caledonia")),
    ("OC", "NF", "NFK", 574, _("Norfolk Island")),
    ("OC", "NR", "NRU", 520, _("Nauru, Republic of")),
    ("OC", "NU", "NIU", 570, _("Niue")),
    ("OC", "NZ", "NZL", 554, _("New Zealand")),
    ("OC", "PF", "PYF", 258, _("French Polynesia")),
    ("OC", "PG", "PNG", 598, _("Papua New Guinea, Independent State of")),
    ("OC", "PN", "PCN", 612, _("Pitcairn Islands")),
    ("OC", "PW", "PLW", 585, _("Palau, Republic of")),
    ("OC", "SB", "SLB", 90, _("Solomon Islands")),
    ("OC", "TK", "TKL", 772, _("Tokelau")),
    ("OC", "TO", "TON", 776, _("Tonga, Kingdom of")),
    ("OC", "TV", "TUV", 798, _("Tuvalu")),
    ("OC", "VU", "VUT", 548, _("Vanuatu, Republic of")),
    ("OC", "WF", "WLF", 876, _("Wallis and Futuna")),
    ("OC", "WS", "WSM", 882, _("Samoa, Independent State of")),
    ("OC", "XX", None, None, _("Disputed Territory")),
    ("SA", "AR", "ARG", 32, _("Argentina, Argentine Republic")),
    ("SA", "BO", "BOL", 68, _("Bolivia, Republic of")),
    ("SA", "BR", "BRA", 76, _("Brazil, Federative Republic of")),
    ("SA", "CL", "CHL", 152, _("Chile, Republic of")),
    ("SA", "CO", "COL", 170, _("Colombia, Republic of")),
    ("SA", "EC", "ECU", 218, _("Ecuador, Republic of")),
    ("SA", "FK", "FLK", 238, _("Falkland Islands (Malvinas)")),
    ("SA", "GF", "GUF", 254, _("French Guiana")),
    ("SA", "GY", "GUY", 328, _("Guyana, Co-operative Republic of")),
    ("SA", "PE", "PER", 604, _("Peru, Republic of")),
    ("SA", "PY", "PRY", 600, _("Paraguay, Republic of")),
    ("SA", "SR", "SUR", 740, _("Suriname, Republic of")),
    ("SA", "UY", "URY", 858, _("Uruguay, Eastern Republic of")),
    ("SA", "VE", "VEN", 862, _("Venezuela, Bolivarian Republic of")),
)

COUNTRIES = [
    (c[1], c[4].partition(',')[0].partition('(')[0].strip())
    for c in COUNTRIES_RAW
]

CONTINENTS = (
    ('AF', _('Africa')),
    ('AN', _('Antarctica')),
    ('AS', _('Asia')),
    ('EU', _('Europe')),
    ('NA', _('North America')),
    ('OC', _('Oceania')),
    ('SA', _('South America')),
)

CURRENCIES = (
    ('USD', _('USD - United States Dollar')),
    ('AED', _('AED - United Arab Emirates Dirham')),
    ('AFN', _('AFN - Afghanistan Afghani')),
    ('ALL', _('ALL - Albania Lek')),
    ('AMD', _('AMD - Armenia Dram')),
    ('ANG', _('ANG - Netherlands Antilles Guilder')),
    ('AOA', _('AOA - Angola Kwanza')),
    ('ARS', _('ARS - Argentina Peso')),
    ('AUD', _('AUD - Australia Dollar')),
    ('AWG', _('AWG - Aruba Guilder')),
    ('AZN', _('AZN - Azerbaijan New Manat')),
    ('BAM', _('BAM - Bosnia and Herzegovina Convertible Marka')),
    ('BBD', _('BBD - Barbados Dollar')),
    ('BDT', _('BDT - Bangladesh Taka')),
    ('BGN', _('BGN - Bulgaria Lev')),
    ('BHD', _('BHD - Bahrain Dinar')),
    ('BIF', _('BIF - Burundi Franc')),
    ('BMD', _('BMD - Bermuda Dollar')),
    ('BND', _('BND - Brunei Darussalam Dollar')),
    ('BOB', _('BOB - Bolivia Boliviano')),
    ('BRL', _('BRL - Brazil Real')),
    ('BSD', _('BSD - Bahamas Dollar')),
    ('BTN', _('BTN - Bhutan Ngultrum')),
    ('BWP', _('BWP - Botswana Pula')),
    ('BYR', _('BYR - Belarus Ruble')),
    ('BZD', _('BZD - Belize Dollar')),
    ('CAD', _('CAD - Canada Dollar')),
    ('CDF', _('CDF - Congo/Kinshasa Franc')),
    ('CHF', _('CHF - Switzerland Franc')),
    ('CLP', _('CLP - Chile Peso')),
    ('CNY', _('CNY - China Yuan Renminbi')),
    ('COP', _('COP - Colombia Peso')),
    ('CRC', _('CRC - Costa Rica Colon')),
    ('CUC', _('CUC - Cuba Convertible Peso')),
    ('CUP', _('CUP - Cuba Peso')),
    ('CVE', _('CVE - Cape Verde Escudo')),
    ('CZK', _('CZK - Czech Republic Koruna')),
    ('DJF', _('DJF - Djibouti Franc')),
    ('DKK', _('DKK - Denmark Krone')),
    ('DOP', _('DOP - Dominican Republic Peso')),
    ('DZD', _('DZD - Algeria Dinar')),
    ('EGP', _('EGP - Egypt Pound')),
    ('ERN', _('ERN - Eritrea Nakfa')),
    ('ETB', _('ETB - Ethiopia Birr')),
    ('EUR', _('EUR - Euro Members')),
    ('FJD', _('FJD - Fiji Dollar')),
    ('FKP', _('FKP - Falkland Islands (Malvinas) Pound')),
    ('GBP', _('GBP - United Kingdom Pound')),
    ('GEL', _('GEL - Georgia Lari')),
    ('GGP', _('GGP - Guernsey Pound')),
    ('GHS', _('GHS - Ghana Cedi')),
    ('GIP', _('GIP - Gibraltar Pound')),
    ('GMD', _('GMD - Gambia Dalasi')),
    ('GNF', _('GNF - Guinea Franc')),
    ('GTQ', _('GTQ - Guatemala Quetzal')),
    ('GYD', _('GYD - Guyana Dollar')),
    ('HKD', _('HKD - Hong Kong Dollar')),
    ('HNL', _('HNL - Honduras Lempira')),
    ('HRK', _('HRK - Croatia Kuna')),
    ('HTG', _('HTG - Haiti Gourde')),
    ('HUF', _('HUF - Hungary Forint')),
    ('IDR', _('IDR - Indonesia Rupiah')),
    ('ILS', _('ILS - Israel Shekel')),
    ('IMP', _('IMP - Isle of Man Pound')),
    ('INR', _('INR - India Rupee')),
    ('IQD', _('IQD - Iraq Dinar')),
    ('IRR', _('IRR - Iran Rial')),
    ('ISK', _('ISK - Iceland Krona')),
    ('JEP', _('JEP - Jersey Pound')),
    ('JMD', _('JMD - Jamaica Dollar')),
    ('JOD', _('JOD - Jordan Dinar')),
    ('JPY', _('JPY - Japan Yen')),
    ('KES', _('KES - Kenya Shilling')),
    ('KGS', _('KGS - Kyrgyzstan Som')),
    ('KHR', _('KHR - Cambodia Riel')),
    ('KMF', _('KMF - Comoros Franc')),
    ('KPW', _('KPW - Korea (North) Won')),
    ('KRW', _('KRW - Korea (South) Won')),
    ('KWD', _('KWD - Kuwait Dinar')),
    ('KYD', _('KYD - Cayman Islands Dollar')),
    ('KZT', _('KZT - Kazakhstan Tenge')),
    ('LAK', _('LAK - Laos Kip')),
    ('LBP', _('LBP - Lebanon Pound')),
    ('LKR', _('LKR - Sri Lanka Rupee')),
    ('LRD', _('LRD - Liberia Dollar')),
    ('LSL', _('LSL - Lesotho Loti')),
    ('LTL', _('LTL - Lithuania Litas')),
    ('LVL', _('LVL - Latvia Lat')),
    ('LYD', _('LYD - Libya Dinar')),
    ('MAD', _('MAD - Morocco Dirham')),
    ('MDL', _('MDL - Moldova Le')),
    ('MGA', _('MGA - Madagascar Ariary')),
    ('MKD', _('MKD - Macedonia Denar')),
    ('MMK', _('MMK - Myanmar (Burma) Kyat')),
    ('MNT', _('MNT - Mongolia Tughrik')),
    ('MOP', _('MOP - Macau Pataca')),
    ('MRO', _('MRO - Mauritania Ouguiya')),
    ('MUR', _('MUR - Mauritius Rupee')),
    ('MVR', _('MVR - Maldives (Maldive Islands) Rufiyaa')),
    ('MWK', _('MWK - Malawi Kwacha')),
    ('MXN', _('MXN - Mexico Peso')),
    ('MYR', _('MYR - Malaysia Ringgit')),
    ('MZN', _('MZN - Mozambique Metical')),
    ('NAD', _('NAD - Namibia Dollar')),
    ('NGN', _('NGN - Nigeria Naira')),
    ('NIO', _('NIO - Nicaragua Cordoba')),
    ('NOK', _('NOK - Norway Krone')),
    ('NPR', _('NPR - Nepal Rupee')),
    ('NZD', _('NZD - New Zealand Dollar')),
    ('OMR', _('OMR - Oman Rial')),
    ('PAB', _('PAB - Panama Balboa')),
    ('PEN', _('PEN - Peru Nuevo Sol')),
    ('PGK', _('PGK - Papua New Guinea Kina')),
    ('PHP', _('PHP - Philippines Peso')),
    ('PKR', _('PKR - Pakistan Rupee')),
    ('PLN', _('PLN - Poland Zloty')),
    ('PYG', _('PYG - Paraguay Guarani')),
    ('QAR', _('QAR - Qatar Riyal')),
    ('RON', _('RON - Romania New Le')),
    ('RSD', _('RSD - Serbia Dinar')),
    ('RUB', _('RUB - Russia Ruble')),
    ('RWF', _('RWF - Rwanda Franc')),
    ('SAR', _('SAR - Saudi Arabia Riyal')),
    ('SBD', _('SBD - Solomon Islands Dollar')),
    ('SCR', _('SCR - Seychelles Rupee')),
    ('SDG', _('SDG - Sudan Pound')),
    ('SEK', _('SEK - Sweden Krona')),
    ('SGD', _('SGD - Singapore Dollar')),
    ('SHP', _('SHP - Saint Helena Pound')),
    ('SLL', _('SLL - Sierra Leone Leone')),
    ('SOS', _('SOS - Somalia Shilling')),
    ('SPL', _('SPL - Seborga Luigino')),
    ('SRD', _('SRD - Suriname Dollar')),
    ('STD', _('STD - São Tomé and Príncipe Dobra')),
    ('SVC', _('SVC - El Salvador Colon')),
    ('SYP', _('SYP - Syria Pound')),
    ('SZL', _('SZL - Swaziland Lilangeni')),
    ('THB', _('THB - Thailand Baht')),
    ('TJS', _('TJS - Tajikistan Somoni')),
    ('TMT', _('TMT - Turkmenistan Manat')),
    ('TND', _('TND - Tunisia Dinar')),
    ('TOP', _("TOP - Tonga Pa'anga")),
    ('TRY', _('TRY - Turkey Lira')),
    ('TTD', _('TTD - Trinidad and Tobago Dollar')),
    ('TVD', _('TVD - Tuvalu Dollar')),
    ('TWD', _('TWD - Taiwan New Dollar')),
    ('TZS', _('TZS - Tanzania Shilling')),
    ('UAH', _('UAH - Ukraine Hryvna')),
    ('UGX', _('UGX - Uganda Shilling')),
    ('UYU', _('UYU - Uruguay Peso')),
    ('UZS', _('UZS - Uzbekistan Som')),
    ('VEF', _('VEF - Venezuela Bolivar')),
    ('VND', _('VND - Viet Nam Dong')),
    ('VUV', _('VUV - Vanuatu Vat')),
    ('WST', _('WST - Samoa Tala')),
    ('XAF', _('XAF - Communauté Financière Africaine (BEAC) CFA Franc BEAC')),
    ('XCD', _('XCD - East Caribbean Dollar')),
    (
        'XDR',
        _('XDR - International Monetary Fund (IMF) Special Drawing Rights')
    ),
    ('XOF', _('XOF - Communauté Financière Africaine (BCEAO) Franc')),
    ('XPF', _('XPF - Comptoirs Français du Pacifique (CFP) Franc')),
    ('YER', _('YER - Yemen Rial')),
    ('ZAR', _('ZAR - South Africa Rand')),
    ('ZMK', _('ZMK - Zambia Kwacha')),
    ('ZWD', _('ZWD - Zimbabwe Dollar')),
)


def build_languages():
    languages = []
    languages_native = []
    languages_english = []

    if not babel:  # pragma: no cover
        return languages, languages_native, languages_english

    locales = babel.localedata.locale_identifiers()
    locales.sort()
    for l_id in locales:
        locale = babel.Locale(l_id)
        if locale.english_name:
            languages_english.append((l_id, _(locale.english_name)))
            if locale.display_name:
                languages_native.append((l_id, locale.display_name))

                if locale.display_name == locale.english_name:
                    label = '{0}'.format(locale.english_name)
                else:
                    label = '{0} ({1})'.format(
                        locale.display_name,
                        locale.english_name
                    )
                languages.append((l_id, label))
    return languages, languages_native, languages_english

LANGUAGES, LANGUAGES_NATIVE, LANGUAGES_ENGLISH = build_languages()


class Country(models.Model):
    """
    Country model
    =============

    Stores 2-letter ISO country code 2-letter continent code
    """

    code = models.CharField(
        _('country'),
        max_length=2,
        choices=COUNTRIES,
        unique=True
    )
    continent = models.CharField(
        _('continent'),
        max_length=2,
        choices=CONTINENTS
    )

    def __unicode__(self):  # pragma: no cover
        return self.get_code_display()

    def __str__(self):  # pragma: no cover
        return self.get_code_display()

    class Meta:
        verbose_name = _('country')
        verbose_name_plural = _('countries')
