I’ve been working on an AppleScript for a couple of weeks now to automate some site searches. It works pretty much as I need, but after trying to add a new resource today, I found that this failed because the German umlaut letters (ä,ö,ü) were not being pasted correctly into the required URL.
Here is the site:
If you put enter an umlauted word (for instance “selbständig”) at the site itself, this is converted to “selbst%E4ndig”.
Clearly, I need my script to convert the umlaut letters to their HTML equivalents so that searches can be processed. Please note this isn’t a problem for all the sites in my script, only some. But if you change the umlaut letters to their HTML equivalents, this seems to work for all the sites, thus my desire to find a way to convert them.
I found the following in the lists.apple.com archives, but am not sure if it’s what i need or how to apply it in my script:
http://lists.apple.com/archives/Applescript-users/2002/Mar/msg00900.html
property SZListe : {"C", "\"", "<", ">", "B!", "B\"", "B#", "B%", "B'", "B(", "B)", "B*", "B+", "B,", "B.", "B0", "B1", "B4", "B5", "B6", "B7", "B8", "B:", "B;", "B?", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C ", "C
", "C", "C", "C
", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C ", "C!", "C\"", "C#", "C$", "C%", "C&", "C'", "C(", "C)", "C*", "C+", "C,", "C-", "C.", "C/", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "C:", "C;", "C<", "C?", "b\"", "b", "b\"", "b,", "b", "b", "b", "b", "b", "b"}
property ESListe : {"ß", """, "<", ">", "¡", "¢", "£", "¥", "§", "¨", "©", "ª", "«", "¬", "®", "°", "±", "´", "µ", "¶", "·", "¸", "º", "»", "¿", "À", "Á", "", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "Ø", "Ù", "Ú", "Û", "Ü", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ÿ", "•", "⁄", "™", "€", "‘", "’", "‚", "“", "”", "„"}
set theText to "Whatever you like to test"
considering case, diacriticals and punctuation
if theText is not "" then
if theText contains "&" then
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"&"}
set ls to text items of theText
set AppleScript's text item delimiters to {"&"}
set theText to ls as string
set AppleScript's text item delimiters to oldDelims
end if
repeat with i from 1 to the count of items in SZListe
if theText contains item i of SZListe then
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to item i of SZListe
set ls to text items of theText
set AppleScript's text item delimiters to item i of ESListe
set theText to ls as string
set AppleScript's text item delimiters to oldDelims
end if
end repeat
end if
end considering
I tried copying it into the top of my script and changing “theText” to “search” (my search variable), but this sadly did not work.
Here is my script:
set search to text returned of (display dialog "Enter Search Query - Joint Terms with \"+\":" default answer "" buttons {"Search", "Cancel"} default button "Search")
set lang to {"German", "Dutch", "Google Tools", "Reference", "Currency Converter"}
set langSelect to (choose from list lang with prompt "Make Selection:" without multiple selections allowed) as text
if langSelect is "German" then
set sites to {"Linguee", "Woerterbuch.info", "Uni Leipzig", "Langenscheidt", "Google", "Google Images", "Wiki.de", "Lisa", "SAP.com", "Pons", "Dict.cc", "Eur-Lex", "UBS Banking", "MS Language Portal", "WIPO", "IATE", "All Sites"}
set chosen to (choose from list sites with prompt "Make Selection:" without multiple selections allowed) as text
if chosen is "Linguee" then
open location "http://www.linguee.com/english-german/search?sourceoverride=none&source=auto&query=" & search
else if chosen is "Woerterbuch.info" then
open location "http://www.woerterbuch.info/?query=" & search & "&s=dict&l=en"
else if chosen is "Uni Leipzig" then
open location "http://dict.uni-leipzig.de/"
else if chosen is "Langenscheidt" then
open location "http://www.wissen.de/wde/generator/wissen/services/suche/wb/index.html?dictqry=" & search & "&Start=%A0%A0Suchen%A0%A0&dictlang=en"
else if chosen is "Google" then
open location "http://translate.google.com/?hl=en&eotf=0&sl=de&q=" & search
else if chosen is "Google Images" then
open location "http://images.google.co.uk/search?tbm=isch&hl=en&source=hp&biw=1440&bih=723&q=" & search & "&gbv=2&oq=" & search & "&aq=f&aqi=g10&aql=&gs_sm=e&gs_upl=1760l3034l0l4125l6l6l0l0l0l0l183l767l1.5l6l0"
else if chosen is "Wiki.de" then
open location "http://de.wikipedia.org/wiki/" & search
else if chosen is "Lisa" then
open location "http://lisa-woerterbuch.de/%C3%9Cbersetzung/Deutsch-Englisch/" & search & ".html"
else if chosen is "SAP.com" then
open location "http://help.sap.com/saphelp_glossary/de/index.htm"
else if chosen is "Pons" then
open location "http://mobile.pons.eu/dict/search/mobile-results/?l=deen&q=" & search
else if chosen is "Dict.cc" then
open location "http://www.dict.cc/?s=" & search
else if chosen is "Eur-Lex" then
open location "http://eur-lex.europa.eu/Result.do?arg0=" & search & "&arg1=" & search & "&arg2=&titre=titreettexte&chlang=de&RechType=RECH_mot&Submit=Suche"
else if chosen is "UBS Banking" then
open location "http://www.ubs.com/3/g?lo=t&qt=" & search & "&utf=€"
else if chosen is "MS Language Portal" then
open location "http://www.microsoft.com/Language/en-US/Search.aspx"
else if chosen is "WIPO" then
open location "http://www.wipo.int/classifications/nivilo/nice/index.htm?lang=DE#"
else if chosen is "IATE" then
open location "http://iate.europa.eu/iatediff/SearchByQueryLoad.do?method=load"
else if chosen is "All Sites" then
open location "http://www.linguee.com/english-german/search?sourceoverride=none&source=auto&query=" & search
open location "http://www.woerterbuch.info/?query=" & search & "&s=dict&l=en"
open location "http://dict.uni-leipzig.de/"
open location "http://www.wissen.de/wde/generator/wissen/services/suche/wb/index.html?dictqry=" & search & "&Start=%A0%A0Suchen%A0%A0&dictlang=en"
open location "http://translate.google.com/?hl=en&eotf=0&sl=de&q=" & search
open location "http://images.google.co.uk/search?tbm=isch&hl=en&source=hp&biw=1440&bih=723&q=" & search & "&gbv=2&oq=" & search & "&aq=f&aqi=g10&aql=&gs_sm=e&gs_upl=1760l3034l0l4125l6l6l0l0l0l0l183l767l1.5l6l0"
open location "http://de.wikipedia.org/wiki/" & search
open location "http://lisa-woerterbuch.de/%C3%9Cbersetzung/Deutsch-Englisch/" & search & ".html"
open location "http://help.sap.com/saphelp_glossary/de/index.htm"
open location "http://mobile.pons.eu/dict/search/mobile-results/?l=deen&q=" & search
open location "http://www.dict.cc/?s=" & search
open location "http://eur-lex.europa.eu/Result.do?arg0=" & search & "&arg1=" & search & "&arg2=&titre=titreettexte&chlang=de&RechType=RECH_mot&Submit=Suche"
open location "http://www.ubs.com/3/g?lo=t&qt=" & search & "&utf=€"
open location "http://www.microsoft.com/Language/en-US/Search.aspx"
open location "http://www.wipo.int/classifications/nivilo/nice/index.htm?lang=DE#"
open location "http://iate.europa.eu/iatediff/SearchByQueryLoad.do?method=load"
end if
else
if langSelect is "Dutch" then
set sites to {"MWB", "Google", "Wiki.nl", "van Dale", "Woordenboek.eu", "Dict.cc", "LookWayUp", "BabLa", "Vertalen.nu", "Euro-Lex", "IATE", "MS Language Portal", "All Sites"}
set chosen to (choose from list sites with prompt "Make Selection:" without multiple selections allowed) as text
if chosen is "MWB" then
open location "http://www.mijnwoordenboek.nl/vertalen.php?woord=" & search
else if chosen is "Google" then
#open location "http://translate.google.com/#nl|en|" & search
open location "http://translate.google.com/?hl=en&eotf=0&sl=nl&q=" & search
else if chosen is "Wiki.nl" then
open location "http://nl.wikipedia.org/wiki/" & search
else if chosen is "van Dale" then
open location "http://www.vandale.nl/vandale/zoekService.do?selectedDictionary=nn&selectedDictionaryName=Nederlands&searchQuery=" & search
else if chosen is "Woordenboek.eu" then
open location "http://www.online-languages.info/_ud2/ud2.php?l1=dutch&disa=1&rad=exact&w=" & search & "&searchword=" & search & "&nllang=Engels"
else if chosen is "Dict.cc" then
open location "http://ennl.dict.cc/?s=" & search
else if chosen is "LookWayUp" then
open location "http://lookwayup.com/lwu.exe/lwu/toEng?s=d&w=" & search & "&slang=Nld"
else if chosen is "BabLa" then
open location "http://nl.bab.la/woordenboek/nederlands-engels/" & search
else if chosen is "Vertalen.nu" then
open location "http://www.vertalen.nu/vertaal?vertaal=" & search & "&van=nl&naar=eng"
else if chosen is "Euro-Lex" then
open location "http://eur-lex.europa.eu/Result.do?arg0=" & search & "&arg1=" & search & "&arg2=&titre=titreettexte&chlang=nl&RechType=RECH_mot&Submit=Zoeken"
else if chosen is "IATE" then
open location "http://iate.europa.eu/iatediff/SearchByQueryLoad.do?method=load"
else if chosen is "MS Language Portal" then
open location "http://www.microsoft.com/Language/en-US/Search.aspx"
else if chosen is "All Sites" then
open location "http://www.mijnwoordenboek.nl/vertalen.php?woord=" & search
open location "http://translate.google.com/?hl=en&eotf=0&sl=nl&q=" & search
open location "http://nl.wikipedia.org/wiki/" & search
open location "http://www.vandale.nl/vandale/zoekService.do?selectedDictionary=nn&selectedDictionaryName=Nederlands&searchQuery=" & search
open location "http://www.online-languages.info/_ud2/ud2.php?l1=dutch&disa=1&rad=exact&w=" & search & "&searchword=" & search & "&nllang=Engels"
open location "http://ennl.dict.cc/?s=" & search
open location "http://lookwayup.com/lwu.exe/lwu/toEng?s=d&w=" & search & "&slang=Nld"
open location "http://nl.bab.la/woordenboek/nederlands-engels/" & search
open location "http://www.vertalen.nu/vertaal?vertaal=" & search & "&van=nl&naar=eng"
open location "http://eur-lex.europa.eu/Result.do?arg0=" & search & "&arg1=" & search & "&arg2=&titre=titreettexte&chlang=nl&RechType=RECH_mot&Submit=Zoeken"
open location "http://iate.europa.eu/iatediff/SearchByQueryLoad.do?method=load"
open location "http://www.microsoft.com/Language/en-US/Search.aspx"
end if
else
if langSelect is "Google Tools" then
set sites to {"Site Translation", "Books", "Images", "Blogs", "Finance", "News", "Products", "Trends", "All Sites"}
set chosen to (choose from list sites with prompt "Make Selection:" without multiple selections allowed) as text
if chosen is "Site Translation" then
open location "http://translate.google.co.uk/translate?hl=en&sl=fr&tl=en&u=" & search
else if chosen is "Books" then
open location "http://www.google.co.uk/search?tbm=bks&tbo=1&q=" & search
else if chosen is "Images" then
open location "http://images.google.co.uk/search?tbm=isch&hl=en&source=hp&biw=1440&bih=723&q=" & search & "&gbv=2&oq=" & search & "&aq=f&aqi=g10&aql=&gs_sm=e&gs_upl=1760l3034l0l4125l6l6l0l0l0l0l183l767l1.5l6l0"
else if chosen is "Blogs" then
open location "http://www.google.co.uk/search?tbm=blg&hl=en&source=hp&biw=&bih=&q=" & search & "&btnG=Search"
else if chosen is "Finance" then
open location "http://www.google.co.uk/finance?q=" & search
else if chosen is "News" then
open location "http://www.google.co.uk/search?aq=f&hl=en&gl=uk&tbm=nws&btnmeta_news_search=1&q=" & search
else if chosen is "Products" then
open location "http://www.google.co.uk/search?q=" & search & "&hl=en&tbm=shop&aq=f&oq=&aq=f"
else if chosen is "Trends" then
open location "http://www.google.co.uk/trends?q=" & search
else if chosen is "All Sites" then
open location "http://www.google.co.uk/search?tbm=bks&tbo=1&q=" & search
open location "http://images.google.co.uk/search?tbm=isch&hl=en&source=hp&biw=1440&bih=723&q=" & search & "&gbv=2&oq=" & search & "&aq=f&aqi=g10&aql=&gs_sm=e&gs_upl=1760l3034l0l4125l6l6l0l0l0l0l183l767l1.5l6l0"
open location "http://www.google.co.uk/search?tbm=blg&hl=en&source=hp&biw=&bih=&q=" & search & "&btnG=Search"
open location "http://www.google.co.uk/finance?q=" & search
open location "http://www.google.co.uk/search?aq=f&hl=en&gl=uk&tbm=nws&btnmeta_news_search=1&q=" & search
open location "http://www.google.co.uk/search?q=" & search & "&hl=en&tbm=shop&aq=f&oq=&aq=f"
open location "http://www.google.co.uk/trends?q=" & search
end if
else
if langSelect is "Reference" then
set sites to {"Acronyms", "Google Scholar", "Google Images", "OED Online", "JStor", "DOAJ", "ERIC", "InfoMine", "Intute", "Archive.org", "FIS Paedagogik", "BASE", "Scirus", "ScienceDirect", "US Med Library", "All Sites"}
set chosen to (choose from list sites with prompt "Make Selection:" without multiple selections allowed) as text
if chosen is "Acronyms" then
open location "http://www.chemie.fu-berlin.de/cgi-bin/acronym?" & search
else if chosen is "Google Scholar" then
open location "http://scholar.google.co.uk/scholar?q=" & search & "&hl=en&btnG=Search&as_sdt=1%2C5&as_sdtp=on"
else if chosen is "Google Images" then
open location "http://images.google.co.uk/search?tbm=isch&hl=en&source=hp&biw=1440&bih=723&q=" & search & "&gbv=2&oq=" & search & "&aq=f&aqi=g10&aql=&gs_sm=e&gs_upl=1760l3034l0l4125l6l6l0l0l0l0l183l767l1.5l6l0"
else if chosen is "OED Online" then
open location "http://www.oed.com/search?searchType=dictionary&q=" & search & "&_searchBtn=Search"
else if chosen is "JStor" then
open location "http://www.jstor.org/action/doBasicSearch?Query=" & search & "&acc=off&wc=on"
else if chosen is "DOAJ" then
open location "http://www.doaj.org/doaj?func=findJournals&uiLanguage=en&hybrid=&query=" & search
else if chosen is "ERIC" then
open location "http://eric.ed.gov/ERICWebPortal/search/simpleSearch.jsp?newSearch=true&eric_sortField=&searchtype=keyword&pageSize=10&ERICExtSearch_SearchValue_0=" & search & "&eric_displayStartCount=1&_pageLabel=ERICSearchResult&ERICExtSearch_SearchType_0=kw"
else if chosen is "InfoMine" then
open location "http://infomine.ucr.edu/"
else if chosen is "Intute" then
open location "http://www.intute.ac.uk/cgi-bin/search.pl?term1=" & search & "&submit=Search&limit=0&subject=All"
else if chosen is "Archive.org" then
open location "http://www.archive.org/search.php?query=" & search
else if chosen is "FIS Paedagogik" then
open location "http://www.fachportal-paedagogik.de/metasuche/fpp_list.html?feldinhalt1=" & search & "&senden=Suchen&bool1=and&feldname1=Freitext&mtz=20&ckd=yes&art=einfach&searchall=1"
else if chosen is "BASE" then
open location "http://www.base-search.net/Search/Results?lookfor=" & search & "&type=all&lem=0&lem=1&refid=dcbasen"
else if chosen is "Scirus" then
open location "http://www.scirus.com/srsapp/search?q=" & search & "&t=all&sort=0&g=s"
else if chosen is "ScienceDirect" then
open location "http://www.sciencedirect.com/science?_ob=HomePageURL&_method=userHomePage&_btn=Y&_zone=TopNavBar&_origin=quicksearch&_acct=C000228598&_version=1&_urlVersion=0&_userid=10&md5=494fed7897aed3b6989cdd524846b384"
else if chosen is "US Med Library" then
open location "http://www.ncbi.nlm.nih.gov/pubmed?term=" & search
else if chosen is "All Sites" then
open location "http://www.chemie.fu-berlin.de/cgi-bin/acronym?" & search
open location "http://scholar.google.co.uk/scholar?q=" & search & "&hl=en&btnG=Search&as_sdt=1%2C5&as_sdtp=on"
open location "http://images.google.co.uk/search?tbm=isch&hl=en&source=hp&biw=1440&bih=723&q=" & search & "&gbv=2&oq=" & search & "&aq=f&aqi=g10&aql=&gs_sm=e&gs_upl=1760l3034l0l4125l6l6l0l0l0l0l183l767l1.5l6l0"
open location "http://www.oed.com/search?searchType=dictionary&q=" & search & "&_searchBtn=Search"
open location "http://www.jstor.org/action/doBasicSearch?Query=" & search & "&acc=off&wc=on"
open location "http://www.doaj.org/doaj?func=findJournals&uiLanguage=en&hybrid=&query=" & search
open location "http://eric.ed.gov/ERICWebPortal/search/simpleSearch.jsp?newSearch=true&eric_sortField=&searchtype=keyword&pageSize=10&ERICExtSearch_SearchValue_0=" & search & "&eric_displayStartCount=1&_pageLabel=ERICSearchResult&ERICExtSearch_SearchType_0=kw"
open location "http://infomine.ucr.edu/"
open location "http://www.intute.ac.uk/cgi-bin/search.pl?term1=" & search & "&submit=Search&limit=0&subject=All"
open location "http://www.archive.org/search.php?query=" & search
open location "http://www.fachportal-paedagogik.de/metasuche/fpp_list.html?feldinhalt1=" & search & "&senden=Suchen&bool1=and&feldname1=Freitext&mtz=20&ckd=yes&art=einfach&searchall=1"
open location "http://www.base-search.net/Search/Results?lookfor=" & search & "&type=all&lem=0&lem=1&refid=dcbasen"
open location "http://www.scirus.com/srsapp/search?q=" & search & "&t=all&sort=0&g=s"
open location "http://www.sciencedirect.com/science?_ob=HomePageURL&_method=userHomePage&_btn=Y&_zone=TopNavBar&_origin=quicksearch&_acct=C000228598&_version=1&_urlVersion=0&_userid=10&md5=494fed7897aed3b6989cdd524846b384"
open location "http://www.ncbi.nlm.nih.gov/pubmed?term=" & search
end if
else if langSelect is "Currency Converter" then
open location "http://www.xe.com/ucc/convert/?Amount=" & search & "&From=EUR&To=GBP"
end if
end if
end if
end if
Can anyone help?
Thanks,
Bowjest