-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
Update index.js to allow for multiple URL support #7
Conversation
WIP update to index.js to allow for multiple URL support in the API by adding a new argument field (ties into PR vitalets/google-translate-token#2).
Could you add a unit test to ensure that it works: test('translate via custom tld', async t => {
try {
const res = await translate('vertaler', {tld: 'cn'});
t.is(res.text, 'translator');
t.false(res.from.language.didYouMean);
t.is(res.from.language.iso, 'nl');
t.false(res.from.text.autoCorrected);
t.is(res.from.text.value, '');
t.false(res.from.text.didYouMean);
} catch (err) {
t.fail(err.code);
}
}); |
@vitalets I'll add that in, just I need some pointing in the right direction on what exactly should be done to finish the implementation of this extra field. |
Updates test.js to add support for testing the WIP custom field
Done. Added the test in, just now I need to figure out how I'm gonna actually implement that extra field. (It's just using |
I think you should add default opts.tld = opts.tls || 'com'; and use it when building url: var url = 'https://translate.google.' + opts.tld + '/translate_a/single'; |
Revise the index.js URL code to help with the development of the custom URL argument
Codecov Report
@@ Coverage Diff @@
## master #7 +/- ##
==========================================
+ Coverage 92.3% 92.42% +0.11%
==========================================
Files 2 2
Lines 65 66 +1
==========================================
+ Hits 60 61 +1
Misses 5 5
Continue to review full report at Codecov.
|
That's done. Will this allow for the extra URL argument to be passed in and be used in translation (it'll still need work on the token side of things to get the token from the URL passed here)? |
Updates index.js again to actually make the field usable (I think)
Reverts previous commit as I'm unsure how this is supposed to work
Updates index.js to add in vitalets' suggestion (allows for the tld variable to be passed to the token side of things)
@vitalets Does this look any better codewise? I've done what you needed me to do here. |
I'v cloned your branch made some fix and merged. Thank you! 👍 |
WIP update to index.js to allow for multiple URL support in the API by adding a new argument field (ties into PR vitalets/google-translate-token#2). This fixes matheuss#60, matheuss/google-translate-token#10 and part of issue #4.