sienori / simple-translate

WebExtensions for translating text on web pages
http://simple-translate.sienori.com/
Mozilla Public License 2.0
1.15k stars 131 forks source link

Can you please add function of pronounce? #118

Closed wangboweiqwe closed 3 years ago

sienori commented 6 years ago

I would like to implement it in the future.

autonome commented 5 years ago

I would like to see the transliteration (eg Pinyin) also. Is that included in this feature request, or different?

Is it possible from the Google API you are using?

tombh commented 4 years ago

Just making some notes. I may look into PR'ing this myself.

The Google Translate API doesn't seem to return any pinyin:

$ curl 'https://translate.googleapis.com/translate_a/single?client=gtx&sl=zh&tl=en&dt=t&dt=bd&dj=1&q=%E4%BD%A0%E5%A5%BD%21%0A'
{"sentences":[{"trans":"Hello there!","orig":"你好!","backend":1}],"dict":[{"pos":"interjection","terms":["Hello!","Hi!","Hallo!"],"entry":[{"word":"Hello!","reverse_translation":["你好!","喂!"],"score":0.39160562},{"word":"Hi!","reverse_translation":["嗨!","你好!"],"score":0.054680396},{"word":"Hallo!","reverse_translation":["你好!"]}],"base_form":"你好!","pos_enum":9}],"src":"zh-CN","spell":{}}

However, there are transliteration APIs like:

$ curl 'https://glosbe.com/transliteration/api?from=Han&dest=Latin&text=%E4%BD%A0%E5%A5%BD&format=json'
{"result":"ok","text":"nǐ hǎo"}

The starting place to look into adding this to the code is: https://github.com/sienori/simple-translate/blob/1700ebb114dc065d938cbeb3a65e7fea08dd3595/src/common/translate.js

sienori commented 3 years ago

The current version adds a pronunciation feature.