translateer
Light-weight translator
Installation
Using npm or yarn
npm install translateer --save
yarn add translateer --save
How to use
const translator = ;
translate
translate
is a function with only one object argument which is specified below.
q
[optional] default is empty, the word/sentence you want to query.
from
[optional] default is auto, used to specify the language of q
.
to
[optional] default is en, used to specify the language for translation.
version
[optional] default is 1.0, used to specify the version of API.
Examples for API v1.0 (Default)
translator; // Hola Mundo
Examples for API v2.0
translator; /*{ "sentences": [ { "trans": "Hola Mundo", "orig": "hello world", "backend": 1 } ], "src": "en", "alternative_translations": [ { "src_phrase": "hello world", "alternative": [ { "word_postproc": "Hola Mundo", "score": 1000, "has_preceeding_space": true, "attach_to_next_token": false }, { "word_postproc": "Hola Mundo", "score": 1000, "has_preceeding_space": true, "attach_to_next_token": false } ], "srcunicodeoffsets": [ { "begin": 0, "end": 11 } ], "raw_src_segment": "hello world", "start_pos": 0, "end_pos": 0 } ], "confidence": 0.71052581, "ld_result": { "srclangs": [ "en" ], "srclangs_confidences": [ 0.71052581 ], "extended_srclangs": [ "en" ] }}*/
getAudio
getAudio
is a function returning the url of the audio file
q
[optional] default is empty, the word/sentence you want to query.
to
[optional] default is auto detected, used to specify the language for translation.
speed
[optional] default is 1, used to specify the audio speed.
Example
translator;// https://translate.google.com/translate_tts?ie=UTF-8&q=test&tl=en&total=1&idx=0&textlen=4&tk=290146.141044&client=t&prev=input&ttsspeed=1
Copyright
Copyright (C) 2017 Tony Ngan, released under the MIT License.