Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions app/utils/countrycodes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Default country code.
default_code = "XX"

# Mapping of country names to alpha-2 codes.
# Mapping of country names to alpha-2 codes according to
# https://en.wikipedia.org/wiki/ISO_3166-1.
# As a reference see also https://github.com/TakahikoKawasaki/nv-i18n (in Java)
is_3166_1 = {
"Afghanistan" : "AF",
"Åland Islands" : "AX",
Expand Down Expand Up @@ -122,8 +124,7 @@
"Kiribati" : "KI",
"Korea, Democratic People's Republic of" : "KP",
"Korea, Republic of" : "KR",
# Introducing Kosovo may be controversial. I guess we need to bite the bullet.
"Kosovo" : "XK",
"Kosovo, Republic of" : "XK",
"Kuwait" : "KW",
"Kyrgyzstan" : "KG",
"Lao People's Democratic Republic" : "LA",
Expand Down Expand Up @@ -218,7 +219,7 @@
"Sudan" : "SD",
"Suriname" : "SR",
"Svalbard and Jan Mayen" : "SJ",
"Swaziland" : "SZ",
"Eswatini" : "SZ", # previous name "Swaziland"
"Sweden" : "SE",
"Switzerland" : "CH",
"Syrian Arab Republic" : "SY",
Expand Down Expand Up @@ -254,6 +255,16 @@
"Yemen" : "YE",
"Zambia" : "ZM",
"Zimbabwe" : "ZW",

# see also
# https://en.wikipedia.org/wiki/List_of_sovereign_states_and_dependent_territories_by_continent_(data_file)#Data_file
# https://en.wikipedia.org/wiki/List_of_sovereign_states_and_dependent_territories_by_continent
"United Nations Neutral Zone" : "XD",
"Iraq-Saudi Arabia Neutral Zone" : "XE",
"Spratly Islands" : "XS",

# TODO "Disputed Territory" conflicts with `default_code`
# "Disputed Territory" : "XX",
}

# Mapping of alternative names, spelling, typos to the names of countries used
Expand Down Expand Up @@ -340,6 +351,9 @@
"Deutschland" : "Germany",
"The Bahamas" : "Bahamas",
"The Gambia" : "Gambia",
"Kosovo" : "Kosovo, Republic of",
"Swaziland" : "Eswatini",
"Gambia, The" : "Gambia",
# "Others" has no mapping, i.e. the default val is used
# "Cruise Ship" has no mapping, i.e. the default val is used
}
Expand Down