fix: send HTML tag handling to DeepL so notranslate works - #16
Merged
Merged
Conversation
The DeepL provider sent no `tag_handling` at all. Per DeepL's own
documentation, "Without `tag_handling`, tags are treated as regular
text" -- and `class="notranslate"`, which DeepL does honour, is honoured
only under HTML tag handling. The tokenizer hands a notranslate span to
the provider whole, tags included, precisely so the provider can leave
its contents alone. It could not.
Confirmed against the live API:
"<span class='notranslate'>Bold Mountain</span> is a good place."
no tag_handling -> "<span class='notranslate'>Болд-Маунтин</span> — отличное место."
tag_handling -> "<span class='notranslate'>Bold Mountain</span> — это хорошее место."
Note what the first line does: the span's tags survive untouched and only
the protected name is translated. Nothing about the output looks wrong,
which is why this went unnoticed -- `tag_handling` appears nowhere in this
repository's history, so notranslate has not worked for a single day since
the gem moved from Google to DeepL.
Both values are sent as defaults a caller can override, the way every
other provider option works. Under HTML tag handling DeepL defaults
`split_sentences` to `nonewlines`; this library sends one sentence per
value, so that changes nothing here.
Detection is left alone: it sends a 100-character sample that may end
mid-tag, and DeepL never strictly parses HTML anyway.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The DeepL provider sent no
tag_handling. Per DeepL's documentation, "Withouttag_handling, tags are treated as regular text" — andclass="notranslate", which DeepL does honour, is honoured only under HTML tag handling.The tokenizer hands a notranslate span to the provider whole, tags included, precisely so the provider can leave its contents alone. It could not.
Confirmed against the live API
Note what the first line does: the span's tags survive untouched and only the protected name is translated. Nothing about the output looks wrong — which is why this went unnoticed.
tag_handlingappears nowhere in this repository's history, so notranslate has not worked for a single day since the gem moved from Google to DeepL.The change
tag_handling: :htmlandtag_handling_version: "v2"(the algorithm DeepL's docs recommend) are sent as defaults a caller can override, the way every other provider option works.Under HTML tag handling DeepL defaults
split_sentencestononewlines; this library sends one sentence per value, so that changes nothing here.Detection is left alone: it sends a 100-character sample that may end mid-tag, and DeepL never strictly parses HTML anyway.
Verification