Skip to content

fix(server): permit to register new spellings for other languages than en#156

Merged
mdevolde merged 1 commit intojxmorris12:masterfrom
mdevolde:fix/new_spelling
Mar 7, 2026
Merged

fix(server): permit to register new spellings for other languages than en#156
mdevolde merged 1 commit intojxmorris12:masterfrom
mdevolde:fix/new_spelling

Conversation

@mdevolde
Copy link
Collaborator

@mdevolde mdevolde commented Mar 7, 2026

fix(server): permit to register new spellings for other languages than en

Why the pull request was made

To fix a bug that restrict the addition of words to english.
If you give new_spellings to LanguageTool with, for exemple, es as language, the new_spellings will be added in the english dict, and so, the custom words will not be taken into acount.

Summary of changes

  • In language_tool_python.server.LanguageTool._get_valid_spelling_file_path, find the spelling file depending on the language of the current server.

Screenshots (if appropriate):

Not applicable.

How has this been tested?

By applying local tests, and by testing to add accepted words in some languages.

Resources

This commit on the fork of @vfigueroa-nur allowed me to detect this bug.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (changes to documentation only)
  • Refactor / code style update (non-breaking change that improves code structure or readability)
  • Tests / CI improvement (adding or updating tests or CI configuration only)
  • Other (please describe):

Checklist

  • Followed the project's contributing guidelines.
  • Updated any relevant tests.
  • Updated any relevant documentation.
  • Added comments to your code where necessary.
  • Formatted your code, run the linters, checked types and tests.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes LanguageTool(new_spellings=...) so custom spellings are registered in the LanguageTool resource directory matching the tool’s configured language (instead of being hard-coded to English), enabling non-English custom dictionaries.

Changes:

  • Initialize self._language before registering new_spellings.
  • Compute spelling.txt path using the instance language’s resource directory rather than /en/.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mdevolde mdevolde merged commit 2211972 into jxmorris12:master Mar 7, 2026
8 checks passed
@mdevolde mdevolde deleted the fix/new_spelling branch March 7, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants