Closed wangboweiqwe closed 3 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?
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
The current version adds a pronunciation feature.
I would like to implement it in the future.