FasdUAS 1.101.10 k l _Y ********************************************************************* 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 v1.4, 2010/01/15, added support for groups: adds missing/unknown country entries, extra check for problematic cards v1.5, 2010/02/06, using "iPhone" country list instead of ISO list, changed default values of some parameters v1.5.1, 2011/07/28, small fixes, Lion compatibility, changes default value of treat_iso_list_as_unknown and check_for_updates v.1.5.2, 2011/08/20, growl fix, user request: made preferred country case sensitive instructions ----------------- - use as address book plug-in (recommended): install in /Library/Address Book Plug-Ins or ~/Library/Address Book Plug-Ins - or run as standalone script - suggested: modify the sections between #### ... #### this specifies what your country lookup table should look like, and if you see a summary at the end, etc. - when running as plug-in, if you change any parameter (e.g. "add_to_groups"): 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...)    ********************************************************************* 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 v1.4, 2010/01/15, added support for groups: adds missing/unknown country entries, extra check for problematic cards v1.5, 2010/02/06, using "iPhone" country list instead of ISO list, changed default values of some parameters v1.5.1, 2011/07/28, small fixes, Lion compatibility, changes default value of treat_iso_list_as_unknown and check_for_updates v.1.5.2, 2011/08/20, growl fix, user request: made preferred country case sensitive instructions ----------------- - use as address book plug-in (recommended): install in /Library/Address Book Plug-Ins or ~/Library/Address Book Plug-Ins - or run as standalone script - suggested: modify the sections between #### ... #### this specifies what your country lookup table should look like, and if you see a summary at the end, etc. - when running as plug-in, if you change any parameter (e.g. "add_to_groups"): 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...)  l  j 0current_version m 1.5.2  l pj ########################################################## <<<<< EDIT FROM HERE vvvvvvv ########################################################## <<<<< EDIT FROM HERE vvvvvvv l j 0 add_to_groups m  boovtrue d^ create groups for entries with missing/unknown countries; is *add-only*, so clean up manually create groups for entries with missing/unknown countries; is *add-only*, so clean up manually l ! j" 0 show_results "m  boovtrue B< optional: show summary in TextEdit after running the script!##x optional: show summary in TextEdit after running the script$% $l&'( &j ) 0check_for_updates )m  boovtrue 'ke optional: will check to see if there is an updated version of the script (no info is sent to server)(** optional: will check to see if there is an updated version of the script (no info is sent to server)%+, +l-. -lf I have show_results and check_for_updates normally set to "true", but that's completely up to you :-).// I have show_results and check_for_updates normally set to "true", but that's completely up to you :-),01 0l234 2j 5 0treat_iso_list_as_unknown 5m  boovfals 3LF if country code is found in iso list, still treat as unknown country?466 if country code is found in iso list, still treat as unknown country?178 7l9:; 9j< 0plugin_only_selected <m  boovfals :RL when using as plug-in: only update selected person or run for every person?;== when using as plug-in: only update selected person or run for every person?8>? >l@A @lf ########################################################## <<<<< EDIT TO HERE ^^^^^ABB ########################################################## <<<<< EDIT TO HERE ^^^^^?CD ClDEF EpGGH 0testingHI 0fill_empty_countryIJ 0default_countryJ 0 use_growlFKL KpMMN 0 mycountriesNO 0big_iso_countriesOP 0small_iso_countriesPQ 0 log_unknownQ 0 log_missingLRS RpTTU 0changes_countryUV 0 changes_codeVW 0 names_checkedWX 0addresses_checkedXY 0 group_missingY 0 group_unknownSZ[ Zp\\] 0list_of_isocodes]^ 0list_of_countries^_ 0list_of_aliases_` 0list_of_missing_countries` 0list_of_unknown_countries[ab albcd clef e[U-------------------------------------------------------------------------------------fgg-------------------------------------------------------------------------------------dhi hljk jRL both standalone script and plug-in will use this as the starting subroutinekll both standalone script and plug-in will use this as the starting subroutineimn miop oIq 0country_name_codeqr ro 0 localpeople LocalPeople pk]sstu tluvw vlxy x[U-------------------------------------------------------------------------------------yzz-------------------------------------------------------------------------------------w{| {l}~ } create list of countries~2 create list of countries| l hb mycountries: list of records {i,{p[,a]}} - iso code, *preferred country name*, 0 or more aliases  mycountries: list of records {i,{p[,a]}} - iso code, *preferred country name*, 0 or more aliases  r J o 0 mycountries r N o 0 mycountries o 0clist l  pj ########################################################## <<<<< EDIT FROM HERE vvvvvvv ########################################################## <<<<< EDIT FROM HERE vvvvvvv l  pj ---------- update the list below to contain all the countries you are interested in --------------------- ---------- update the list below to contain all the countries you are interested in --------------------- l  SM format of list: {isocode, {list of preferred name and -if wanted- aliases}}  format of list: {isocode, {list of preferred name and -if wanted- aliases}}  l  c] the first country name is the preferred name, this can be in your local language if you want the first country name is the preferred name, this can be in your local language if you want l  you only need to add countries here if you want to a) use a non-iso country name and/or b) if you want to add aliases / fix mis-spellings you only need to add countries here if you want to a) use a non-iso country name and/or b) if you want to add aliases / fix mis-spellings l  =7 the iso names can be found at the bottom of the scriptn the iso names can be found at the bottom of the script l  note: *only* use the ISO codes from the table at the bottom, Address Book will hide addresses with country codes not in its own table note: *only* use the ISO codes from the table at the bottom, Address Book will hide addresses with country codes not in its own table s  J  m us J  m United States mUSA mUS m0United States of America mEstados Unidos n ; o 0clist s& J# mnl J! mNetherlands mNederland mthe Netherlands mNL n ;$% o#$ 0clist l'6 s'6 J'3 m'(be J(1 m()Belgium m), Belgi m,/Belgique n ;45 o34 0clist 60 I like to use the English name for this country` I like to use the English name for this country   l7G    s7G J7D m7:de J:B m:=Germany m=@Deutschland n ;EF oDE 0clist  +% using the English name (in all caps)   J using the English name (in all caps) !" !lHX#$% #sHX&' &JHU(()* )mHK++,,gb*- -JKS../0 /mKN1122United Kingdom03 3mNQ4455UK 'n67 6;VW 7oUV 0clist $=7 note: Address Book uses "gb" as country code, not "uk"%88n note: Address Book uses "gb" as country code, not "uk""9: 9lYf;<= ;sYf>? >JYc@@AB AmY\CCDDfrBE EJ\aFFG Gm\_HHII France ?nJK J;de Kocd 0clist <IC optional: direct copy from iso list, only advantage: faster search=LL optional: direct copy from iso list, only advantage: faster search:MN MlggOP O Examples: copy {"ca", {"Canada", "Canad","Kanada","Kanata"}} to end of clist -- correct typo's, update entries with incorrect spelling copy {"de", {"Deutschland", "Germany"}} to end of clist -- use the German name for this country copy {"ve", {"Venezuela"}} to end of clist -- example of overwriting the standard name from the iso list ("Venezuela, Bolivarian Republic Of") copy {"", {"Chile"}} to end of clist -- example: I dont like Apples Chile address format, leave iso code empty for default country format copy {"np", {"NEPAL"}} to end of clist -- if it finds Nepal (or nePal etc.), it will be replaced with all caps NEPAL --copy {"??", {"Luxembourg"}} to end of clist -- *incorrect*, iso code is invalid --copy {"an", {"Netherlands Antilles"}} -- *incorrect*: Apple does not know this iso code, result: will no longer disply address -- add as many lines as you like... (and remove the ones you don't need) PQQ> Examples: copy {"ca", {"Canada", "Canad","Kanada","Kanata"}} to end of clist -- correct typo's, update entries with incorrect spelling copy {"de", {"Deutschland", "Germany"}} to end of clist -- use the German name for this country copy {"ve", {"Venezuela"}} to end of clist -- example of overwriting the standard name from the iso list ("Venezuela, Bolivarian Republic Of") copy {"", {"Chile"}} to end of clist -- example: I don t like Apple s Chile address format, leave iso code empty for default country format copy {"np", {"NEPAL"}} to end of clist -- if it finds Nepal (or nePal etc.), it will be replaced with all caps NEPAL --copy {"??", {"Luxembourg"}} to end of clist -- *incorrect*, iso code is invalid --copy {"an", {"Netherlands Antilles"}} -- *incorrect*: Apple does not know this iso code, result: will no longer disply address -- add as many lines as you like... (and remove the ones you don't need) NRS RlggTU Tlf ########################################################## <<<<< EDIT TO HERE ^^^^^UVV ########################################################## <<<<< EDIT TO HERE ^^^^^SWX WlggXYZ Ylgg[\ [pj ########################################################## <<<<< EDIT FROM HERE vvvvvvv\]] ########################################################## <<<<< EDIT FROM HERE vvvvvvvZ^_ ^lgg`a `0* these settings can normally be left aloneabbT these settings can normally be left alone_cd clgnefg ergnhi hmgjjjkk" " without country io 0 group_missing f/) group for addresses without country namegllR group for addresses without country namedmn mlovopq orovrs rmorttuu" " unknown country so 0 group_unknown pHB group for addresses with country not in the list from this scriptqvv group for addresses with country not in the list from this scriptnwx wlw|yz{ yrw||} |mwx  boovfals }o 0fill_empty_country zXR should we fill addresses that have empty country name fields with a default name?{~~ should we fill addresses that have empty country name fields with a default name?x l} r} m}Netherlands o 0default_country UO if the country name field is empty for a contact, what country should be used? if the country name field is empty for a contact, what country should be used? l r m  boovtrue o 0 use_growl JD use Growl (is set to false automatically if Growl is not installed) use Growl (is set to false automatically if Growl is not installed) l l r m  boovfals o 0testing f` change this if you only want to modify cards that have last name "testing" (see vcard download) change this if you only want to modify cards that have last name "testing" (see vcard download) l lf ########################################################## <<<<< EDIT TO HERE ^^^^^ ########################################################## <<<<< EDIT TO HERE ^^^^^ l Z o 0check_for_updates k l r I 0check_latest_version o 0current_version o 0lets_get_new_version 2, will show popup if there is a newer versionX will show popup if there is a newer version l Z o 0lets_get_new_version L WQ let's stop if the user wanted to open the browser to download the latest version let's stop if the user wanted to open the browser to download the latest version l l~~  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 < 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  l}|{}|{ O r lzy e Ixwv x.misccurdldt nullwvzy ou u0 starttime startTime mt t misccura lsrqsrq lpp :4 make preparations for Growl (http://www.growl.info)h make preparations for Growl (http://www.growl.info) l Ionm o0 prepare_growlnm +% use_growl is set if Growl is runningJ use_growl is set if Growl is running llkjlkj Iih i0send_growl_msg m Starting plug-ing m|Now checking+fixing country names and codes. Can take a while.gh lfedfed l Icba c0load_iso_country_listba ! reads the iso country list6 reads the iso country list l`_^`_^ l]]   for statistics at the end4 for statistics at the end r m\\ o[ [0changes_country r mZZ oY Y0 changes_code r mXX oW W0 names_checked r mVV oU U0addresses_checked lTSRTSR r JQQ oP P0list_of_countries r   JOO  oN N0list_of_aliases   r   JMM oL L0list_of_isocodes  l  r  J  KK oJ J0list_of_missing_countries B< will be filled with names that have address without countryx will be filled with names that have address without country l r JII oH H0list_of_unknown_countries <6 will be filled with countries not in the lookup tablel will be filled with countries not in the lookup table l!"# !r$% $m&&'' %oG G0 log_missing "d^ will be filled with script-ready table based on unknown countries (alternative to list above)#(( will be filled with script-ready table based on unknown countries (alternative to list above) )* )l&+,- +r&./ .m"0011 /oF F0 log_unknown ,d^ will be filled with script-ready table based on unknown countries (alternative to list above)-22 will be filled with script-ready table based on unknown countries (alternative to list above)*34 3l''EDCEDC456 5r'/78 7N'-9 9oB B0list_of_countries 8oA A 0locref6:; :r08<= <N06> >o@ @0list_of_aliases =o? ? 0loaref;?@ ?r9AAB AN9?C Co> >0list_of_isocodes Bo= = 0loiref@DE DlBB<;:<;:EFG FlBB9HI9 H>8 to speed up lookup: extract data from the list of listsIJJp to speed up lookup: extract data from the list of listsGKL KlBB8MN8 M>8 list_of_countries: all official/preferred country namesNOOp list_of_countries: all official/preferred country namesLPQ PlBB7RS7 RLF list_of_aliases: all official/preferred country names *and* alias(es)STT list_of_aliases: all official/preferred country names *and* alias(es)QUV UlBB6WX6 W& list_of_isocodes: all iso codesXYY@ list_of_isocodes: all iso codesVZ[ ZXB\5] \kV^^_` _lV^abc arV^de dnV\fg f4W\4h 4 cobj hmZ[33 goVW2 2 0 mycountry eo1 1 0myiso b the iso codecii the iso code`jk jl_glmn lr_gop on_eqr q4`e0s 0 cobj smcd// ro_`. . 0 mycountry po- - 0calist m60 preferred country name + any (optional) aliasesntt` preferred country name + any (optional) aliaseskuv ulhpwxy wrhpz{ znhn|} |4in,~ , cobj ~mlm++ }ohi* * 0calist {o) )0myc x preferred country namey. preferred country namev lqq('&('&% Zq$# Fq Fq lqv"! >qv oqr 0myiso mru??"! ly~ >y~ oyz  0myiso mz} l H E o  0loiref o  0myiso l k r o  0myiso n ; o  0loiref r o 0myc n ; o  0locref X r n 1  pcnt o 0myca n ; o  0loaref 0myca o  0calist 0* ignore the record if the iso code is "??"T ignore the record if the iso code is "??"$#% 5 0 mycountry ]oEF 0 mycountries[ l     l  )# 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 F 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  l   l XR example: lookup an alias or preferred country name, return iso and preferred name example: lookup an alias or preferred country name, return iso and preferred name l ?9set {myi, myc} to my find_iso_code_in_country_list("USA")rset {myi, myc} to my find_iso_code_in_country_list("USA") l l [U-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- l A; load the records from Address Book in variable LocalPeoplev load the records from Address Book in variable LocalPeople O k l SM if this subroutine is called from the application, then LocalPeople is empty if this subroutine is called from the application, then LocalPeople is empty l IC if it is called as plugin, it could be set to the selected address if it is called as plugin, it could be set to the selected address Z  = l I .corecnte******** o 0 localpeople LocalPeople m Z l = o 0testing m  boovtrue k I .ascrcmnt******** m*** only cards with last name 'testing' will be checked and updated *** l r l e 6 2  azf4 = l 1  azf8 mtesting o 0 localpeople LocalPeople  testing names testing names r l e 2  azf4 o 0 localpeople LocalPeople I  .ascrcmnt******** b    b    m   Processing  l I .corecnte******** o 0 localpeople LocalPeople  m persons madrbalisf Macintosh HDɏ1H+Address Book.app_ m Applicationsɏ#z Q+Macintosh HD:Applications:Address Book.app"Address Book.app Macintosh HDApplications/Address Book.app/ l [U-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- l VP ### optional: call subroutine to find all the countries in the address book ### ### optional: call subroutine to find all the countries in the address book ### l !  LF can help to identify which countries should be added to the iso list !"" can help to identify which countries should be added to the iso list #$ #l%& %~xchoose from list my list_of_countries_in_address_book(LocalPeople) with title "Countries in Address Book" with prompt ""&''choose from list my list_of_countries_in_address_book(LocalPeople) with title "Countries in Address Book" with prompt ""$() (l*+ *?9return -- in that case, you can stop here if you want to +,,rreturn -- in that case, you can stop here if you want to )-. -l./0 /l12 1[U-------------------------------------------------------------------------------------233-------------------------------------------------------------------------------------045 4l67 6 call the main subroutine7882 call the main subroutine59: 9I%; '0#check_and_fix_country_name_and_code;< <o ! 0 localpeople LocalPeople:=> =l&&>?@ ?O&4AB Ar,3CD Cl,1E Ee,1F FI,1 .misccurdldt null Do 0endtimeendTime Bm&)  misccura@GH Gr5:IJ I\58KL Ko56 0endtimeendTime Lo67 0 starttime startTime Jo 0durationHMN Ml;;NOP Or;QR Qb;ST Sb;UV Ub;WX Wb;YZ Yb;[\ [b;]^ ]b;_` _b;ab ab;cd cb;ef eb;gh gb;ij ib;kl kb;~mn mb;zop ob;vqr qb;rst sb;nuv ub;jwx wb;fyz yb;b{| {b;^}~ }b;Z b;V b;R b;N b;J b;F b;B m;>checked: o>A  ret l BE mBE " names:  oFI 0 names_checked oJM  ret l NQ mNQ " addresses:  oRU 0addresses_checked oVY  ret ~oZ]  ret |l ^a m^aupdated: zobe  ret xl fi mfi " countries:  vojm 0changes_country tonq  ret rl ru mru " formats:  povy 0 changes_code noz}  ret lo~  ret jl  mcountries: ho  ret fl  m " unknown:  dl I .corecnte******** o 0list_of_unknown_countries bo  ret `l  m " missing:  ^l I .corecnte******** o 0list_of_missing_countries \o  ret Zo  ret Xl  mprocess took  Vo 0duration Tm seconds Ro 0summaryP l I .ascrcmnt******** o 0summary Z  l o 0 use_growl k I 0send_growl_msg m$Summary of results o 0summary Z~} F l|{ = oz z0 show_results my y boovfals|{ lxw ? lvu Its t.corecnte******** or r0list_of_unknown_countriessvu mqqxw Ipo p0send_growl_msg m$Additional detailsn b b mXenable show_results variable to see list of lml Ikj k.corecnte******** oi i0list_of_unknown_countriesjml m$ unknown countriesno~} l  hgfhgf Z [ed l cb =  o a a0 show_results m` ` boovtruecb kW Z:_^ G. l]\ ? l[Z IYX Y.corecnte******** oW W0list_of_missing_countriesX[Z mVV]\ l!*UT ?!* l!(SR I!(QP Q.corecnte******** o!$O O0list_of_unknown_countriesPSR m()NNUT I16MLK M0write_log_to_fileLK_^J Z;WIH l;?GF H;? o;>E E 0 use_growlGF lBS IBSD D.sysodlogaskrTEXT oBCC C 0summaryB B appr mFIJAddress Book: country names + formatsA@ A btns mLO    Ok@ >8 not using Growl, then only show if show_results was set  p not using Growl, then only show if show_results was setIHJed ?  l\\>=<>=<?n   l;:9;:9 l88 [U-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- l77 [U this is the entry point when script is run standalone, for plug-in entry: see bottom this is the entry point when script is run standalone, for plug-in entry: see bottom i I654 6.aevtoappnull****54 l I3 2 30country_name_code !1 !J0012 D> {} means: leave empty, the subroutine will then fill it later""| {} means: leave empty, the subroutine will then fill it later#$ #l/.-/.-$%& %l,+*,+*&'( 'l)(')('()* )l&+,& +xr------------------------------------------------------------------------------------------------------------------,--------------------------------------------------------------------------------------------------------------------*./ .l%01% 0 subroutines122 subroutines/34 3l$56$ 5xr------------------------------------------------------------------------------------------------------------------677------------------------------------------------------------------------------------------------------------------489 8l#"!#"!9:; :i<= <I > %0!list_of_countries_in_address_book>? ?o 0 localpeople LocalPeople =kc@@AB ArCD CJ Do 0list_of_countriesBEF ElFGH GOTIJ IX SKL KXNMN Mk+IOOPQ Pr+1RS Re+/T Tl+/U Un+/VW V1,.  az32 Wo+, 0 theaddress theAddress So 0 thecountry theCountryQX XZ2IYZ YF2>[\ [l25] ]>25^_ ^o23 0 thecountry theCountry _m34  msng  \l8<`  `H8<a aE8;bc bo89 0list_of_countries co9: 0 thecountry theCountry  ZrAEde doAB 0 thecountry theCountry enfg f;CD goBC 0list_of_countries 0 theaddress theAddress Nlh hnij im  az27 jo 0 theperson thePerson 0 theperson thePerson Lo 0 localpeople LocalPeople Jmkkadrbalisf Macintosh HDɏ1H+Address Book.app_ m Applicationsɏ#z Q+Macintosh HD:Applications:Address Book.app"Address Book.app Macintosh HDApplications/Address Book.app/Hlm lIUZn .ascrcmnt******** nmUVoopp6Countries in address book: mqr qI[`s .ascrcmnt******** so[\ 0list_of_countriesrt tLacu uoab 0list_of_countries;vw vlwxy xlz{ zxr------------------------------------------------------------------------------------------------------------------{||------------------------------------------------------------------------------------------------------------------y}~ }l~ i! I !0find_iso_code_in_country_list o 0 country_alias o 0 list_to_check kM XG kB r n 4  cobj m o 0 mycountry o 0myi r n 4  cobj m o 0 mycountry o 0myca l l 60 mycountry list format {iso,{country/countries}}` mycountry list format {iso,{country/countries}} l 93 big/small_iso_countries list format {iso, country}f big/small_iso_countries list format {iso, country} Z2 =# n! m!  pcls o 0myca m!"  list r&, n&* 4'*  cobj m() o&' 0myca o 0myc r/2 o/0 0myca o 0myc l33 Z3B E36 o34 0myca o45 0 country_alias k9> l99 LFlog " looking for: " & country_alias & ", found: " & myi & " = " & myclog " looking for: " & country_alias & ", found: " & myi & " = " & myc L9> J9= o9: 0myi o:; 0myc 0 mycountry o 0 list_to_check lHH " if the country is not found8 if the country is not found LHM JHL mHI?? oIJ 0 country_alias l l xr------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ l i"% I '0#check_and_fix_country_name_and_code o 0 localpeople LocalPeople O k l X k r m o 0 changes_made r c l n 1  pnam o 0 theperson thePerson m  TEXT o 0thenametheName l  X  k2 Q2K  l5:    r5: n58 168  az18 o56 0 theaddress theAddress o 0theaddresstypetheAddressType  ^X a user reported an issue where it was not possible to read the label, so build in check  a user reported an issue where it was not possible to read the label, so build in check  R .ascrerr ********  kBK IBI .ascrcmnt******** bBE oBC 0thenametheName mCD,: problem with address SJK lLL rLU !  bLS"# "bLQ$% $bLO&' &oLM 0thenametheName 'mMN(()) ( %oOP 0theaddresstypetheAddressType #mQR**++) !o 0 message_str,- ,rV\./ .lVZ0 0eVZ1 1lVZ2 2nVZ34 31WY  az32 4oVW 0 theaddress theAddress /o 0 thecountry theCountry-56 5r]c78 7l]a9 9e]a: :l]a; ;n]a<= <1^`  az33 =o]^ 0 theaddress theAddress 8o 0thecountrycodetheCountryCode6>? >ldd?@A @ZdBC BldiD D=diEF Eode 0 thecountry theCountry Fmeh  msng CZlGHI GlloJ Jolo 0fill_empty_country HkrKKLM LlrrNO NKElog " country is missing, set to default country: " & default_countryOPPlog " country is missing, set to default country: " & default_countryMQR QrryST Soru 0default_country TlU~ UnVW V1vx} } az32 Wouv| |0 theaddress theAddress~RX{ XrzYZ Y[z}[\ [oz{z z0 changes_made \m{|yy Zox x0 changes_made{ Ik]]^_ ^lw`aw `ZTlog " country is missing, but -per user setting- not changing to " & default_countryabblog " country is missing, but -per user setting- not changing to " & default_country_cd cref eov v0 message_str fngh g; hou u0list_of_missing_countriesdij irkl kbmn mbop oot t0 log_missing pos s0 message_str nor r ret loq q0 log_missingjqp qQrst rIouv o.az00az44nullazf6 uon n0 theperson thePersonvmwl m az45 w4kx k azf5 xoj j0 group_missingl sRihg i.ascrerr ********hg tkyyz{ zIfe| f.corecrel****nulle|d}~ d kocl }mc c azf5~ba b prdt K`_ ` pnam o^ ^0 group_missing_a{] I\ \.az00az44nullazf6 o[ [0 theperson thePersonZY Z az45 4X X azf5 oW W0 group_missingY]pA lVUTVUT r mS S boovfals oR R0country_is_in_alias_list ZQP lON E oM M0list_of_aliases oL L0 thecountry theCountryON r mK K boovtrue oJ J0country_is_in_alias_listQP lIHGIHG lFF  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 h 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  lEDCEDC l ZBA F l@? > o> >0 thecountry theCountry m= = msng@? l<; > o: :0country_is_in_alias_list m9 9 boovtrue<; k l88 oi 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 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 l77 [U the official iso list is broken up in two parts: large countries and small countries the official iso list is broken up in two parts: large countries and small countries l66 # this to speed up the search.: this to speed up the search. l55  Optional: still treat it as an "unknown" country, as it makes the script much faster if we do not have to do this fallback search Optional: still treat it as an "unknown" country, as it makes the script much faster if we do not have to do this fallback search l44 NHlog message_str & ": can not find country " & theCountry & " in my list"log message_str & ": can not find country " & theCountry & " in my list" r m?? o3 30iso l22 ;5log message_str & ": searching in large country list"jlog message_str & ": searching in large country list" r  n I 10 1!0find_iso_code_in_country_list o  / /0 thecountry theCountry. o  - -0big_iso_countries.0 f J o, ,0iso+ o* * 0 preferred+ l!E Z!E)( l!&'& =!& o!"% %0iso m"%??'& l)A k)A l))$$ ;5log message_str & ": searching in small country list"jlog message_str & ": searching in small country list"# r)A n)2 I*2"! "!0find_iso_code_in_country_list o*+ 0 thecountry theCountry o+. 0small_iso_countries! f)* J o 0iso o  0 preferred# QK could not find it in the list of large countries, let's try the small ones could not find it in the list of large countries, let's try the small ones)( JD country was not in big country list, searched in small country list country was not in big country list, searched in small country list lFd ZFd    lFK   >FK   oFG 0iso mGJ??  lN` kN` lNN '!log " found in iso list: " & isoBlog " found in iso list: " & iso rNT oNO 0 thecountry theCountry n ;RS oOR 0list_of_aliases   rU`!" !JU[##$% $oUV 0iso%& &JVY''( (oVW  0 preferred "n)* );^_ *o[^ 0 mycountries 5/ we found the country in the small country list++^ we found the country in the small country list @: country code was found in the large or small country list ,,t country code was found in the large or small country list- -le./0 .Ze12 1Gex34 3lej5  5=ej67 6oef 0iso 7mfi8899??  4lmt: :=mt;< ;omr 0treat_iso_list_as_unknown <mrs  boovtrue 2k{==>? >r{@A @o{| 0 thecountry theCountry AnBC B; Co| 0list_of_unknown_countries?DE DrFG FbHI HbJK JbLM LbNO NbPQ PbRS Ro 0 log_unknown SmTTUUcopy {" Qo 0iso OmVVWW ", {" Mo 0 thecountry theCountry KmXXYY&"}} to end of clist Io  ret Go 0 log_unknownEZ[ Zl\] \LFlog message_str & ": unknown country " & theCountry & " (" & iso & ")"]^^log message_str & ": unknown country " & theCountry & " (" & iso & ")"[_ _Q`ab `Icd .az00az44nullazf6 co 0 theperson thePersonde  az45 e4f  azf5 fo 0 group_unknown aR .ascrerr ******** bkgghi hIj .corecrel****nulljkl  kocl km  azf5lm  prdt mKnno  pnam oo 0 group_unknownip pIqr .az00az44nullazf6 qo 0 theperson thePersonrs  az45 s4t  azf5 to 0 group_unknown  /SM country code was found in the small country list, but treat as "unknown" 0uu country code was found in the small country list, but treat as "unknown"  BA ;5 country name was not in the user's list of countriesvvj country name was not in the user's list of countrieswx wlxyz yZ{|} {F~ ~l > o 0 thecountry theCountry m  msng l = o 0country_is_in_alias_list m  boovtrue |k l MGlog " country is " & theCountry & ", check if it is the preferred name"log " country is " & theCountry & ", check if it is the preferred name" r n I !0find_iso_code_in_country_list o 0 thecountry theCountry o 0 mycountries f J o 0iso o 0 preferred l% Z% l = o 0iso m r! l 1  az63 o 0iso D> this way you can overwrite the country code from the iso list| this way you can overwrite the country code from the iso list l&& P&M Z-L l-0 >-0 o-. 0 thecountry theCountry o./ 0 preferred k3H l33 C=log " preferred name for " & theCountry & " is: " & preferredzlog " preferred name for " & theCountry & " is: " & preferred r38 o34 0 preferred l n 157  az32 o45 0 theaddress theAddress r9B [9> o9< 0changes_country m<= o 0changes_country rCH [CF oCD 0 changes_made mDE o 0 changes_made  conscase lNN ZN FNi lNS >NS oNO 0iso mOR?? lVe GVe lV[ =V[ oVW 0thecountrycodetheCountryCode mWZ  msng l^a >^a o^_ 0thecountrycodetheCountryCode o_` 0iso kl lll log message_strlog message_str lll ^Xlog " country code for " & theCountry & " was " & theCountryCode & ", should be: " & isolog " country code for " & theCountry & " was " & theCountryCode & ", should be: " & iso rlq olm 0iso l n 1np  az33 omn 0 theaddress theAddress rrw [ru ors 0 changes_made mst o 0 changes_made rx [x} ox{ 0 changes_code m{| o 0 changes_code l F l = o 0thecountrycodetheCountryCode o 0iso l >   o 0 thecountry theCountry  o 0 preferred   k     l~~ ?9 this means: actual country name is not the preferred oner this means: actual country name is not the preferred one} l|| C= leave it like that, up to the user to change in country listz leave it like that, up to the user to change in country list} }l{{ OIlog " skipping, country is missing or not in lookup table: " & theCountrylog " skipping, country is missing or not in lookup table: " & theCountryz lzyxzyx Zwv lut ? !  os s0 changes_made !mrrut k""#$ #lq%&q %D>log "made changes to " & theName & " (" & theAddressType & ")"&''|log "made changes to " & theName & " (" & theAddressType & ")"$(p (Ionm o.coresavenullnullnmpwv)* )llkjlkj*+, +li-.i -71for testing: to reset everything to old situation.//bfor testing: to reset everything to old situation,01 0lh23h 2@:set the country code of theAddress to missing value -- iso344tset the country code of theAddress to missing value -- iso156 5lgfegfe67d 7r89 8[:; :oc c0addresses_checked ;mbb 9oa a0addresses_checkedd 0 theaddress theAddress l#&<`_ <n#&=> =m$&^ ^ az27 >o#$] ]0 theperson thePerson`_ % loop of addresses for a person??> loop of addresses for a person@\ @rAB A[CD Co[ [0 names_checked DmZZ BoY Y0 names_checked\ 0 theperson thePerson oX X0 localpeople LocalPeople  loop of personsEE loop of personsFW FlGHI GIVUT V.coresavenullnullUT H=7 already did a save after each change, but just in caseIJJn already did a save after each change, but just in caseW mKKadrbalisf Macintosh HDɏ1H+Address Book.app_ m Applicationsɏ#z Q+Macintosh HD:Applications:Address Book.app"Address Book.app Macintosh HDApplications/Address Book.app/LM LlSRQSRQMNO NlPONPONOPQ PlMRSM Rxr------------------------------------------------------------------------------------------------------------------STT------------------------------------------------------------------------------------------------------------------QUV UlLKJLKJVWX Wi&)YZ YIIHG I0 prepare_growlHG ZZF[\FE [l]DC ]oB B 0 use_growlDC \kB^^_` _lA@?A@?`ab aOcd cref eI>g= >.coredoexboolobj g4 <h < pcap hm iijjGrowlHelperApp= fo; ; 0 use_growl dmkksevsalis Macintosh HDɏ1H+System Events.app lb CoreServicesɏ#z PB =Macintosh HD:System:Library:CoreServices:System Events.app$System Events.app Macintosh HD-System/Library/CoreServices/System Events.app/blm lZno:9 nlp87 pHq qo6 6 0 use_growl87 oL55:9mrs rl 432432stu tl 1vw1 v5/ using terms from application "GrowlHelperApp"wxx^ using terms from application "GrowlHelperApp"uyz yO @{| {k(?}}~ ~r(- J(+0 m() Alert0 l/. o- -,0allnotificationslistallNotificationsList/. r.1 o./, ,,0allnotificationslistallNotificationsList l+* o) )40enablednotificationslistenabledNotificationsList+* l22('&('&% I2?$# $.registernullnull#" " appl l 45! m45BAddress Book country name plug-in!   anot l 67 o67 ,0allnotificationslistallNotificationsList  dnot l 89 o89 40enablednotificationslistenabledNotificationsList  iapp m:;Address Book% |5 %  capp m"#0com.Growl.GrowlHelperApp  kfrmID z lAA  end using terms from, end using terms fromFEX l i*- I 0send_growl_msg o 0desc o 0msg  Z   l o  0 use_growl k l 5/ using terms from application "GrowlHelperApp"^ using terms from application "GrowlHelperApp" O I  .notifygrnullnull  name l  m Alert  titl l  o 0desc  desc l  o 0msg  appl mBAddress Book country name plug-in 5   capp m0com.Growl.GrowlHelperApp  kfrmID  l  end using terms from, end using terms from  l l xr------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ l i.1 I 0check_latest_version o 0current_version k r b mhttp://winfred.vankuijk.net/wp-content/uploads/latest_version_address_book_plugin.txt? o 0current_version o 0myurl l \V try to get the url with built in curl command, spend a maximum of 3 seconds to get it try to get the url with built in curl command, spend a maximum of 3 seconds to get it r  b  b  mZ/usr/bin/curl --fail --max-time 3 --output - o 0myurl m  2> /dev/null o 0mycmd r mhttp://winfred.vankuijk.net/2010/01/fixing-countries-in-address-book/#download o 0myloc Q& r I .sysoexecTEXTTEXT o 0mycmd o 0myoutput R .ascrerr ******** k$&     l$$    XR could not check the latest version, will skip and go back to regular programme...  could not check the latest version, will skip and go back to regular programme...  L$& m$%  boovfals r'C I 0parse_version_output o() 0myoutput J o 0latest_version o 0 version_date o 0version_description lDD lD!"# !ZD$% $lDG& &ADG'( 'oDE 0current_version (oEF 0latest_version %kJ))*+ *QJ,-. ,rM/0 /IM12 .sysodlogaskrTEXT 1bMj34 3bMh56 5bMf78 7bMd9: 9bMb;< ;bM`=> =bM^?@ ?bM\AB AbMZCD CbMXEF EbMVGH GbMTIJ IbMRKL KbMPMN MmMNOOPP.New version available: NoNO 0latest_version Ll PQQ QmPQRRSS ( JoRS 0 version_date HmTUTTUU) FoVW  ret DmXYVVWW$You have version: BoZ[ 0current_version @o\]  ret >o^_  ret <l `aX Xm`aYYZZ*New in this release:  :obc 0version_description 8ode  ret 6ofg  ret 4mhi[[\\Go to site?2]^  btns ]l mu_ _Jmu``ab ammpccddSkipbe empsffggYes^hi  dflt hmx{jjkkYesilm  givu lm~mn  appr nmoopp@New version of plug-in available 0o 0 open_site -R .ascrerr ******** .lqrs qLt tm  boovfals r user pressed Skipsuu$ user pressed Skip+v vZwx w=yz yn{| {1  bhit |o 0 open_site zm}}~~Yes xk Q l O I .GURLGURLnullTEXT o 0myloc msevsalis Macintosh HDɏ1H+System Events.app lb CoreServicesɏ#z PB =Macintosh HD:System:Library:CoreServices:System Events.app$System Events.app Macintosh HD-System/Library/CoreServices/System Events.app/  open in default browser0 open in default browser R .ascrerr ******** L m  boovfals l L m  boovtrue JD if we arrive here: we opened the browser, user is going to download if we arrive here: we opened the browser, user is going to download "0* compare current_version to latest_version#T compare current_version to latest_version  l L m  boovfals 82 if we arrive here: we already have latest versiond if we arrive here: we already have latest version l i25 I 0parse_version_output o 0output kD r n 1  txdl 1  ascr o "0saveddelimiterssavedDelimiters Q7 k * l  r  J  m | n 1   txdl 1  ascr 71 output looks like "1.2.3|2010/01/12|what is new"b output looks like "1.2.3|2010/01/12|what is new" r* n 2  citm o 0output J o 0 myversion o 0mydate o 0mydesc R .ascrerr ******** r27 o23 "0saveddelimiterssavedDelimiters n 146  txdl 134  ascr l8= r8= o89~ ~"0saveddelimiterssavedDelimiters n 1:<} } txdl 19:| | ascr 0* reset the delimiter to the original stateT reset the delimiter to the original state{ L>D J>C o>?z z 0 myversion o?@y y 0mydatex o@Aw w 0mydescx{ lvutvut lss xr------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ lrqprqp i69 Ionm o0write_log_to_filenm k r llk Iji j.earsffdralis afdr filk oh h 0mypath r) b' b% b# b! b b   b   b   b   b b b  b   m    R*** Address Book country names plug-in (v o g g0current_version m     ) *** of f ret l  ed m    http://winfred.vankuijk.net/2010/01/fixing-countries-in-address-book/ed oc c ret ob b ret l  a` m    H>>> Don't like to see this file? <<<a` o_ _ ret l  ^] m    ROpen script (location is mentioned below)^] o \ \ ret l !" [Z m!"    Pand set *show_results* variable to false[Z o#$Y Y ret o%&X X ret oW W0 the_content ! " !Z* # $VU #?*1 % & %l*/ 'TS 'I*/R (Q R.corecnte******** (o*+P P0list_of_unknown_countriesQTS &m/0OO $r4 ) * )b4 + , +o45N N0 the_content ,l 5 -ML -l5 .KJ .b5 / 0 /b5 1 2 1b5 3 4 3b5 5 6 5b5 7 8 7b5 9 : 9b5 ; < ;b5 = > =b5 ? @ ?b5~ A B Ab5| C D Cb5x E F Eb5v G H Gb5t I J Ib5p K L Kb5n M N Mb5j O P Ob5h Q R Qb5d S T Sb5b U V Ub5^ W X Wb5\ Y Z Yb5X [ \ [b5V ] ^ ]b5R _ ` _b5P a b ab5L c d cb5J e f eb5H g h gb5F i j ib5D k l kb5B m n mb5@ o p ob5> q r qb5< s t sb5: u v ub58 w x wm56 y y z zBunknown countries in address book xo67I I ret vl 89 {HG {m89 | | } }--------------------------------------------------------------------HG to:;F F ret rl <= ~ED ~m<=    .modify the list below: ED po>?C C ret nl @A BA m@A    1) if missing (code='??'), add the official iso code (e.g. us, nl, fr, gb)BA loBC@ @ ret jl DE ?> mDE    x2) if not missing: then it is not mandatory to add to table,?> hoFG= = ret fl HI <; mHI    j but you will get faster results if you add the row<; doJK: : ret bl LO 98 mLO    j >>> don't want to see these in the list below? <<<98 `oPQ7 7 ret ^l RU 65 mRU    V Set *treat_iso_list_as_unknown* to false65 \oVW4 4 ret Zl X[ 32 mX[    z3) start with your preferred country name and add any aliases32 Xo\]1 1 ret Vl ^a 0/ m^a    | e.g. {"de", {"Deutschland","Germany"}} -- prefer local name0/ Tobc. . ret Rl dg -, mdg    e.g. {"es", {"Spain","Spaain"}} -- will fix incorrect spelling-, Pohi+ + ret Nl jm *) mjm    j4) leave ISO code empty to use default country format*) Lono( ( ret Jl ps '& mps    e.g. {"", {"Chile"}} -- don't use Apple's format, use default format'& Hotu% % ret Fl vw $# ovw" " ret $# Dl x{ ! mx{    note: *only* add ISO codes that are in the table at bottom of the script, ! Bo|}  ret @l ~  m~    Address Book hides addresses with ISO codes that it does not know! >o  ret <l  o  ret  :l  m    v##### start of list [copy lines below] #################### 8o  ret 6l  o 0 log_unknown 4l  m    r##### end of list [copy lines above] #################### 2o  ret 0l  o  ret KJML *o 0 the_contentVU " l      Z  ? l  I  .corecnte******** o 0list_of_missing_countries m k   O r 1  az63 o 0defco m  adrbalisf Macintosh HDɏ1H+Address Book.app_ m Applicationsɏ#z Q+Macintosh HD:Applications:Address Book.app"Address Book.app Macintosh HDApplications/Address Book.app/  r b o 0 the_content l l b b b b b b b b b b b b b o  ret l m    FYI: contacts where address is available, but country is missing o  ret l m    This is fine, however for missing countries the default format will be used o  ret l m    dIn your case (Address Book > Settings > General):  o 0defco o  ret l m    -------------------------------------------------------------------- o  ret l o 0 log_missing l m    -------------------------------------------------------------------- o  ret l m     o 0 the_content  l  Z0 F l G ?  l  I  .corecnte******** o 0list_of_missing_countries m ?   l  I  .corecnte******** o 0list_of_unknown_countries m l  > o 0check_for_updates m   boovtrue r, b*  o 0 the_content l )  l)  b)   b%   b#   b   b   b   o  ret o  ret l   m    v>>> want to get updated of new versions of this script? <<< o  ret l " m" ! ! " "Pset *check_for_updates* variable to true o#$  ret l %( # #m%( $ $ % % o 0 the_content  & ' &l11 ' ( ) (Z1t * + *l1H , ,G1H - . -?1: / 0 /l18 1 1I18 2 .corecnte******** 2o14 0list_of_missing_countries 0m89 .?=D 3 4 3l=B 5 5I=B 6 .corecnte******** 6o=> 0list_of_unknown_countries 4mBC +rKp 7 8 7bKn 9 : 9oKL 0 the_content :l Lm ; ;lLm < <bLm = > =bLi ? @ ?bLg A B AbLc C D CbLa E F EbL[ G H GbLY I J IbLU K L KbLS M N MbLO O P OoLM  ret PoMN  ret Nl OR Q QmOR R R S S=========================================================================== LoST  ret Jl UX T TmUX U U V Vmodify the list & settings to the following file and restart Address Book:  HoYZ  ret Fl [` W Wl[` X Xn[` Y Z Y1\`  psxp Zo[\ 0mypath Doab  ret Bl cf [ [mcf \ \ ] ]=========================================================================== @ogh  ret >l il ^ ^mil _ _ ` ` 8o 0 the_content ) a b aluu b c d cru e f elu g gbu h i hlu j jcu k l klu| m mIu| n .earsffdralis afdr nmux  afdrdesk lm|  TEXT im o o p pRAddress Book countries plug-in report.txt fo 0the_file d q r qr s t sI u v .rdwropenshorfile uo~ ~ 0the_file v} w| } perm wm{ { boovtrue| toz z0fp r x y xQ z {y zk | | } ~ }lx  x  set eof fp to 0   " set eof fp to 0 ~ w Iv v.rdwrwritnull**** ou u0 the_content t t refn os s0fp r q r wrat mppqw {Ronm o.ascrerr ********nmy y Il k l.rdwrclosnull**** oj j0fpk  li i 82tell application "TextEdit" to open alias the_file   dtell application "TextEdit" to open alias the_file  h O Ig f g.aevtodocnullalis oe e 0the_filef m  MACSalist Macintosh HDɏ1H+ Finder.appH( CoreServicesɏ#z( 6Macintosh HD:System:Library:CoreServices:Finder.app Finder.app Macintosh HD&System/Library/CoreServices/Finder.app/h ldcbdcb  la`_a`_  l^ ^ xr------------------------------------------------------------------------------------------------------------------   ------------------------------------------------------------------------------------------------------------------  l] ] ,& settings for the address-book plug-in   L settings for the address-book plug-in  l\ \ [U to use: install in /Library/Address Book Plug-Ins or ~/Library/Address Book Plug-Ins   to use: install in /Library/Address Book Plug-Ins or ~/Library/Address Book Plug-Ins  l[ZY[ZY  w k   i:= IXWV X.az00az57nullnullWV L m    address  lUTSUTS  i>A IRQ R.az00az59nullnullQ P P az61 oO O0 theperson thePerson N M N az62 oL L0theentrytheEntryM L mK K boovtrue  lJIHJIH  iBE IGF G.az00az58nullnullF E E az61 oD D0 theperson thePerson C B C az62 oA A0theentrytheEntryB Z @ = o? ?0plugin_only_selected m> > boovtrue L m    6Check country name and code@ L m    BCheck all country names and codes  l=<;=<;  : iFI I98 9.az00az60nullnull8 7 7 az61 o6 60 theperson thePerson 5 4 5 az62 o3 30theentrytheEntry4 Z 2 = o1 10plugin_only_selected m0 0 boovtrue l  I / . /0country_name_code  - o , ,0 theperson thePerson-. .( only pass this person to the subroutine   P only pass this person to the subroutine2 l I+ * +0country_name_code  ) J(()* RL {} means: leave empty, the subroutine will fill it later (with all persons)   {} means: leave empty, the subroutine will fill it later (with all persons): adrbalisf Macintosh HDɏ1H+Address Book.app_ m Applicationsɏ#z Q+Macintosh HD:Applications:Address Book.app"Address Book.app Macintosh HDApplications/Address Book.app/  l'&%'&%  l$ $ xr------------------------------------------------------------------------------------------------------------------   ------------------------------------------------------------------------------------------------------------------  l# #  load all iso countries   . load all iso countries  l"! "!   iJM  I 0load_iso_country_list k3     l   ~ list is broken up in two parts to speed up the search. first search the large countries if that fails: search the small ones.    list is broken up in two parts to speed up the search. first search the large countries if that fails: search the small ones.   l  3- 103 large countries (population > 7 million)   Z 103 large countries (population > 7 million)   r   J     J     m    ao   m     Angola    J    m ! ! " "ar  # #m $ $ % %Argentina  & ' &J ( ( ) * )m + + , ,at * - -m . . / /Austria ' 0 1 0J  2 2 3 4 3m 5 5 6 6au 4 7 7m  8 8 9 9Australia 1 : ; :J < < = > =m ? ? @ @az > A Am B B C CAzerbaijan ; D E DJ F F G H Gm I I J Jbd H K Km L L M MBangladesh E N O NJ P P Q R Qm S S T Tbe R U Um V V W WBelgium O X Y XJ Z Z [ \ [m ] ] ^ ^bf \ _ _m ` ` a aBurkina Faso Y b c bJ ( d d e f em # g g h hbg f i im#& j j k kBulgaria c l m lJ(0 n n o p om(+ q q r rbi p s sm+. t t u uBurundi m v w vJ08 x x y z ym03 { { | |bj z } }m36 ~ ~   Benin w J8@   m8;    bo   m;>    Bolivia  J@H   m@C    br   mCF    Brazil  JHP   mHK    by  mKN    Belarus   JPX   mPS    ca  mSV    Canada   JX`   mX[    cd  m[^    @Democratic Republic of the Congo   J`h   m`c    ch  mcf    Switzerland   Jhp   mhk    ci  mkn    Cte d'Ivoire   Jpx   mps    cl   msv    Chile  Jx   mx{    cm   m{~    Cameroon  J   m    cn   m    China  J   m    co   m    Colombia  J   m    cs   m    Czech Republic  J   m    cu   m    Cuba    J     m    de   m    Germany  J     m    do   m    $Dominican Republic    J     m    dz   m    Algeria  ! J " " # $ #m % % & &ec $ ' 'm ( ( ) )Ecuador ! * + *J , , - . -m / / 0 0eg . 1 1m 2 2 3 3 Egypt + 4 5 4J 6 6 7 8 7m 9 9 : :es 8 ; ;m < < = = Spain 5 > ? >J @ @ A B Am C C D Det B E Em F F G GEthiopia ? H I HJ J J K L Km M M N Nfr L O Om P P Q Q France I R S RJ T T U V Um W W X Xgb V Y Ym Z Z [ [United Kingdom S \ ] \J ^ ^ _ ` _m a a b bgn ` c cm d d e e Guinea ] f g fJ h h i j im k k l lgr j m mm n n o o Greece g p q pJ r r s t sm u u v vgt t w wm x x y yGuatemala q z { zJ | | } ~ }m    hk ~ m    Hong Kong { J   m    hn  m     Honduras  J   m    ht  m    Haiti  J   m    hu  m    Hungary  J (   m #    id  m#&    Indonesia  J(0   m(+    il  m+.    Israel  J08   m03    in  m36    India  J8@   m8;    iq  m;>    Iraq  J@H   m@C    ir  mCF    Iran  JHP   mHK    it  mKN    Italy  JPX   mPS    ja  mSV    Japan  JX`   mX[    ke  m[^    Kenya  J`h   m`c    kh  mcf    Cambodia  Jhp   mhk    kp   mkn    North Korea    Jpx   mps    kr  msv    South Korea    Jx     mx{    kz   m{~    Kazakhstan    J     m    lk  ! !m " " # #Sri Lanka  $ % $J & & ' ( 'm ) ) * *ma ( + +m , , - -Morocco % . / .J 0 0 1 2 1m 3 3 4 4mg 2 5 5m 6 6 7 7Madagascar / 8 9 8J : : ; < ;m = = > >ml < ? ?m @ @ A AMali 9 B C BJ D D E F Em G G H Hmm F I Im J J K KMyanmar C L M LJ N N O P Om Q Q R Rmw P S Sm T T U U Malawi M V W VJ X X Y Z Ym [ [ \ \mx Z ] ]m ^ ^ _ _ Mexico W ` a `J b b c d cm e e f fmy d g gm h h i iMalaysia a j k jJ l l m n mm o o p pmz n q qm r r s sMozambique k t u tJ v v w x wm y y z zne x { {m | | } } Niger u ~  ~J   m    ng  m    Nigeria  J   m    nl  m    Netherlands  J   m    np  m    Nepal  J   m    pe  m    Peru  J   m    ph  m    Philippines  J   m    pk  m    Pakistan  J   m    pl  m    Poland  J   m    pt  m     Portugal  J   m    ro  m    Romania  J   m    rs  m    Serbia  J (   m #    ru  m#&    $Russian Federation  J(0   m(+    rw  m+.    Rwanda  J08   m03    sa  m36    Saudi Arabia  J8@ m8;sd m;>  Sudan   J@H     m@Cse mCF Sweden  JHP mHKsn mKNSenegal JPX  !" !mPS##$$so"% %mSV&&''Somalia() (JX`**+, +mX[--..sy,/ /m[^0011(Syrian Arab Republic)23 2J`h4456 5m`c7788td69 9mcf::;;Chad3<= <Jhp>>?@ ?mhkAABBth@C CmknDDEEThailand=FG FJpxHHIJ ImpsKKLLtnJM MmsvNNOOTunisiaGPQ PJxRRST Smx{UUVVtrTW Wm{~XXYY TurkeyQZ[ ZJ\\]^ ]m__``tw^a ambbcc Taiwan[de dJffgh gmiijjtzhk kmllmm6United Republic of Tanzaniaeno nJppqr qmssttuaru umvvwwUkraineoxy xJzz{| {m}}~~ug| m Uganday J mus mUnited States J muz mUzbekistan J mve mVenezuela J mvn mViet Nam J mye m Yemen J myu m*Serbia and Montenegro J mza mSouth Africa J mzm m Zambia J mzw mZimbabwe o 0big_iso_countries  l 2, 97 small countries (population < 7 million)X 97 small countries (population < 7 million) r1 J- J mad mAndorra J mae m(United Arab Emirates J  mag m&Antigua and Barbuda J  m    al  m     Albania   J mam mArmenia J! mba m  ,Bosnia and Herzegovina!" !J!)##$% $m!$&&''bb%( (m$'))**Barbados"+, +J)1--./ .m),0011bh/2 2m,/3344Bahrain,56 5J197789 8m14::;;bm9< <m47==>>Bermuda6?@ ?J9AAABC Bm9<DDEEbnCF Fm<?GGHH"Brunei Darussalam@IJ IJAIKKLM LmADNNOObsMP PmDGQQRRBahamasJST SJIQUUVW VmILXXYYbtWZ ZmLO[[\\ BhutanT]^ ]JQY__`a `mQTbbccbwad dmTWeeffBotswana^gh gJYaiijk jmY\llmmbzkn nm\_oopp Belizehqr qJaisstu tmadvvwwcfux xmdgyyzz0Central African Republicr{| {Jiq}}~ ~milcg mlo Congo| Jqy mqtcr mtwCosta Rica Jy my|cv m|Cape Verde J mcy m Cyprus J mdj mDjibouti J mdk mDenmark J mdm mDominica J mee mEstonia J mer mEritrea J mfi mFinland J mfj mFiji J mfk m Falkland Islands J mfo mFaroe Islands J mga m Gabon J     m    gd  mGrenada J mge mGeorgia J m  !!gl" "m##$$Greenland%& %J''() (m**++gm), ,m--.. Gambia&/0 /J1123 2m4455gq36 6m7788"Equatorial Guinea09: 9J ;;<= <m>>??gs=@ @mAABBPSouth Georgia and South Sandwich Islands:CD CJ EEFG Fm  HHIIgwGJ Jm KKLLGuinea-BissauDMN MJOOPQ PmRRSSgyQT TmUUVV GuyanaNWX WJ!YYZ[ Zm\\]]hr[^ ^m__``CroatiaXab aJ!)ccde dm!$ffggieeh hm$'iijjIrelandbkl kJ)1mmno nm),ppqqimor rm,/ssttIsle of Manluv uJ19wwxy xm14zz{{isy| |m47}}~~Icelandv J9A m9<jm m<?Jamaica JAI mADjo mDG Jordan JIQ mILkg mLOKyrgyzstan JQY mQTki mTWKiribati JYa mY\km m\_Comoros Jai madkw mdg Kuwait Jiq milky mloCayman Islands Jqy mqtla mtw@Lao People's Democratic Republic Jy my|lb m|Lebanon J mlc mSaint Lucia J mli mLiechtenstein J mlr mLiberia J mls mLesotho J mlt m    Lithuania   J   mlu mLuxembourg  J mlv~ m Latvia~ J!!"# "m$$%%ly#&} &m''(( Libya} )* )J++,- ,m..//mc-0| 0m1122 Monaco|*34 3J5567 6m8899md7:{ :m;;<<Moldova{4=> =J??@A @mBBCCmeADz DmEEFFMontenegroz>GH GJIIJK JmLLMMmkKNy NmOOPPMacedoniayHQR QJSSTU TmVVWWmnUXx XmYYZZMongoliaxR[\ [J]]^_ ^m``aamo_bw bmccdd Macaow\ef eJgghi hmjjkkmrilv lmmmnnMauritaniavfop oJqqrs rmttuumtsvu vmwwxx Maltaupyz yJ {{|} |m~~mu}t mMauritiustz J  m  mvs m Maldivess J mnar mNamibiar J! mncq mNew Caledoniaq J!) m!$nip m$'Nicaraguap J)1 m),noo m,/ Norwayo J19 m14nrn m47"Republic of Naurun J9A m9<nzm m<?New Zealandm JAI mADoml mDGOmanl JIQ mILpak mLO Panamak JQY mQTpfj mTW French Polynesiaj JYa mY\pgi m\_ Papua New Guineai Jai madpyh mdgParaguayh Jiq milqag mlo Qatarg Jqy mqt    sb  f  mtw  Solomon Islandsf Jy my|sce m|Seychellese J msg d  m!!""Singapored#$ #J%%&' &m(())sh'*c *m++,,Saint Helenac$-. -J//01 0m2233si14b 4m5566Sloveniab.78 7J99:; :m<<==sk;>a >m??@@Slovakiaa8AB AJCCDE DmFFGGslEH` HmIIJJSierra Leone`BKL KJMMNO NmPPQQsrOR_ RmSSTTSuriname_LUV UJWWXY XmZZ[[stY\^ \m]]^^*Sao Tome and Principe^V_` _Jaabc bmddeesvcf] fmgghhEl Salvador]`ij iJkklm lmnnooszmp\ pmqqrrSwaziland\jst sJuuvw vmxxyytgwz[ zm{{||Togo[t}~ }J mtjZ mTajikistanZ~ J mtlY mTimor-LesteY J mtmX mTurkmenistanX J mtoW m TongaW J mttV m&Trinidad and TobagoV J mtvU m TuvaluU J  muyT mUruguayT J  m  vaS m VaticanS J mvcR m@Saint Vincent and the GrenadinesR J! mvuQ mVanuatuQP J!) m!$wsO m$' SamoaOP oN N0small_iso_countries l22MM 5/ list of supported countries can be found here:^ list of supported countries can be found here: l22LL  http://developer.apple.com/library/ios/#documentation/AddressBook/Reference/ABPersonRef_iPhoneOS/Reference/reference.html#//apple_ref/c/data/kABPersonAddressCountryCodeKeyX http://developer.apple.com/library/ios/#documentation/AddressBook/Reference/ABPersonRef_iPhoneOS/Reference/reference.html#//apple_ref/c/data/kABPersonAddressCountryCodeKey l22KK  http://developer.apple.com/library/mac/#documentation/UserExperience/Reference/AddressBook/Classes/ABPerson_Class/Reference/CountryCodes.html#//apple_ref/doc/uid/TP40003945-RH2b http://developer.apple.com/library/mac/#documentation/UserExperience/Reference/AddressBook/Classes/ABPerson_Class/Reference/CountryCodes.html#//apple_ref/doc/uid/TP40003945-RH2 l22JJ ~x although the Address Book e.g. shows the country Afghanistan, but the list on the developer site does not show that one although the Address Book e.g. shows the country Afghanistan, but the list on the developer site does not show that one l22IHGIHGF l22EE  !!! do not add ISO codes to the above list, these are from Apple's own (iPhone) list and Apple will hide addresses with any other codes !!! !!! do not add ISO codes to the above list, these are from Apple's own (iPhone) list and Apple will hide addresses with any other codes !!!F  lDCBDCBA l@?>@?>A=<;:98     =76543210/.-,+*)('&%$# 70current_version 60 add_to_groups 50 show_results 40check_for_updates 30treat_iso_list_as_unknown 20plugin_only_selected 10country_name_code 0.aevtoappnull**** /%0!list_of_countries_in_address_book .!0find_iso_code_in_country_list -'0#check_and_fix_country_name_and_code ,0 prepare_growl +0send_growl_msg *0check_latest_version )0parse_version_output (0write_log_to_file '.az00az57nullnull &.az00az59nullnull %.az00az58nullnull $.az00az60nullnull #0load_iso_country_list < boovtrue ; boovtrue : boovtrue 9 boovfals 8 boovfals"p!  "0country_name_code! 0 localpeople LocalPeople  0 localpeople LocalPeople  0clist 0lets_get_new_version 0 starttime startTime  0locref  0loaref  0loiref  0 mycountry  0myiso  0calist 0myc 0myca 0endtimeendTime  0duration  0summary_ +14CHj t &0  0 mycountries   0 group_missing 0 group_unknown 0fill_empty_country 0default_country  0 use_growl  0testing 0check_latest_version  misccura .misccurdldt null 0 prepare_growl 0send_growl_msg 0load_iso_country_list 0changes_country 0 changes_code 0 names_checked 0addresses_checked 0list_of_countries 0list_of_aliases 0list_of_isocodes 0list_of_missing_countries 0list_of_unknown_countries 0 log_missing 0 log_unknown  kocl  cobj .corecnte********  bool  pcnt .ascrcmnt********  azf4  azf8 '0#check_and_fix_country_name_and_code  ret 0write_log_to_file  appr  btns .sysodlogaskrTEXT^jvEO),EOvlv6GOvlv6GOaamvlv6GOaaalvlv6GOaaalvlv6GOaakvlv6GOaE`OaE`OfE`OaE` OeE`!OfE`"Ob*bk+#EOhYhYhOa$ *j %EUO*j+&O*a'a(l+)O*j+*OjE`+OjE`,OjE`-OjE`.OjvE`/OjvE`0OjvE`1OjvE`2OjvE`3Oa4E`5Oa6E`7O)a/,EO)a0,EO)a1,EO[a8a9l :kha9k/EOa9l/EOa9k/EOa; a<a=&  a=&06FO6FO [a8a9l :kh a>,6F[OYYh[OYOa?Tj :j7_"e$a@j AO*aB-aC[aD,\ZaE81EEY *aB-EEYhOaFj :%aG%j AUO*k+HOa$ *j %EUOEOaI_J%aK%_-%_J%aL%_.%_J%_J%aM%_J%aN%_+%_J%aO%_,%_J%_J%aP%_J%aQ%_3j :%_J%aR%_2j :%_J%_J%aS%%aT%EOj AO_!D*aUl+)Obf _3j :ja=&*aVaW_3j :%aX%l+)YhYhObeG_2j :j _3j :ja=& *j+YYhO_! aZa[a\a] ^YhYhOP  .aevtoappnull**** 0country_name_code*jvk+ = %0!list_of_countries_in_address_book 0 localpeople LocalPeople 0 localpeople LocalPeople 0 theperson thePerson 0 theaddress theAddress 0 thecountry theCountry ko 0list_of_countries  kocl  cobj .corecnte********  az27  az32  msng  bool .ascrcmnt********djvEOLI[l kh4,[l kh,EEO  & 6FYh[OY[OYUOj Oj O  ! !0find_iso_code_in_country_list"" 0 country_alias 0 list_to_check  0 country_alias 0 list_to_check 0 mycountry 0myi 0myca 0myc!  kocl  cobj .corecnte********  pcls  listNF[l khk/EOl/EO, k/EYEO lvYh[OYOlv #$ '0#check_and_fix_country_name_and_code%% 0 localpeople LocalPeople# 0 localpeople LocalPeople 0 theperson thePerson 0 changes_made 0thenametheName 0 theaddress theAddress 0theaddresstypetheAddressType 0 message_str 0 thecountry theCountry 0thecountrycodetheCountryCode 0country_is_in_alias_list 0iso 0 preferred$6K(*8TVX  kocl  cobj .corecnte********  pnam  TEXT  az27  az18 .ascrcmnt********  az32  az33  msng 0fill_empty_country 0default_country 0list_of_missing_countries 0 log_missing  ret  az45  azf5 0 group_missing .az00az44nullazf6  prdt .corecrel****null 0list_of_aliases  bool 0big_iso_countries !0find_iso_code_in_country_list 0small_iso_countries 0 mycountries 0list_of_unknown_countries 0 log_unknown 0 group_unknown  az63 0changes_country 0 changes_code .coresavenullnull 0addresses_checked 0 names_checkedƠ[l khjEO,&EO,[l kh ,EWX %j OO%%%EO,EEO,EEOap__,FOkEYW_6FO_%_%E`Oa*a_/l W,X *aa_la Oa*a_/l YhOfEO_eEYhOa ea&aEO)_ l+!E[k/EZ[l/EZOa")_#l+!E[k/EZ[l/EZYhOa$_6FOkvlv_%6FYhOa& bea&h_'6FO_(a)%%a*%%a+%_%E`(Oa*a_,/l W,X *aa_,la Oa*a_,/l YhYhOa ea&)_%l+!E[k/EZ[l/EZOa- *a.,EYhOa/g",FO_0kE`0OkEYhVOa1 a a&a&,FOkEO_2kE`2Y a&hYhYhOj *j 3YhO_4kE`4[OYuO_5kE`5[OYHO*j 3U Z&'~ 0 prepare_growl&}| },0allnotificationslistallNotificationsList |40enablednotificationslistenabledNotificationsList'{kziyxwvutsrq { 0 use_growl z pcap y.coredoexboolobj x capp w kfrmID v appl u anot t dnot s iappr q.registernullnull~GC */j EUO hYhO)0kvEOEO* UOPYhpon()m p0send_growl_msgol*l*kj k0desc j0msgn(ih i0desc h0msg) gfedcba`_ g 0 use_growl f capp e kfrmID d name c titl b desc a appl` _.notifygrnullnullm!)0* UOPYh^]\+,[ ^0check_latest_version]Z-Z-Y Y0current_version\+ XWVUTSRQP X0current_version W 0myurl V 0mycmd U 0myloc T 0myoutput S0latest_version R0 version_date Q0version_description P 0 open_site,ONMLKORTJVY[IcfHjGFEoDCB}A O.sysoexecTEXTTEXTNM L0parse_version_output K cobj J ret I btns H dflt G givuF E apprD C.sysodlogaskrTEXT B bhit A.GURLGURLnullTEXT[%EO%%EOEO j EW XfO*k+E[k/EZ[l/EZ[m/EZOG%%%%%%%%%%%%%%aaalvaaaaaaa EW XfOa,a!aj UW XfOeYhYhOf@?>./= @0parse_version_output?<0<0; ; 0output>.:9876 : 0output 9"0saveddelimiterssavedDelimiters 8 0 myversion 7 0mydate 6 0mydesc/543210 5 ascr 4 txdl 3 citm 2 cobj10=E,EO&kv,FO-E[k/EZ[l/EZ[m/EZW X,FO,FOmv/.-12, /0write_log_to_file.-1+*)(' + 0mypath *0 the_content ) 0defco ( 0the_file '0fp2=&  %    $# y |  " !    ! $ R U \ _ o  &.earsffdralis afdr % ret $0list_of_unknown_countries #.corecnte******** "0 log_unknown !0list_of_missing_countries  az63 0 log_missing  bool  psxp  afdrdesk  TEXT  perm .rdwropenshorfile  refn  wrat .rdwrwritnull**** .rdwrclosnull**** .aevtodocnullalis,)j EOb%%%%%%%%%%%%%EOj jl%%%%%%%%%%%a%%a%%a%%a%%a%%a%%a%%%a%%a%%%a%%_%a%%%%EYhO_j jAa *a,EUOa%%a %%a!%%%a"%%_#%a$%%a%%%EYhO_j j j ja&& bea&&%a'%%a(%%a)%%EYhO_j j j ja&&*%a*%%a+%%a,,%%a-%%a.%%EYhOa/j a0&a1%EOa2el 3EOa4a5ka6 7WX89hOj :Oa;j ? 0load_iso_country_list>?   ! $ + . 5 8 ? B I L S V ] ` g j q t { ~      % ( / 2 9 < C F M P W Z a d k n u x        " ) , 3 6 = @ G J Q T [ ^ e h o r y | #&-07:ADKNUX_bilsv} &)03:=DGNQX[belovy  #*-47>AHKRU\_fipsz} $'.18;BELOVY`cjmtw~  !(+25<?FIPSZ]dgnqx{a 0big_iso_countriesg 0small_iso_countries4lvlvlvlvlvlvlvlvaalvaalvaalvaalvaalvaalvaalvaalva a!lva"a#lva$a%lva&a'lva(a)lva*a+lva,a-lva.a/lva0a1lva2a3lva4a5lva6a7lva8a9lva:a;lvaa?lva@aAlvaBaClvaDaElvaFaGlvaHaIlvaJaKlvaLaMlvaNaOlvaPaQlvaRaSlvaTaUlvaVaWlvaXaYlvaZa[lva\a]lva^a_lva`aalvabaclvadaelvafaglvahailvajaklvalamlvanaolvapaqlvaraslvataulvavawlvaxaylvaza{lva|a}lva~alvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvavE`Oaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaalvaa lva a lva a lvaalvaalvaalvaalvaalvaalvaalvaalvaalva a!lva"a#lva$a%lva&a'lva(a)lva*a+lva,a-lva.a/lva0a1lva2a3lva4a5lva6a7lva8a9lva:a;lvaa?lva@aAlvaBaClvaDaElvaFaGlvaHaIlvaJaKlvaLaMlvaNaOlvaPaQlvaRaSlvaTaUlvaVaWlvaXaYlvaZa[lva\a]lva^a_lva`aalvabaclvadaelvafaglvahailvajaklvalamlvanaolvapaqlvaraslvataulvavawlvaxaylvaza{lva|a}lva~alvaalvaalvaalvaalvaalvaalvaalvaalvaalvavE`OPascr ޭ