(* ********************************************************************* Address Book - check and fix country names & country codes This script will go through your Address Book and do two things: 1) standardize the country name (e.g. United States, instead of USA, United States of America, etc.); 2) add the country code for the each address, this will make sure the address is displayed properly. ********************************************************************* Winfred van Kuijk - http://winfred.vankuijk.net/2010/01/fixing-countries-in-address-book/ v1.0, 2010/01/03, initial release v1.1, 2010/01/04, added result display options, added ability to run as Address Book plugin, Growl support v1.2, 2010/01/10, added support for all known iso countries, write results to log file for easy copy/paste v1.2.1, 2010/01/11, small Growl fix for non-Growl users v1.2.2, 2010/01/12, leave iso code empty in lookup list to overwrite Apple's format + check small countries if not in large country list v1.3, 2010/01/12, added support for optional checking of latest version instructions ----------------- - use as address book plug-in: install in /Library/Address Book Plug-Ins or ~/Library/Address Book Plug-Ins - or run as standalone script - important: modify the sections between #### ... #### this specifies what your country lookup table should look like, and if you see a summary at the end, etc. - format of mycountries table: iso code, your preferred country name, aliases - when running as plug-in, if you change e.g. "I_am_ready" or "plugin_only_selected": restart Address Book Just in case: make sure you have a recent backup of your Address Book, e.g. Time Capsule or manual (File -> Export... -> Address Book Archive...) *) property current_version : "1.3" -- ########################################################## <<<<< EDIT FROM HERE vvvvvvv property I_am_ready : false -- change this one after you have updated the country codes below, script will only run when "true" property show_results : false -- optional: show summary after running the script property check_for_updates : false -- optional: will check to see if there is an updated version of the script -- I have show_results and check_for_updates normally set to "true", but that's completely up to you :-) property plugin_only_selected : false -- when using as plug-in: only update selected person or run for every person? -- ########################################################## <<<<< EDIT TO HERE ^^^^^ global include_iso, testing, fill_empty_country, default_country, use_growl global mycountries, big_iso_countries, small_iso_countries, log_unknown, log_missing global changes_country, changes_code, names_checked, addresses_checked global list_of_isocodes, list_of_countries, list_of_aliases, list_of_missing_countries, list_of_unknown_countries --------------------------------------------------------------------------------------- -- both standalone script and plug-in will use this as the starting subroutine on country_name_code(LocalPeople) --------------------------------------------------------------------------------------- -- create list of countries -- mycountries: list of records {i,{p[,a]} - iso code, *preferred country name*, 0 or more aliases set mycountries to {} set clist to a reference to mycountries -- ########################################################## <<<<< EDIT FROM HERE vvvvvvv -- ---------- update the list below to contain all the countries you are interested in --------------------- -- format of list: {isocode, {list of preferred name and -if applicable- aliases}} -- the first country name is the preferred name, this can be in your local language if you want -- you only need to add countries here if you want to a) use a non-iso name and/or b) if you want to add aliases -- the iso names can be found at the bottom of the script copy {"nl", {"Netherlands", "Nederland", "the Netherlands", "NL"}} to end of clist copy {"be", {"Belgium", "België", "Belgique"}} to end of clist -- I like to use the English name for this country copy {"de", {"Deutschland", "Germany"}} to end of clist -- I like to use the German name for this country copy {"gb", {"United Kingdom", "UK"}} to end of clist copy {"us", {"United States", "USA", "US", "United States of America", "Estados Unidos"}} to end of clist copy {"fr", {"France"}} to end of clist -- example of country with no aliases, only needed if not loading iso list copy {"ve", {"Venezuela"}} to end of clist -- example of overwriting the standard name from the iso list copy {"", {"Chile"}} to end of clist -- example: I don't like Apple's Chile format, leave iso code empty for default country format --copy {"??", {"Luxembourg"}} to end of clist -- incorrect, iso code is incorrect -- add as many lines as you like... (and remove the ones you don't need) -- ########################################################## <<<<< EDIT TO HERE ^^^^^ -- ########################################################## <<<<< EDIT FROM HERE vvvvvvv -- these settings can normally be left alone set fill_empty_country to false -- should we fill addresses that have empty country fields with a default name? set default_country to "Netherlands" -- if the country name field is empty for a contact, what country should be used? set testing to false -- change this if you only want to modify cards that have last name "testing" (see vcard download) -- ########################################################## <<<<< EDIT TO HERE ^^^^^ if check_for_updates then set lets_get_new_version to check_latest_version(current_version) -- will show popup if there is a newer version if lets_get_new_version then return -- let's stop if the user wanted to open the browser to download the latest version end if if (I_am_ready is not true) then display dialog "Please update the settings before you run this script. I would like to make sure you have the country settings that you prefer. " & return & return & "After changing: restart Address Book." & return & return & "And just in case: did you already create a backup?" with title "First check the settings" with icon stop buttons "Abort" return -- abort end if (* workflow of script ----------------- - create list of countries: iso codes, preferred names and aliases (e.g.: iso = us, preferred = United States, aliases = USA, United States of America, etc.) - part 1: use the custom list provided by the user - part 2: add countries from the iso list (if not already in the list) - create lookup lists for the iso codes, preferred and all country names - go through each person - go through each address for that person - optional: if the address is there, but the country is empty, use the default country name - if the country is in the alias list: make sure the preferred country name and iso code are used *) tell current application to set startTime to (get current date) -- make preparations for Growl (http://www.growl.info) prepare_growl() -- use_growl is set if Growl is running send_growl_msg("Starting plug-in", "Now checking+fixing country names and codes.") load_iso_country_list() -- reads the iso country list -- for statistics at the end set changes_country to 0 set changes_code to 0 set names_checked to 0 set addresses_checked to 0 set list_of_countries to {} set list_of_aliases to {} set list_of_isocodes to {} set list_of_missing_countries to {} -- will be filled with names that have address without country set list_of_unknown_countries to {} -- will be filled with countries not in the lookup table set log_missing to "" -- will be filled with script-ready table based on unknown countries (alternative to list above) set log_unknown to "" -- will be filled with script-ready table based on unknown countries (alternative to list above) set locref to a reference to list_of_countries set loaref to a reference to list_of_aliases set loiref to a reference to list_of_isocodes -- to speed up lookup: extract data from the list of lists -- list_of_countries: all official/preferred country names -- list_of_aliases: all official/preferred country names *and* alias(es) -- list_of_isocodes: all iso codes repeat with mycountry in mycountries set myiso to item 1 of mycountry -- the iso code set calist to item 2 of mycountry -- preferred country name + any (optional) aliases set myc to item 1 of calist -- preferred country name if (myiso is not "??") and (myiso is not "") and (myiso is not in loiref) then -- ignore the record if the iso code is "??" set end of loiref to myiso set end of locref to myc repeat with myca in calist set end of loaref to contents of myca end repeat end if end repeat (* log "List of iso codes to look out for:" & (count (list_of_isocodes)) log list_of_isocodes log "List of countries to look out for:" & (count (list_of_countries)) log list_of_countries log "List of countries + aliases to look out for:" & (count (list_of_aliases)) log list_of_aliases *) -- example: lookup an alias or preferred country name, return iso and preferred name --set {myi, myc} to my find_iso_code_in_country_list("USA") --------------------------------------------------------------------------------------- -- load the records from Address Book in variable LocalPeople tell application "Address Book" -- if this subroutine is called from the application, then LocalPeople is empty -- if it is called as plugin, it could be set to the selected address if (count of LocalPeople) = 0 then if (testing is true) then log "*** only cards with last name 'testing' will be checked and updated ***" set LocalPeople to (get every person where the last name is "testing") -- testing names else set LocalPeople to (get every person) end if end if log "Processing " & (count of LocalPeople) & " persons" end tell --------------------------------------------------------------------------------------- -- ### optional: call subroutine to find all the countries in the address book ### -- can help to identify which countries should be added to the iso list --choose from list my list_of_countries_in_address_book(LocalPeople) with title "Countries in Address Book" with prompt "" --return -- in that case, you can stop here if you want to --------------------------------------------------------------------------------------- -- call the main subroutine check_and_fix_country_name_and_code(LocalPeople) tell current application to set endTime to (get current date) set duration to endTime - startTime set summary to "names checked: " & names_checked & return & ¬ "addresses checked: " & addresses_checked & return & return & ¬ "countries updated: " & changes_country & return & ¬ "country codes updated: " & changes_code & return & ¬ "countries in list: " & (count list_of_countries) & return & ¬ "countries not in list: " & (count list_of_unknown_countries) & return & return & ¬ "process took " & duration & " seconds." log summary if (use_growl) then send_growl_msg("Summary of results", summary) if (show_results is false) and ((count list_of_unknown_countries) > 0) then send_growl_msg("Additional details", "enable show_results variable to see list of " & (count list_of_unknown_countries) & " missing countries") end if end if if (show_results is true) then if ((count list_of_missing_countries) > 0) or ((count list_of_unknown_countries) > 0) then write_log_to_file() end if if (not use_growl) then -- not using Growl, then only show if show_results was set display dialog summary with title "Country names + codes fixed" buttons "Ok" end if end if end country_name_code --------------------------------------------------------------------------------------- -- this is the entry point when script is run standalone, for plug-in entry: see bottom on run country_name_code({}) -- {} means: leave empty, the subroutine will then fill it later end run -------------------------------------------------------------------------------------------------------------------- -- subroutines -------------------------------------------------------------------------------------------------------------------- on list_of_countries_in_address_book(LocalPeople) set list_of_countries to {} tell application "Address Book" repeat with thePerson in LocalPeople repeat with theAddress in the address of thePerson set theCountry to get the country of theAddress if (theCountry is not missing value) and (theCountry is not in list_of_countries) then set end of list_of_countries to theCountry end if end repeat end repeat end tell log "Countries in address book: " log list_of_countries return list_of_countries end list_of_countries_in_address_book -------------------------------------------------------------------------------------------------------------------- on find_iso_code_in_country_list(country_alias, list_to_check) repeat with mycountry in list_to_check set myi to item 1 of mycountry set myca to item 2 of mycountry -- mycountry list format {iso,{country/countries}} -- big/small_iso_countries list format {iso, country} if class of myca is list then set myc to item 1 of myca else set myc to myca end if if country_alias is in myca then --log " looking for: " & country_alias & ", found: " & myi & " = " & myc return {myi, myc} end if end repeat -- if the country is not found return {"??", country_alias} end find_iso_code_in_country_list -------------------------------------------------------------------------------------------------------------------- on check_and_fix_country_name_and_code(LocalPeople) tell application "Address Book" repeat with thePerson in LocalPeople set changes_made to 0 set theName to the name of thePerson as string repeat with theAddress in the address of thePerson set theAddressType to label of theAddress set message_str to theName & " (" & theAddressType & ")" set theCountry to (get the country of theAddress) set theCountryCode to (get the country code of theAddress) if (theCountry is missing value) then if (fill_empty_country) then --log " country is missing, set to default country: " & default_country set the country of theAddress to default_country set changes_made to changes_made + 1 else --log " country is missing, but -per user setting- not changing to " & default_country if (show_results is true) then set end of list_of_missing_countries to message_str set log_missing to log_missing & message_str & return end if end if end if set country_is_in_alias_list to false if (theCountry is in list_of_aliases) then set country_is_in_alias_list to true (* if (country_is_in_alias_list) then --log " " & theCountry & " is in list_of_aliases" else --log " " & theCountry & " is *not* in list_of_aliases" end if *) if (theCountry is not missing value) and (country_is_in_alias_list is not true) then -- Could not find country in my list, let's see if it is in the official iso list and if so: add to my list -- the official iso list is broken up in two parts: large countries and small countries -- this to speed up the search. -- Still treat it as an "unknown" country, as it makes the script much faster if we do not have to do this fallback search --log message_str & ": can not find country " & theCountry & " in my list" set iso to "??" log message_str & "searching in large country list" set {iso, preferred} to my find_iso_code_in_country_list(theCountry, big_iso_countries) if (iso is "??") then -- could not find it in the list of large countries, let's try the small ones log message_str & "searching in small country list" set {iso, preferred} to my find_iso_code_in_country_list(theCountry, small_iso_countries) end if if (iso is not "??") then log " found in iso list: " & iso set end of list_of_aliases to theCountry set end of mycountries to {iso, {preferred}} end if set end of list_of_unknown_countries to theCountry set log_unknown to log_unknown & "copy {\"" & iso & "\", {\"" & theCountry & "\"}} to end of clist" & return log message_str & ": unknown country " & theCountry & " (" & iso & ")" end if if (theCountry is not missing value) and (country_is_in_alias_list is true) then --log " country is " & theCountry & ", check if it is the preferred name" set {iso, preferred} to my find_iso_code_in_country_list(theCountry, mycountries) if (iso is "") then set iso to the default country code -- this way you can overwrite the country code from the iso list if (theCountry is not preferred) then --log " preferred name for " & theCountry & " is: " & preferred set the country of theAddress to preferred set changes_country to changes_country + 1 set changes_made to changes_made + 1 end if if (iso is not "??") and ((theCountryCode is missing value) or (theCountryCode is not iso)) then --log message_str --log " country code for " & theCountry & " was " & theCountryCode & ", should be: " & iso set the country code of theAddress to iso set changes_made to changes_made + 1 set changes_code to changes_code + 1 else if ((theCountryCode is iso) and (theCountry is not preferred)) then -- this means: actual country name is not the preferred one -- leave it like that, up to the user to change in country list end if else --log " skipping, country is missing or not in lookup table: " & theCountry end if if (changes_made > 0) then log "made changes to " & theName & " (" & theAddressType & ")" save end if --for testing: to reset everything to old situation --set the country code of theAddress to missing value -- iso set addresses_checked to addresses_checked + 1 end repeat -- loop of addresses for a person set names_checked to names_checked + 1 end repeat -- loop of persons save -- already did a save after each change, but just in case end tell end check_and_fix_country_name_and_code -------------------------------------------------------------------------------------------------------------------- on prepare_growl() tell application "System Events" to set use_growl to exists application process "GrowlHelperApp" if (not use_growl) then return tell application "GrowlHelperApp" set the allNotificationsList to {"Summary of results"} set the enabledNotificationsList to allNotificationsList register as application ¬ "Address Book country name plug-in" all notifications allNotificationsList ¬ default notifications enabledNotificationsList ¬ icon of application "Address Book" end tell end prepare_growl on send_growl_msg(desc, msg) if (use_growl) then try tell application "GrowlHelperApp" notify with name ¬ "Summary of results" title ¬ desc description ¬ msg application name "Address Book country name plug-in" end tell end try end if end send_growl_msg -------------------------------------------------------------------------------------------------------------------- on check_latest_version(current_version) set myurl to "http://winfred.vankuijk.net/wp-content/uploads/latest_version_address_book_plugin.txt?" & current_version -- try to get the url with built in curl command, spend a maximum of 3 seconds to get it set mycmd to "/usr/bin/curl --fail --max-time 3 --output - " & myurl & " 2> /dev/null" set myloc to "http://winfred.vankuijk.net/2010/01/fixing-countries-in-address-book/#download" try set myoutput to do shell script mycmd on error -- could not check the latest version, will skip and go back to regular programme... return false end try set {latest_version, version_date, version_description} to parse_version_output(myoutput) if (current_version < latest_version) then try set open_site to display dialog "New version available: " & latest_version & ¬ " (" & version_date & ")" & return & "You have version: " & current_version & return & return & ¬ "New in this release: " & version_description & return & return & "Go to site?" buttons {"Skip", "Yes"} ¬ default button "Yes" giving up after 20 with title "New version of plug-in available" on error return false -- user pressed Skip end try if button returned of open_site is "Yes" then try tell application "System Events" to open location myloc -- open in default browser on error return false end try return true -- if we arrive here: we opened the browser, user is going to download end if end if -- compare current_version to latest_version return false -- if we arrive here: we already have latest version end check_latest_version on parse_version_output(output) set savedDelimiters to AppleScript's text item delimiters try set AppleScript's text item delimiters to {"|"} -- output looks like "1.2.3|2010/01/12|what is new" set {myversion, mydate, mydesc} to text items of output on error set AppleScript's text item delimiters to savedDelimiters end try set AppleScript's text item delimiters to savedDelimiters -- reset the delimiter to the original state return {myversion, mydate, mydesc} end parse_version_output -------------------------------------------------------------------------------------------------------------------- on write_log_to_file() set mypath to (path to me) set the_content to "-- *** Address Book country names plugin ***" & return & return if (count list_of_unknown_countries) > 0 then set the_content to the_content & ¬ ("-- unknown countries in address book" & return & ¬ "--------------------------------------------------------------------" & return & ¬ "-- modify the list below: " & return & ¬ "-- 1) if missing, add the official iso code (e.g. us, nl, fr, gb)" & return & ¬ "-- if not missing: then it is not mandatory," & return & ¬ "-- but you will get faster results if you add the row" & return & ¬ "-- 2) start with your preferred country name and add any aliases" & return & ¬ "-- e.g. {\"de\", {\"Deutschland\",\"Germany\"}} -- prefer local spelling" & return & ¬ "-- e.g. {\"es\", {\"Spain\",\"Spaain\"}} -- will fix incorrect spelling" & return & ¬ return & ¬ "-- ##### start of list [copy lines below] ####################" & return & ¬ log_unknown & ¬ "-- ##### end of list [copy lines above] ####################" & return & ¬ return & ¬ "-- add the result to the following file and restart Address Book: " & return & ¬ "-- " & (POSIX path of mypath) & return & ¬ return) end if if (count list_of_missing_countries) > 0 then set the_content to the_content & ¬ ("(*" & return & ¬ "FYI: address is available, but country is missing" & return & ¬ "(which is fine, however for missing countries the default format will be used)" & return & ¬ "--------------------------------------------------------------------" & return & ¬ log_missing & ¬ "*)") end if set the_file to (((path to desktop) as string) & "Address Book countries plug-in.txt") set fp to open for access the_file with write permission try set eof fp to 0 write the_content to fp end try close access fp tell application "TextEdit" to open alias the_file end write_log_to_file -------------------------------------------------------------------------------------------------------------------- -- settings for the address-book plug-in -- to use: install in /Library/Address Book Plug-Ins or ~/Library/Address Book Plug-Ins using terms from application "Address Book" on action property return "address" end action property on should enable action for thePerson with theEntry return true end should enable action on action title for thePerson with theEntry if plugin_only_selected is true then return "Check country name and code" else return "Check all country names and codes" end if end action title on perform action for thePerson with theEntry if plugin_only_selected is true then country_name_code(thePerson) -- only pass this person to the subroutine else country_name_code({}) -- {} means: leave empty, the subroutine will fill it later (with all persons) end if end perform action end using terms from -------------------------------------------------------------------------------------------------------------------- -- load all iso countries on merge_with_iso_country_list() -- this subroutine will only be called if include_iso is set to true, default is false -- use with care, a very long list will make the script very slow set include_iso to false -- include all 154 countries in country lookup list, will slow things down significantly set clistref to a reference to mycountries set ilistref to a reference to big_iso_countries -- create quick lookup of iso codes in my country table, so we know if an iso code is missing set myisolist to {} repeat with myc in mycountries set thisiso to item 1 of myc if thisiso is not in myisolist then set end of myisolist to thisiso end if end repeat -- go through official iso countries, if it is not in my list, add to it repeat with iso_country in all_iso -- shortcut for doing all of them --repeat with i from 1 to this_many --set iso_country to item i of all_iso set iso to item 1 of iso_country -- official iso code set official to item 2 of iso_country -- official country name if iso is not in myisolist then set counter to counter + 1 set end of clistref to {iso, {official}} if counter = this_many then exit repeat end if end repeat -- result: first my countries (+aliases) plus "this_many" other countries end merge_with_iso_country_list on load_iso_country_list() -- following list is from: http://www.iso.org/iso/english_country_names_and_code_elements -- list is broken up in two parts to speed up the search. first search the large countries if that fails: search the small ones. -- 154 large countries (population > 1 million) set big_iso_countries to {{"af", "Afghanistan"}, {"al", "Albania"}, {"dz", "Algeria"}, {"ao", "Angola"}, {"ar", "Argentina"}, {"am", "Armenia"}, {"au", "Australia"}, {"at", "Austria"}, {"az", "Azerbaijan"}, {"bd", "Bangladesh"}, {"by", "Belarus"}, {"be", "Belgium"}, {"bj", "Benin"}, {"bo", "Bolivia, Plurinational State Of"}, {"ba", "Bosnia and Herzegovina"}, {"bw", "Botswana"}, {"br", "Brazil"}, {"bg", "Bulgaria"}, {"bf", "Burkina Faso"}, {"bi", "Burundi"}, {"kh", "Cambodia"}, {"cm", "Cameroon"}, {"ca", "Canada"}, {"cf", "Central African Republic"}, {"td", "Chad"}, {"cl", "Chile"}, {"cn", "China"}, {"co", "Colombia"}, {"cd", "Congo, the Democratic Republic of The"}, {"cr", "Costa Rica"}, {"ci", "Côte d'Ivoire"}, {"hr", "Croatia"}, {"cu", "Cuba"}, {"cz", "Czech Republic"}, {"dk", "Denmark"}, {"do", "Dominican Republic"}, {"ec", "Ecuador"}, {"eg", "Egypt"}, {"sv", "El Salvador"}, {"er", "Eritrea"}, {"ee", "Estonia"}, {"et", "Ethiopia"}, {"fi", "Finland"}, {"fr", "France"}, {"gf", "French Guiana"}, {"ga", "Gabon"}, {"gm", "Gambia"}, {"ge", "Georgia"}, {"de", "Germany"}, {"gh", "Ghana"}, {"gr", "Greece"}, {"gt", "Guatemala"}, {"gn", "Guinea"}, {"gw", "Guinea-Bissau"}, {"ht", "Haiti"}, {"hn", "Honduras"}, {"hk", "Hong Kong"}, {"hu", "Hungary"}, {"in", "India"}, {"id", "Indonesia"}, {"ir", "Iran, Islamic Republic Of"}, {"iq", "Iraq"}, {"ie", "Ireland"}, {"il", "Israel"}, {"it", "Italy"}, {"jm", "Jamaica"}, {"jp", "Japan"}, {"jo", "Jordan"}, {"kz", "Kazakhstan"}, {"ke", "Kenya"}, {"kp", "Korea, Democratic People's Republic Of"}, {"kr", "Korea, Republic Of"}, {"kw", "Kuwait"}, {"kg", "Kyrgyzstan"}, {"lv", "Latvia"}, {"lb", "Lebanon"}, {"ls", "Lesotho"}, {"lr", "Liberia"}, {"ly", "Libyan Arab Jamahiriya"}, {"lt", "Lithuania"}, {"mk", "Macedonia, the Former Yugoslav Republic Of"}, {"mg", "Madagascar"}, {"mw", "Malawi"}, {"my", "Malaysia"}, {"ml", "Mali"}, {"mr", "Mauritania"}, {"mu", "Mauritius"}, {"mx", "Mexico"}, {"md", "Moldova, Republic Of"}, {"mn", "Mongolia"}, {"ma", "Morocco"}, {"mz", "Mozambique"}, {"mm", "Myanmar"}, {"na", "Namibia"}, {"np", "Nepal"}, {"nl", "Netherlands"}, {"nz", "New Zealand"}, {"ni", "Nicaragua"}, {"ne", "Niger"}, {"ng", "Nigeria"}, {"no", "Norway"}, {"om", "Oman"}, {"pk", "Pakistan"}, {"ps", "Palestinian Territory, Occupied"}, {"pa", "Panama"}, {"pg", "Papua New Guinea"}, {"py", "Paraguay"}, {"pe", "Peru"}, {"ph", "Philippines"}, {"pl", "Poland"}, {"pt", "Portugal"}, {"pr", "Puerto Rico"}, {"qa", "Qatar"}, {"ro", "Romania"}, {"ru", "Russian Federation"}, {"rw", "Rwanda"}, {"sa", "Saudi Arabia"}, {"sn", "Senegal"}, {"rs", "Serbia"}, {"sl", "Sierra Leone"}, {"sg", "Singapore"}, {"sk", "Slovakia"}, {"si", "Slovenia"}, {"so", "Somalia"}, {"za", "South Africa"}, {"es", "Spain"}, {"lk", "Sri Lanka"}, {"sd", "Sudan"}, {"sz", "Swaziland"}, {"se", "Sweden"}, {"ch", "Switzerland"}, {"sy", "Syrian Arab Republic"}, {"tw", "Taiwan, Province of China"}, {"tj", "Tajikistan"}, {"tz", "Tanzania, United Republic Of"}, {"th", "Thailand"}, {"tl", "Timor-Leste"}, {"tg", "Togo"}, {"tt", "Trinidad and Tobago"}, {"tn", "Tunisia"}, {"tr", "Turkey"}, {"tm", "Turkmenistan"}, {"ug", "Uganda"}, {"ua", "Ukraine"}, {"ae", "United Arab Emirates"}, {"gb", "United Kingdom"}, {"us", "United States"}, {"uy", "Uruguay"}, {"uz", "Uzbekistan"}, {"ve", "Venezuela, Bolivarian Republic Of"}, {"vn", "Vietnam"}, {"ye", "Yemen"}, {"zm", "Zambia"}, {"zw", "Zimbabwe"}} -- 92 small countries (population < 1 million) - disabled by default, makes process slower set small_iso_countries to {{"ax", "Åland Islands"}, {"as", "American Samoa"}, {"ad", "Andorra"}, {"ai", "Anguilla"}, {"aq", "Antarctica"}, {"ag", "Antigua and Barbuda"}, {"aw", "Aruba"}, {"bs", "Bahamas"}, {"bh", "Bahrain"}, {"bb", "Barbados"}, {"bz", "Belize"}, {"bm", "Bermuda"}, {"bt", "Bhutan"}, {"bv", "Bouvet Island"}, {"io", "British Indian Ocean Territory"}, {"bn", "Brunei Darussalam"}, {"cv", "Cape Verde"}, {"ky", "Cayman Islands"}, {"cx", "Christmas Island"}, {"cc", "Cocos (Keeling) Islands"}, {"km", "Comoros"}, {"cg", "Congo"}, {"ck", "Cook Islands"}, {"cy", "Cyprus"}, {"dj", "Djibouti"}, {"dm", "Dominica"}, {"gq", "Equatorial Guinea"}, {"fk", "Falkland Islands (Malvinas)"}, {"fo", "Faroe Islands"}, {"fj", "Fiji"}, {"pf", "French Polynesia"}, {"tf", "French Southern Territories"}, {"gi", "Gibraltar"}, {"gl", "Greenland"}, {"gd", "Grenada"}, {"gp", "Guadeloupe"}, {"gu", "Guam"}, {"gg", "Guernsey"}, {"gy", "Guyana"}, {"hm", "Heard Island and McDonald Islands"}, {"va", "Holy See (Vatican City State)"}, {"is", "Iceland"}, {"im", "Isle of Man"}, {"je", "Jersey"}, {"ki", "Kiribati"}, {"la", "Lao People's Democratic Republic"}, {"li", "Liechtenstein"}, {"lu", "Luxembourg"}, {"mo", "Macao"}, {"mv", "Maldives"}, {"mt", "Malta"}, {"mh", "Marshall Islands"}, {"mq", "Martinique"}, {"yt", "Mayotte"}, {"fm", "Micronesia, Federated States Of"}, {"mc", "Monaco"}, {"me", "Montenegro"}, {"ms", "Montserrat"}, {"nr", "Nauru"}, {"an", "Netherlands Antilles"}, {"nc", "New Caledonia"}, {"nu", "Niue"}, {"nf", "Norfolk Island"}, {"mp", "Northern Mariana Islands"}, {"pw", "Palau"}, {"pn", "Pitcairn"}, {"re", "Réunion"}, {"bl", "Saint Barthélemy"}, {"sh", "Saint Helena"}, {"kn", "Saint Kitts and Nevis"}, {"lc", "Saint Lucia"}, {"mf", "Saint Martin"}, {"pm", "Saint Pierre and Miquelon"}, {"vc", "Saint Vincent and the Grenadines"}, {"ws", "Samoa"}, {"sm", "San Marino"}, {"st", "Sao Tome and Principe"}, {"sc", "Seychelles"}, {"sb", "Solomon Islands"}, {"gs", "South Georgia and the South Sandwich Islands"}, {"sr", "Suriname"}, {"sj", "Svalbard and Jan Mayen"}, {"tk", "Tokelau"}, {"to", "Tonga"}, {"tc", "Turks and Caicos Islands"}, {"tv", "Tuvalu"}, {"um", "United States Minor Outlying Islands"}, {"vu", "Vanuatu"}, {"vg", "Virgin Islands, British"}, {"vi", "Virgin Islands, U.S."}, {"wf", "Wallis and Futuna"}, {"eh", "Western Sahara"}} end load_iso_country_list