Reputation: 53
I want to translate a website where 98% of the page is already in English but about 2% of the text on the page is in Chinese.
How do I only translate the Chinese language to english on page load?
What service should be used? Google Translate/Bing ? Or is there a third one which is even better ?
Best, salexes
Upvotes: 0
Views: 265
Reputation: 571
Language detection on a page that is mostly English will return English. You can find characters in a non-Latin script by looking at the Unicode range of the characters of the page, finding the sentence boundaries around the section containing those non-Latin characters, and then selectively translate that section. The Translate API can handle the language detection of this section. It is important that you segment the text at sentence boundaries, not below that. Won't work for Danish in English text, but will work for Chinese in English text.
Upvotes: 1