Skip to content

Commit 8293d18

Browse files
authored
Merge pull request #79 from Bost/master
Countries and aliases
2 parents 09f3d3e + ca999cf commit 8293d18

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

app/utils/countrycodes.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Default country code.
22
default_code = "XX"
33

4-
# Mapping of country names to alpha-2 codes.
4+
# Mapping of country names to alpha-2 codes according to
5+
# https://en.wikipedia.org/wiki/ISO_3166-1.
6+
# As a reference see also https://github.com/TakahikoKawasaki/nv-i18n (in Java)
57
is_3166_1 = {
68
"Afghanistan" : "AF",
79
"Åland Islands" : "AX",
@@ -122,8 +124,7 @@
122124
"Kiribati" : "KI",
123125
"Korea, Democratic People's Republic of" : "KP",
124126
"Korea, Republic of" : "KR",
125-
# Introducing Kosovo may be controversial. I guess we need to bite the bullet.
126-
"Kosovo" : "XK",
127+
"Kosovo, Republic of" : "XK",
127128
"Kuwait" : "KW",
128129
"Kyrgyzstan" : "KG",
129130
"Lao People's Democratic Republic" : "LA",
@@ -218,7 +219,7 @@
218219
"Sudan" : "SD",
219220
"Suriname" : "SR",
220221
"Svalbard and Jan Mayen" : "SJ",
221-
"Swaziland" : "SZ",
222+
"Eswatini" : "SZ", # previous name "Swaziland"
222223
"Sweden" : "SE",
223224
"Switzerland" : "CH",
224225
"Syrian Arab Republic" : "SY",
@@ -254,6 +255,16 @@
254255
"Yemen" : "YE",
255256
"Zambia" : "ZM",
256257
"Zimbabwe" : "ZW",
258+
259+
# see also
260+
# https://en.wikipedia.org/wiki/List_of_sovereign_states_and_dependent_territories_by_continent_(data_file)#Data_file
261+
# https://en.wikipedia.org/wiki/List_of_sovereign_states_and_dependent_territories_by_continent
262+
"United Nations Neutral Zone" : "XD",
263+
"Iraq-Saudi Arabia Neutral Zone" : "XE",
264+
"Spratly Islands" : "XS",
265+
266+
# TODO "Disputed Territory" conflicts with `default_code`
267+
# "Disputed Territory" : "XX",
257268
}
258269

259270
# Mapping of alternative names, spelling, typos to the names of countries used
@@ -340,6 +351,9 @@
340351
"Deutschland" : "Germany",
341352
"The Bahamas" : "Bahamas",
342353
"The Gambia" : "Gambia",
354+
"Kosovo" : "Kosovo, Republic of",
355+
"Swaziland" : "Eswatini",
356+
"Gambia, The" : "Gambia",
343357
# "Others" has no mapping, i.e. the default val is used
344358
# "Cruise Ship" has no mapping, i.e. the default val is used
345359
}

0 commit comments

Comments
 (0)