5

I have a large .tex file that contains two languages and I want to spellcheck it without going crazy. So just spellchecking for one language and pressing "ignore" for words from the other language is not an option.

So I read up on aspell and found out you can define your own .multi files to combine dictionaries. But apparently you can't do this for dictionaries from different languages, it throws an error (or, if you're working from a GUI, the dictionary will just appear empty).

Also, I found a bug report putting this feature on the wishlist, but it seems no one has implemented it yet.

So, my question is: Are there any sane ways of using two dictionaries for two different languages at once?

This problem gave me a headache and there's next to no documentation on how to do it on the internet. So, I'll put up the workaround I found as an answer, to save anyone else (including future me) the trouble. But if you have a better solution, please post it.

1 Answer 1

3

So, here's my how-to:

Step 1: Find your aspell dictionaries on your system. I found them in /usr/lib/aspell/. You will see .multi and .rws files. All the following commands are to be executed in that directory.

Step 2: Generate wordlists from the dictionaries you want. If the dictionaries have affixes stored with the words, you need to expand them.

aspell --lang=en --master=en.multi  dump master > /home/user/meinwoerterbuch.txt
aspell -d de dump master | aspell -l de expand | perl -e 'while(<>){ print join("\n", split), "\n";}' >> /home/user/meinwoerterbuch.txt 

Here the German dictionary had to be expanded, and because I wanted one word per line, I used perl to take several words per line and print each of them on an extra line. Just look at the output of aspell (I recommend head) to see if you need to expand your dictionary or not.

Step 3: Choose a language name for your dictionary. I chose Hungarian, because I'm pretty sure I'm never going to actually use a Hungarian dictionary for spellchecking, and that way it will be easy to find. I think it has to be something with a valid ISO language code. For Hungarian, that's hu.

Step 4: Create hu.dat and hu_phonet.dat files. The most stripped down versions that seem to work are:

hu.dat:

name hu 
charset iso8859-1
soundslike hu 

hu_phonet.dat:

version 0.1-2002.12.15-3

Step 5: Create your merged dictionary with

sudo aspell --lang=hu --encoding=utf-8 create master ./hu.rws < /home/user/meinwoerterbuch.txt

I had to put the encoding=utf-8, because the txt file is utf-8 encoded. It threw errors without it.

Step 6: Create an appropriate hu.multi file like this:

add hu.rws

Step 7: Choose Hungarian in your spellchecker and start spellchecking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.