-- see settings on seescriptsettings() return {keyboardShortcut:"^~@T", displayName:"Stavekontroll", inContextMenu:"yes"} end seescriptsettings -- Script variables set speller_program to "hfst-ospell-office" -- Finn stavekontrollprogrammet: set shellscriptString to  "export PATH=/usr/local/bin:/opt/local/bin:$PATH; which " & speller_program try set path_prog_speller to do shell script shellscriptString on error display alert "Make Response" message "Fann ikkje '" &  speller_program &  "'" as informational buttons {"OK"} default button "OK" return end try -- Finn pkg-config: set shellscriptString to "export PATH=/usr/local/bin:/opt/local/bin:$PATH; which pkg-config" try set path_prog_pkgconfig to do shell script shellscriptString on error display alert "Make Response" message  "Fann ikkje 'pkg-config'" as informational buttons {"OK"} default button "OK" return end try -- Finn ei sprŒkpakke: set shellscriptString to  "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig " &  path_prog_pkgconfig & " --list-all | fgrep giella | cut -d' ' -f1 | head -n1 " try set spraakpakke to do shell script shellscriptString on error display alert  "SprŒkpakke:" message "Fann ikkje ei einaste sprŒkpakke" as informational  buttons {"OK"} default button "OK" return end try set shellscriptString to  "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig " &  path_prog_pkgconfig & " --variable=dir " & spraakpakke try set pkg_path to do shell script shellscriptString on error display alert "SprŒkpakke:" message "Fann ikkje '" &  spraakpakke & "'" as informational  buttons {"OK"} default button "OK" return end try -- Definer sti til zhfst-fil ut frŒ sprŒkpakka: set zhfst_dir to pkg_path & "/../../voikko/3/" -- Finn alle installerte zhfst-filer: set shellscriptString to  "ls " & zhfst_dir & " | cut -d'.' -f1 | tr ' ' ' ' | sed 's/ $//' " try set language_list to do shell script shellscriptString on error display alert "SprŒkpakke:" message "Fann ingen zhfst-filer." as informational  buttons {"OK"} default button "OK" return end try -- Konverter lista til ei AS-liste: set old_delimts to AppleScript's text item delimiters set AppleScript's text item delimiters to " " set text_list to text items of language_list set AppleScript's text item delimiters to old_delimts set default_language to text of first item of text_list -- Vis dialog med liste over tilgjengelege sprŒk: set spraak to (choose from list text_list  with title  "Vel stavekontrollsprŒk" with prompt  "SprŒk" default items {default_language}) -- Lag full sti til zhfst-fila: if the result is not false then set zhfst_fil to zhfst_dir & spraak & ".zhfst" else return end if -- K¿yr stavekontroll i SEE: tell application "SubEthaEdit" set savedClipboard to the clipboard set the clipboard to contents of selection as text set shellscriptString to  "export __CF_USER_TEXT_ENCODING=`id -u`:0x8000100:0x8000100; pbpaste | tr ' ' ' ' | sed 's/^/5 /' | " &  path_prog_speller & " " & zhfst_fil &  " | tail +2 > /tmp/spellerpipe ; pbpaste | tr ' ' ' ' | paste - /tmp/spellerpipe " set shellresult to do shell script shellscriptString without altering line endings set the clipboard to savedClipboard set contents of selection of front document to shellresult end tell