streetsidesoftware / vscode-spell-checker

A simple source code spell checker for code
https://streetsidesoftware.github.io/vscode-spell-checker/
Other
1.43k stars 127 forks source link

Check one language in keys, another in values for JSON/ YAML #173

Open cantiero opened 6 years ago

cantiero commented 6 years ago

Hi guys. First of all, your extension rocks!!! Thanks for the great work you have done.

I have yaml files with the following structure:

key_1_in_English: value in Portuguese
key_2_in_English: reference_to_key_in_English
key_3_in_English:
  - value in Portuguese
  - value in Portuguese
  - some text in Portuguese ${reference_to_key_in_English} some more text in Portuguese
key__3_in_English: some text in Portuguese ${reference_to_key_in_English} some more text in Portuguese

So, keys are always in English, values in might be:

Is it possible to configure cSpell to use the proper language in each case?

Jason3S commented 6 years ago

This would be challenging. The short answer at the moment is that it is not possible.

One option is to turn off English for these types of files and add a list of allowed keys.

I know this isn't ideal, but it might work in your case.

cantiero commented 6 years ago

Actually, the English check is the most important. As wrong key names generate hard to track bugs at the frontend level. What I have done was enable English with yaml/ json and add this config to disable it where might be Portuguese or mixed language:

    "languageSettings": [
        {
            "languageId": "json,yaml",
            "ignoreRegExpList": [
                "/[^:-]*'.*/",
                "^[^:'-]+$"
            ]
        }
    ]

Is there a way to enable Portuguese in some parts of the same files, based on regex inclusions/ exclusions? If so, I could give it a try.

Thanks!

Jason3S commented 6 years ago

I am guessing you are using yaml files for UI translation. I am also assuming the keys are the English phrase to be translated with possible placeholders in the Portuguese text.

If that is the case, then I suggest using a plug in like Yaml Support for VS Code and use a JSON-Schema file to ensure the keys are correct. The JSON-Schema file can be used for both .JSON and .YAML.

I can see how being able to have different filters per spoken language would be very useful. At the moment, the spell checker does not support that.

cantiero commented 6 years ago

Thanks, Jason!

Jason3S commented 6 years ago

I think I might have a way to do this. Working on it. But it may be a few weeks (I am busy with other stuff).