Hunspell - Can't open affix or dictionary files for dictionary named en_US

23.5k views Asked by At

I'd like to use hunspell to spell check my repo. However when I try to run it I get the following error:

Can't open affix or dictionary files for dictionary named "en_US".

How can I fix this? I'm on a Mac.

Thanks, Kevin

3

There are 3 answers

5
Divinenephron On BEST ANSWER

Execute hunspell -D. You should get output like this:

.::/usr/share/hunspell:/usr/share/myspell:
/usr/share/myspell/dicts:/Library/Spelling:

AVAILABLE DICTIONARIES (path is not mandatory for -d option):
/Library/Spelling/en_GB
LOADED DICTIONARY:
/Library/Spelling/en_GB.aff
/Library/Spelling/en_GB.dic

This lists the directories in which hunspell is searching for dictionary files, as well as the dictionaries is has found. If the dictionary en_US isn't listed, you haven't got that particular dictionary installed.

To install a dictionary, search for it in the LibreOffice extension repository. Download it then extract the .aff and .dic files to one of the locations listed by hunspell -D. For example:

# First download dict-en.oxt
unzip dict-en.oxt -d dict-en
cp dict-en/en_GB.aff dict-en/en_GB.dic ~/Library/Spelling/
rm -r dict-en
1
pksec On

I'm using emacs in windows using msys2. I installed following 2 packages:

pacman -S  mingw-w64-x86_64-hunspell-en mingw-w64-x86_64-hunspell

The mingw-w64-x86_64-hunspell-en package install english dictionaries in /mingw64/share/hunspell, but you check if the files (en_US.dic and en_US.aff) are available or not.

Steps:

  1. set the Environment Variable in .bashrc within mysys2. Without DICPATH it was not working for me.

    export DICTIONARY=en_US
    export DICPATH=/d/../msys2/ming164/share/hunspell
    
  2. run hunspell.exe -D

    SEARCH PATH:
    .;... ;...;...
    AVAILABLE DICTIONARIES (path is not mandatory for -d option):
    D:/xx/mysys64/mingw64/share/hunspell/en_AG
    D:/xx/mysys64/mingw64/share/hunspell/en_AU
    ...
    

    Hunspell 1.6.0

0
novski On

I was lucky to find my language here: https://extensions.openoffice.org/en/search?query=de_CH&sort_by=field_project_stats_year&sort_order=DESC

And with the comment from @RobDavenport i was able to rename the extension and extract the files. Something i reread at this link and gave it a try. I dropped the .dic .dat and .aff into my ~/Library/Spelling/ folder.