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

fix: do not sort the google translate results #167

Merged
merged 1 commit into from Jun 21, 2021

Conversation

azu
Copy link
Contributor

@azu azu commented May 22, 2021

Fix unnatural translation order when the text is wrapped tag like <b> or <a>

Pros

  • Fix unnatural order in some language

Cons

  • This PR insert may translated text to a different node from the original node
    • Google Translate copy the style from the original node
    • This PR append rest results to the last node
Request:
<a i=0>TranslateWebPages is created by </a><a i=1><b>FilipePS</b></a>
Response:
<a i=1>TranslateWebPagesはFilipePS</a><a i=0>によって作成され</a><a i=1>ます</a>

Google translation result:

<a i=1> will be <b> because original node style is <b>

<b>TranslateWebPagesはFilipePS</b>によって作成され<b>ます</b>

This PR result:

The original text has 2 <a i=x>, but the translated result has 3 <a i=x>.

TranslateWebPagesはFilipePS<b>によって作成されます</b>

TranslateWebPagesはFilipePS | <b>[によって作成され, ます].join(" ")</b>

I felt that both are unnatural, I have no opinion.

fix #163

@FilipePS
Copy link
Owner

I see 2 problems with this approach:

  1. The links are with text that does not belong to you, as well as bold text, etc. ... Translate this.
  2. Adding the rest of the text to the last node makes it have a lot more text than it should. I can easily imagine a layout break on some sites, maybe even make the node disappear.

I consider adding this, but it would be something optional, which would be activated in the settings.

I already tried to implement an algorithm similar to the one used in chrome (which inverts the position of nodes, and even creates new ones). However, no implementation was successful.

@azu
Copy link
Contributor Author

azu commented May 27, 2021

Yes, The design(style) will be broken on some websites.
This approach will be a good result on text content websites like a news site or blog.
I prefer that correct translation to the correct website's design.

I consider adding this, but it would be something optional, which would be activated in the settings.

I agree. It may be option.

@FilipePS FilipePS merged commit 747682b into FilipePS:master Jun 21, 2021
@azu azu deleted the feature/163 branch June 21, 2021 13:58
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.

text wrapped by a tag like <b> make unnatural tranlation
2 participants