hunspell / hunspell

The most popular spellchecking library.

Home Page:http://hunspell.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hunspell with mutliple dictionaries on macos

ChauhanT opened this issue · comments

Hi,

I want to use flyspell with a hunspell backed. I prefer hunspell because it offers multilanguage dictionaries which can be very useful for me. My configuration is:

(setq +v/LANG "en_GB"
      +v/DICPATH "/Users/tc/Library/Spelling/"
      +v/MULTIDIC "en_GB,en_US,de_DE")

(use-package flyspell
  :straight t
  :after ispell
  :init
  ;; Set the locale for the dictionary
  (if (string-equal system-type "darwin")
      (setenv "DICTIONARY" "en_GB"))
  
  (setenv "LANG" +v/LANG)

  ;; Dictionary path
  (setenv "DICPATH" +v/DICPATH)
  
  :config
  ;; Use hunspell
  (setq ispell-program-name "hunspell")
  (setq ispell-really-hunspell t)

  ;; ispell-set-spellchecker-params has to be called
  ;; before ispell-hunspell-add-multi-dic will work
  (ispell-set-spellchecker-params)

  ;; Declare a multi-language dictionary and switch to it
  (ispell-hunspell-add-multi-dic +v/MULTIDIC)
  (ispell-change-dictionary +v/MULTIDIC t))

However, this does not work. My dictionary folder is populated like so:

❯ tree ~/Library/Spelling
/Users/tc/Library/Spelling
├── dynamic-counts.dat
├── en_GB.aff
├── en_GB.dic
├── en_US.aff
├── en_US.dic
├── fr_FR.aff
├── fr_FR.dic
├── it_IT.aff
└── it_IT.dic

1 directory, 9 files

While hunspell is detected, it fails to detect any dictionary :( I test this like so:

❯ hunspell
Hunspell 1.7.2
welcome
# welcome 0

test
# test 0

sadness
# sadness 0

I am on macos 13.3.1. Any help/trick/ideas ? It's totally driving me up the wall.

What does:

hunspell -D 2>&1|less

report?, to check what paths it is searching, and what it claims to find

Ah yes. Sorry should have reported that. I had made sure it was finding the right path before reporting this. The output is:

❯ hunspell -D
SEARCH PATH:
.::/usr/share/hunspell:/usr/share/myspell:/usr/share/myspell/dicts:/Library/Spelling:/Users/tc/.openoffice.org/3/user/wordbook:/Users/tc/.openoffice.org2/user/wordbook:/Users/tc/.openoffice.org2.0/user/wordbook:/Users/tc/Library/Spelling:/opt/openoffice.org/basis3.0/share/dict/ooo:/usr/lib/openoffice.org/basis3.0/share/dict/ooo:/opt/openoffice.org2.4/share/dict/ooo:/usr/lib/openoffice.org2.4/share/dict/ooo:/opt/openoffice.org2.3/share/dict/ooo:/usr/lib/openoffice.org2.3/share/dict/ooo:/opt/openoffice.org2.2/share/dict/ooo:/usr/lib/openoffice.org2.2/share/dict/ooo:/opt/openoffice.org2.1/share/dict/ooo:/usr/lib/openoffice.org2.1/share/dict/ooo:/opt/openoffice.org2.0/share/dict/ooo:/usr/lib/openoffice.org2.0/share/dict/ooo
AVAILABLE DICTIONARIES (path is not mandatory for -d option):
/Users/tc/Library/Spelling/fr_FR
/Users/tc/Library/Spelling/it_IT
/Users/tc/Library/Spelling/en_GB
/Users/tc/Library/Spelling/en_US
LOADED DICTIONARY:
/Users/tc/Library/Spelling/en_US.aff
/Users/tc/Library/Spelling/en_US.dic

And I also confirmed I'm not running some other binary by:

❯ which hunspell
/opt/homebrew/bin/hunspell

~
❯ /opt/homebrew/bin/hunspell -d en_GB
Hunspell 1.7.2
work
# work 0

sadness
# sadness 0