AlexanderWillner / deepl-alfred-workflow2

DeepL Alfred Workflow
228 stars 8 forks source link

Do not escape single quotes for the query #11

Closed jilulu closed 3 years ago

jilulu commented 4 years ago

Issue

Trying to translate any scentence that includes a single quote ' will cause DeepL to throw a Parse error.

Reproducing the issue

./deepl.sh -l JA "How's"

{"items": [{"uid": null,"arg": "Error: Parse error","valid": "yes","autocomplete": "autocomplete","title": "Error: Parse error"}]}

Possible cause of this issue

This line https://github.com/AlexanderWillner/deepl-alfred-workflow2/blob/master/deepl.sh#L62 escapses single quotes and replaces it with \'. That seems to be causing a confusion to DeepL.

After the fix

./deepl.sh -l JA "How's."
{
  "items": [
    {
      "uid": null,
      "arg": "どうですか?",
      "valid": "yes",
      "autocomplete": "autocomplete",
      "title": "どうですか?"
    },
    {
      "uid": null,
      "arg": "どうだ?",
      "valid": "yes",
      "autocomplete": "autocomplete",
      "title": "どうだ?"
    },
    {
      "uid": null,
      "arg": "どうなんですか?",
      "valid": "yes",
      "autocomplete": "autocomplete",
      "title": "どうなんですか?"
    },
    {
      "uid": null,
      "arg": "どうなの?",
      "valid": "yes",
      "autocomplete": "autocomplete",
      "title": "どうなの?"
    }
  ]
}
AlexanderWillner commented 3 years ago

Thanks! Adopted it in 5163aef