Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'auto' language type which is available from LanguageTool API #51

Conversation

minoguep
Copy link

@minoguep minoguep commented Dec 19, 2021

I noticed when looking at the the LanguageTool API documentation that this library doesn't support using the auto language code in conjunction with preferredVariants (see here).

Two changes were required here to support this:

  1. Since the auto language code isn't returned by the GET /languages route the LanguageTag._normalize validation fails. To get around this I just add the 'auto' tag in the _get_languages function (and updated the test_langtool_languages test accordingly).
  2. If we are using auto we can supply preferredVariants (e.g. en-US or de-DE). I just went ahead and added this to the LanguageTool object which can be set if required like:
tool = LanguageTool('auto')
tool.preferred_variants = ['en-US', 'de-DE']

Happy to make any styling changes or add any tests if required.

Cheers!

@jxmorris12
Copy link
Owner

This is a great addition, thanks @minoguep!

@jxmorris12 jxmorris12 merged commit e8d7a1a into jxmorris12:master Dec 20, 2021
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.

None yet

3 participants