ENCHANT(5)

๐Ÿ“ฆ
version 2.8.21 ยท 6 versions
, in arch rolling, debian trixie, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

๐Ÿ’– NAME ๐Ÿ’–

okay so bestie, this page is all about Enchant โ€” the language tags, the ordering files, and the personal word lists. That's the whole vibe. โœจ

Basically: enchant language tags, ordering files and personal word lists. Slay.


๐Ÿฆ‹ LANGUAGE TAGS ๐Ÿฆ‹

So Enchant figures out which dictionaries are which by their language tag. A language tag is typically an IETF BCP 47 language tag shaped like LANGUAGE_COUNTRY โ€” for example en_US or zh_SG. Iconic format, no notes.

And the way that you can stack multiple dictionaries together?? Literally just give a comma-separated list, like en_GB,fr_FR. Chef's kiss. This is super useful for checking multi-lingual text, or for using specialised word lists for a particular subject, project or document โ€” those might have names such as en-medical or en-my-novel. ๐ŸŽ€


๐ŸŒธ ORDERING FILE ๐ŸŒธ

Enchant uses global and per-user ordering files named enchant.ordering to decide which spelling provider to use for particular languages. Heads up: the per-user file takes precedence. ๐Ÿ‘‘

The ordering file takes the form language_tag:<comma-separated list of spelling providers>. Wanna see what dictionaries are available? Run enchant-lsmod-2. And '*' means "use this ordering for all languages, unless instructed otherwise." For example:

*:aspell,hunspell,nuspell
en:aspell,hunspell,nuspell
en_GB:hunspell,nuspell,aspell
fr:hunspell,nuspell,aspell

๐Ÿ“ PERSONAL WORD LISTS ๐Ÿ“

Personal word lists are simple plain text files with one word per line. The name of the file starts with the language tag and ends .dic. And every personal word list has a corresponding exclude file ending in .exc, which lists words that are found in the dictionary but that the user wants to be considered invalid. ๐Ÿ’…

These files are stored in an Enchant configuration directory โ€” peep FILES AND DIRECTORIES below for the deets. Oh, and lines starting with a hash sign '#' are ignored. ๐Ÿซถ

๐Ÿ’œ SHARING PERSONAL WORD LISTS BETWEEN SPELL-CHECKERS ๐Ÿ’œ

Okay so this is possible, and usually safe: you can share Enchant's personal word lists with other spelling checkers that use the same format. โš ๏ธ Note that other spell-checkers may not support comments! The spell-checkers known to be compatible are Hunspell, Nuspell and Ispell. (And yes โ€” although Enchant does not support Ispell as a provider, it's still fine to share word lists with it.) Other spell-checkers supported by Enchant are either incompatible, or have no personal word list mechanism. And honestly there may well be yet other spell-checkers, unknown to Enchant, that use the same format. The lore runs deep. ๐Ÿงš

Some applications use Hunspell or Nuspell, but store the personal word list under another name or in another location โ€” Firefox and Thunderbird do this. Firefox also seems to reorder its word list when updating it; again, this is OK, as the result is still in the same format. ๐Ÿ™ˆ

So to share word lists with Enchant: find the other spelling checker's word list file, e.g. ~/.hunspell_fr_FR or ~/.config/nuspell/fr_FR, and merge it with the corresponding Enchant file โ€” in this case ~/.config/enchant/fr_FR.dic. Use the following command, replacing ENCHANT-DICT and OTHER-DICT with the corresponding dictionary file names:

cat ENCHANT-DICT OTHER-DICT | sort -u > merged.txt

Take a look at merged.txt to check the merge has worked, then

mv merged.txt ENCHANT-DICT
rm OTHER-DICT
ln -s OTHER-DICT ENCHANT-DICT

to replace the other dictionary file with a link to the Enchant dictionary โ€” again, filling in the name of the dictionary files. Boom. Merged. โœจ๐Ÿ”ฅ


๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

The following variables affect the behavior of Enchant:

  • ENCHANT_CONFIG_DIR โ€” a directory in which Enchant should look for configuration files. See below. ๐Ÿ‘€
  • G_MESSAGES_DEBUG โ€” Enchant uses GLib's log functions, with the domain libenchant, to output messages useful for debugging. Setting G_MESSAGES_DEBUG to libenchant will cause Enchant to output debugging messages to standard error. See the GLib documentation for more details. ๐Ÿ›

๐Ÿ‘‘ FILES AND DIRECTORIES ๐Ÿ‘‘

Enchant looks in the following places for user files, in decreasing order of precedence:

  • ENCHANT_CONFIG_DIR โ€” (if the environment variable is set.)
  • XDG_CONFIG_HOME/enchant (non-Windows systems) โ€” default: ~/.config/enchant
  • CSIDL_LOCAL_APPDATA\enchant (Windows systems) โ€” default: C:\Documents and Settings\username\Local Settings\Application Data\enchant

Dictionaries for some providers are looked for in a subdirectory with the same name as the provider, for example ~/.config/enchant/hunspell. Currently this works for Hspell, Hunspell, Nuspell and Voikko. โญ

Providers also look in specific system directories, and in some cases and user directories, for their dictionaries; see the documentation for each provider. (Not me telling you to go read more docs, but likeโ€ฆ go read the docs. ๐Ÿ˜ญ)

In addition, Enchant looks in the following systems directories for ordering files:

  • /etc/enchant-2 โ€” (or the equivalent location relative to the enchant library for a relocatable build.)
  • /usr/share/enchant-2 โ€” (or the equivalent location relative to the enchant library for a relocatable build.)

๐ŸŽ€ SEE ALSO ๐ŸŽ€


๐Ÿ’… AUTHOR ๐Ÿ’…

Written by Dom Lachowicz and Reuben Thomas. Legends, honestly. ๐Ÿซถ


and that's the whole page, bestie โ€” ENCHANT(5), File Formats Manual, in all her glory. go forth and spell-check responsibly. ๐Ÿ’–โœจ