How can I spell check for multiple languages in emacs?
Asked Answered
P

1

10

I write mostly my documentation in HTML using emacs as my main editor. Emacs let you interactively spell-check the current buffer with the command ispell-buffer.

Since I switch between a number of languages, I have an HTML comment at the end of the file specifying the main dictionary and personal dictionary for that file, E.g. for Norwegian (norsk) I use the following pair of dictionaries:

<!-- Local IspellDict: norsk -->
<!-- Local IspellPersDict: ~/.aspell/personal.dict -->

This works great.

However, sometimes I have a paragraph in another language (e.g. English) embedded in an otherwise Norwegian document. Example:

<p xml:lang="en">This paragraph is in English.</p>

The spell-checker naturally flag all the words in such a paragraph as misspellings (since the dictionary only contain Norwegian words).

To avoid this, I've tried to add a "british" dictionary to the document, like this:

<!-- Local IspellDict: british -->
<!-- Local IspellDict: norsk -->
<!-- Local IspellPersDict: ~/.aspell/personal.dict -->

Unfortunately, this does not work. The "british" dictionary is simply ignored.

My prefered solution would to load an additional dictionary and use this, toghether with the primary dictionary, for spell-checking. Is this possible?

However, I am also interested in a solution that let me mark paragraphs for not being spell checked. It is not ideal, but it would stop valid English words from being flagged as misspellings.

PS: I have also looked at the answer to this question: Multilingual spell checking with language detection, but it is much broader and does not address the specific use emacs ispell for doing the spell-check.

Playoff answered 2/6, 2013 at 10:29 Comment(1)
possible duplicate of How to define two ispell dictionaries in Emacs for LaTeX mode?Craquelure
G
1

Try ispell-multi and flyspell-xml-lang http://www.dur.ac.uk/p.j.heslin/Software/Emacs/

You can spawn multiple instances of ispell, and use the xml:lang tag to decide which language to check for.

Gaga answered 2/6, 2013 at 11:1 Comment(1)
Thanks for the suggestion. I've loaded ispell-multi and flyspell-xml-lang and tagged the English paragraphs with xml:lang="en", but it still ignores the "british" dictonary. There seem to be some piece missing.Playoff

© 2022 - 2024 — McMap. All rights reserved.