[GH-ISSUE #143] Aspell En dictionary #116

Closed
opened 2026-03-03 01:19:56 +03:00 by kerem · 6 comments
Owner

Originally created by @Vainyards on GitHub (Sep 22, 2023).
Original GitHub issue: https://github.com/d99kris/nmail/issues/143

Originally assigned to: @d99kris on GitHub.

Description:
How do I tell aspell to include EN dictionary?

  • OS / distro: Macos, kitty term with tmux
Originally created by @Vainyards on GitHub (Sep 22, 2023). Original GitHub issue: https://github.com/d99kris/nmail/issues/143 Originally assigned to: @d99kris on GitHub. **Description**: How do I tell aspell to include EN dictionary? - OS / distro: Macos, kitty term with tmux
kerem 2026-03-03 01:19:56 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@d99kris commented on GitHub (Sep 22, 2023):

I believe you can use the --lang argument to specify which language you'd like to use. The following config parameter in ~/.nmail/main.conf works for me:

spell_cmd=aspell --lang=en -c
<!-- gh-comment-id:1731408922 --> @d99kris commented on GitHub (Sep 22, 2023): I believe you can use the `--lang` argument to specify which language you'd like to use. The following config parameter in `~/.nmail/main.conf` works for me: ``` spell_cmd=aspell --lang=en -c ```
Author
Owner

@Vainyards commented on GitHub (Sep 26, 2023):

Great I will test, and see.

Since im writing both in Swedish and English.

Used nmail for a year but totally missed this function! XD

<!-- gh-comment-id:1735046911 --> @Vainyards commented on GitHub (Sep 26, 2023): Great I will test, and see. Since im writing both in Swedish and English. Used nmail for a year but totally missed this function! XD
Author
Owner

@d99kris commented on GitHub (Oct 1, 2023):

Hi @Vainyards - I see, well I think with aspell --lang=en -c then aspell will only use English dictionary. So if you want it to sometimes check Swedish and sometime English you could perhaps create a simple wrapper script that first detects language of the text, and then calls aspell. Something like this:

#!/usr/bin/env bash

# pre-req: needs packages aspell and translate-shell

SAMPLE=$(cat ${1} | cut -d' ' -f1-20) # use first 20 words as a sample to determine language
LANG=$(trans -id "${SAMPLE}" -no-auto -no-ansi | grep "Code" | awk '{print $2}')
LC_ALL="en_US.UTF-8" aspell --lang="${LANG}" -c ${1}

Then save this as a text, e.g. anyspell.sh, chmod it:
chmod +x anyspell.sh
And finally point nmail to use it in ~/.nmail/main.conf:

spell_cmd=~/scripts/anyspell.sh

I'll proceed to close this issue, but feel free to re-open it if you have any follow-up questions or related issues.

<!-- gh-comment-id:1741975799 --> @d99kris commented on GitHub (Oct 1, 2023): Hi @Vainyards - I see, well I think with `aspell --lang=en -c` then aspell will only use English dictionary. So if you want it to sometimes check Swedish and sometime English you could perhaps create a simple wrapper script that first detects language of the text, and then calls aspell. Something like this: ```bash #!/usr/bin/env bash # pre-req: needs packages aspell and translate-shell SAMPLE=$(cat ${1} | cut -d' ' -f1-20) # use first 20 words as a sample to determine language LANG=$(trans -id "${SAMPLE}" -no-auto -no-ansi | grep "Code" | awk '{print $2}') LC_ALL="en_US.UTF-8" aspell --lang="${LANG}" -c ${1} ``` Then save this as a text, e.g. `anyspell.sh`, chmod it: ```chmod +x anyspell.sh``` And finally point nmail to use it in `~/.nmail/main.conf`: ``` spell_cmd=~/scripts/anyspell.sh ``` I'll proceed to close this issue, but feel free to re-open it if you have any follow-up questions or related issues.
Author
Owner

@Vainyards commented on GitHub (Oct 4, 2023):

yes, it works, but I think I have some miss configuration on my mac.

It only looks for Swedish no matter what I type. Any suggestions on how to configure EN?

<!-- gh-comment-id:1746176179 --> @Vainyards commented on GitHub (Oct 4, 2023): yes, it works, but I think I have some miss configuration on my mac. It only looks for Swedish no matter what I type. Any suggestions on how to configure EN?
Author
Owner

@d99kris commented on GitHub (Oct 7, 2023):

Does aspell work standalone if you specify English, i.e. like this (assuming you have a text file named README.md):

aspell --lang=en -c README.md

If yes, maybe there's something wrong in the script I shared - it was just a quick hack. I did some more testing now and have made some updates to the script to make it a little more robust:

#!/usr/bin/env bash

# pre-req:
# sudo apt install aspell aspell-en aspell-sv translate-shell

if [[ ! -f "${1}" ]]; then
  echo "usage: anyspell.sh <txtfile>"
  exit 1
fi

LANG=$(cat "${1}" | awk 'NR<=20{print;next}{exit}' RS='[[:blank:]]+|\n' | tr '\n' ' ' | trans -id -no-auto -no-ansi | grep "Code" | awk '{print $2}')
LC_ALL="en_US.UTF-8" aspell --lang="${LANG}" -c ${1}

I tested it on a text file containing the following Swedish text:

Han kom som ett yrväder en aprilafton och hade ett höganäskrus i en svångrem om halsen.

As well as on a text file containing the following English text:

It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife.

Language is detected correctly for both, and aspell can spell check them.

<!-- gh-comment-id:1751666680 --> @d99kris commented on GitHub (Oct 7, 2023): Does `aspell` work standalone if you specify English, i.e. like this (assuming you have a text file named README.md): ``` aspell --lang=en -c README.md ``` If yes, maybe there's something wrong in the script I shared - it was just a quick hack. I did some more testing now and have made some updates to the script to make it a little more robust: ```bash #!/usr/bin/env bash # pre-req: # sudo apt install aspell aspell-en aspell-sv translate-shell if [[ ! -f "${1}" ]]; then echo "usage: anyspell.sh <txtfile>" exit 1 fi LANG=$(cat "${1}" | awk 'NR<=20{print;next}{exit}' RS='[[:blank:]]+|\n' | tr '\n' ' ' | trans -id -no-auto -no-ansi | grep "Code" | awk '{print $2}') LC_ALL="en_US.UTF-8" aspell --lang="${LANG}" -c ${1} ``` I tested it on a text file containing the following Swedish text: ``` Han kom som ett yrväder en aprilafton och hade ett höganäskrus i en svångrem om halsen. ``` As well as on a text file containing the following English text: ``` It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife. ``` Language is detected correctly for both, and aspell can spell check them.
Author
Owner

@Vainyards commented on GitHub (Oct 17, 2023):

Does aspell work standalone if you specify English, i.e. like this (assuming you have a text file named README.md):

aspell --lang=en -c README.md

If yes, maybe there's something wrong in the script I shared - it was just a quick hack. I did some more testing now and have made some updates to the script to make it a little more robust:

#!/usr/bin/env bash

# pre-req:
# sudo apt install aspell aspell-en aspell-sv translate-shell

if [[ ! -f "${1}" ]]; then
  echo "usage: anyspell.sh <txtfile>"
  exit 1
fi

LANG=$(cat "${1}" | awk 'NR<=20{print;next}{exit}' RS='[[:blank:]]+|\n' | tr '\n' ' ' | trans -id -no-auto -no-ansi | grep "Code" | awk '{print $2}')
LC_ALL="en_US.UTF-8" aspell --lang="${LANG}" -c ${1}

I tested it on a text file containing the following Swedish text:

Han kom som ett yrväder en aprilafton och hade ett höganäskrus i en svångrem om halsen.

As well as on a text file containing the following English text:

It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife.

Language is detected correctly for both, and aspell can spell check them.

Thanks, that probably solved something BUT I noticed aswell that I probably used too few characters for the script to work properly, now it recognize language! So it probably defaulted to SE when under 20 and did not recognize EN.

<!-- gh-comment-id:1766315512 --> @Vainyards commented on GitHub (Oct 17, 2023): > Does `aspell` work standalone if you specify English, i.e. like this (assuming you have a text file named README.md): > > ``` > aspell --lang=en -c README.md > ``` > > If yes, maybe there's something wrong in the script I shared - it was just a quick hack. I did some more testing now and have made some updates to the script to make it a little more robust: > > ```shell > #!/usr/bin/env bash > > # pre-req: > # sudo apt install aspell aspell-en aspell-sv translate-shell > > if [[ ! -f "${1}" ]]; then > echo "usage: anyspell.sh <txtfile>" > exit 1 > fi > > LANG=$(cat "${1}" | awk 'NR<=20{print;next}{exit}' RS='[[:blank:]]+|\n' | tr '\n' ' ' | trans -id -no-auto -no-ansi | grep "Code" | awk '{print $2}') > LC_ALL="en_US.UTF-8" aspell --lang="${LANG}" -c ${1} > ``` > > I tested it on a text file containing the following Swedish text: > > ``` > Han kom som ett yrväder en aprilafton och hade ett höganäskrus i en svångrem om halsen. > ``` > > As well as on a text file containing the following English text: > > ``` > It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife. > ``` > > Language is detected correctly for both, and aspell can spell check them. Thanks, that probably solved something BUT I noticed aswell that I probably used too few characters for the script to work properly, now it recognize language! So it probably defaulted to SE when under 20 and did not recognize EN.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nmail#116
No description provided.