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

Coding minor update #16

Merged
merged 6 commits into from
Dec 25, 2022
Merged

Conversation

cyfung1031
Copy link
Contributor

some coding improvement is made without any affect to the function or features provided in this script.

@cyfung1031
Copy link
Contributor Author

cyfung1031 commented Dec 21, 2022

@CoinkWang

Remarks:
I am not sure the purpose for localLine += ' '; // add space to avoid words stick together
If you just want two words not sticking together and don't want a visible space, you can consider to use zero-width space.
零宽空格 - 维基百科,自由的百科全书

But this is up to your decision.

@CoinkWang
Copy link
Owner

LGTM

@CoinkWang CoinkWang merged commit 243703a into CoinkWang:master Dec 25, 2022
@cyfung1031
Copy link
Contributor Author

LGTM

@CoinkWang

I found that the subtitle translation is having some problems..

https://www.youtube.com/watch?v=M2cckDmNLMI

Choose Japanese subtitle and translate to English.

Screen Shot 2022-12-25 at 23 07 18

0:23 is still okay, although the end of the sentence should not end with "it's"

Screen Shot 2022-12-25 at 23 07 35

0:30 the translation get broken.

Screen Shot 2022-12-25 at 23 07 46

0:33 completely no translation...

@CoinkWang
Copy link
Owner

@cyfung1031 I found that the offical timed texts are broken, any good ideas? I'm afraid it's hard to fix by this proj.

@cyfung1031
Copy link
Contributor Author

cyfung1031 commented Dec 28, 2022

@CoinkWang

I found that in https://greasyfork.org/en/scripts/456108, it uses Google's translation api which is quite good.

https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=en&dj=1&dt=t&dt=rm&q=XXXXXXXXXXXXX

It can translate a very long text as well. In that Userscript, he translate the entire description content at once.

sl=auto means the original lang is detected by the api
tl=en is the target lang for translation.

I guess you can modify this script like this.

get the defaultJson first.
extract its texts in that json object. join by \n (be careful if the text lines already contain \n)

ask Google's translation api to help
get the json response and then line by line put back to defaultJson

@cyfung1031
Copy link
Contributor Author

cyfung1031 commented Dec 28, 2022

@CoinkWang

I found that in https://greasyfork.org/en/scripts/456108, it uses Google's translation api which is quite good.

https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=en&dj=1&dt=t&dt=rm&q=XXXXXXXXXXXXX

It can translate a very long text as well. In that Userscript, he translate the entire description content at once.

sl=auto means the original lang is detected by the api tl=en is the target lang for translation.

I guess you can modify this script like this.

get the defaultJson first. extract its texts in that json object. join by \n (be careful if the text lines already contain \n)

ask Google's translation api to help get the json response and then line by line put back to defaultJson

@CoinkWang see PR #18

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.

2 participants