-
Notifications
You must be signed in to change notification settings - Fork 47
Add Yandex Translate API support #127
Conversation
- https://tech.yandex.com/translate/
- https://tech.yandex.com/dictionary/
Yandex Dictionary API should fit better to our need, but I can't get the API key, it didn't send the SMS verification code to my phone :P |
linter failure on travis |
zdict/dictionaries/yandex.py
Outdated
|
||
|
||
# The daily request limit is 1,000,000 characters. The monthly limit is 10,000,000 characters. | ||
API_KEY = 'trnsl.1.1.20170826T075621Z.6dfcaff242c6caa8.e2b9cf136d451d9d6eb69516ec97b827e8c8229b' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API_KEY = (
'trnsl.1.1.20170826T075621Z.'
'6dfcaff242c6caa8.e2b9cf136d451d9d6eb69516ec97b827e8c8229b')
zdict/dictionaries/yandex.py
Outdated
# Need to keep the `{word}` for `_get_url()` usage. | ||
# TODO: support different translate direction | ||
# TODO: use Dictionary API | ||
API = 'https://translate.yandex.net/api/v1.5/tr.json/translate?key={api_key}&text={word}&lang=ru-en' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as previous remark
yep modifing code, just open the WIP PR, and I will add a test case later. |
there are lots of TODO tags in the code. |
and I think we should update some dependencies :P |
maybe in separated PR, for traceable commit history |
|
||
# The daily request limit is 1,000,000 characters | ||
# The monthly limit is 10,000,000 characters | ||
API_KEY = 'trnsl.1.1.20170826T075621Z.' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:/ I'm not a fan of escaping newline.
But I'm ok, if you do not like string concatenation within ()
.
yes, I expect it in another PR |
zdict/dictionaries/yandex.py
Outdated
'6dfcaff242c6caa8.e2b9cf136d451d9d6eb69516ec97b827e8c8229b' | ||
|
||
|
||
# Change `Template` to the name of new dictionary. like xxxDict. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useless comment?
zdict/dictionaries/yandex.py
Outdated
content = self._get_raw(word) | ||
content_json = json.loads(content) | ||
|
||
if not content_json['code'] != '200': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it's combining not
and !=
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it's a copy paste mistake 🍸
what's wrong with Travis on python 3.6? :/ |
|
Python 3.6 on Travis CI is a shit !? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's keep this PR open a few days for reviewing
I wonder why I can not get the verification code for the signup of Yandex Dictionary API 😢 |
dude, why Travis CI is angry with Python 3.6 !? |
Travis refused to update |
status, | ||
'Some bad thing happened with Yandex' | ||
) | ||
print('Yandex: ' + message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print('Yandex:', message)
?
print will append a space for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the concat by +
, but if you like that one I can change it.
TODO:
these two things won't be done very quick, I'm going to leave it in the future 😝 |
nice screenshot. add it to README? |
supported languages in Yandex Translate API:
Currently, I only implement the |
I'll rebase the PR after this one #128, the testing will be good after that |
Rebased, let's see the new test result 😝 |
Test passed, but I will leave it here for a few days to let everyone aware this. |
oh, you need to update the usage section of README as well. |
thanks for remind |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we need a coding style guide. lol
I think we should bump to |
I'm fine with that |