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

Exclude a word or part of a string from the translation #115

Open
Asmedian opened this issue May 27, 2023 · 4 comments
Open

Exclude a word or part of a string from the translation #115

Asmedian opened this issue May 27, 2023 · 4 comments

Comments

@Asmedian
Copy link

Is there a workaround to do this?
Something like a glossary in the Google documentation with a list of words to exclude from translation

@vitalets
Copy link
Owner

Could you show an example what you mean?

@Asmedian
Copy link
Author

Asmedian commented May 29, 2023

Add a list of what need to "prohibit for translation":
const notTranslatable = ['word', 'text', 'word !@#$%^&()', 'etc'];
Before sending a request for translation, we go through the texts, assign a serial number to each match and frame it, for example, in {"(...)"}
Google still translates such words, preserving the context, but we have the opportunity to reverse replacement.
In the received response, we go through the text for each element from notTranslatable and change it to the original by serial number.
But i'm not sure if this will work in all situations.
So far this is the only solution i have come up with.

@vitalets
Copy link
Owner

I don't know ready to use solutions but your approach look rational enough.
I suggest to keep it in userland, not in library but store as a recipe in readme.

Btw, what is the final task - why do you need to not-translate some words?

@Asmedian
Copy link
Author

It's just that some words from the desired text do not have a translation. They must remain in English.

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

No branches or pull requests

2 participants