antonWetzel / typst-languagetool

LanguageTool Integration for Typst for spell and grammer check
MIT License
36 stars 9 forks source link

checking text for en-GB instead of de-DE #33

Open feuermandel opened 1 week ago

feuermandel commented 1 week ago

Hey Anton,

I did just compile the latest version on typstlanguagetool with the remote-server feature.

Settings in settions.json (VSCodium) are:

` "generic-lsp.configuration": [

    {
      "lsp": "C:\\binaries\\typst-languagetool-lsp.exe",
      "language": "typst", 
      "options": {
        "on_change": "5000ms",
        "dictionary": {
          "de-DE": [
            "OWASP"
          ],
        },
        "disabled_checks": {},       
        "languages": [
          "de-DE",
          ], // code for document language
        "host": "http://internal.server.de",
        "port": "8010",
        "root": ".",
        "main": "main.typ",
      },
    }
  ],

`

Serverlogs on local languagetool-server are:

languagetool    | 2024-10-23 10:22:37.172 GMT INFO  org.languagetool.server.LanguageToolHttpHandler Handled request in 1350ms; sending code 200
languagetool    | 2024-10-23 10:22:37.265 GMT INFO  org.languagetool.server.LanguageToolHttpHandler Handling POST /v2/check
languagetool    | 2024-10-23 10:22:39.418 GMT INFO  org.languagetool.server.TextChecker Check done: 412 chars, en-GB, requestId: null, #15, null, 0/2 matches, 2150ms, agent:-, sent, q:0, h:1, dH:1, r:15, m:all, premium: false

Diagnostics are "Possioble spelling mistake found. )MORFOLOGIK_RULE_EN_GB)"

What do I do wrong to let typstlangaugetool check my test in en_GB instead of german?

antonWetzel commented 1 week ago

Did you change the language in the typst document?

#set text(lang: "de", region: "DE")

The languages parameter is just to map the lang: "de" to de-DE, because the region is not saved by typst.

feuermandel commented 6 days ago

Well, yes I did.

But not via #set text(lang: "de") but with a TOML file:


mysettings.toml: [Generic] Sprache = "de"

Within the template, I use:

#let Variablen = toml("/Variablen.toml")
#set text(lang: str(Variablen.Generic.Sprache))

This seems to work with typst.

But I do not include the template file in each included document. And I do not do a explicit

#let Variablen = toml("/Variablen.toml")
#set text(lang: str(Variablen.Generic.Sprache))

Do I have to specify the lang-Parameter in each file?

To make it even worse: Sometimes (right now) the language "de-DE" is checked (not "en-GB"), but a few hours ago, the same document gets corrected with "en-GB"

antonWetzel commented 6 days ago

If you specify a main file, only this file with dependencies is compiled and the language should work for included files.

I fixed a bug with the diagnostic cache for same text with different languages, but I don't think this is the problem.