mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Replaced translation services. Fixes #355
This commit is contained in:
parent
304d91e8b7
commit
351f700927
@ -12,6 +12,7 @@
|
|||||||
* TWBlue can upload images in Tweets and replies again. ([#240,](https://github.com/manuelcortez/TWBlue/issues/240))
|
* TWBlue can upload images in Tweets and replies again. ([#240,](https://github.com/manuelcortez/TWBlue/issues/240))
|
||||||
* Fixed the way we use to count characters in Twitter. The new methods in TWBlue take into account special characters and URLS as documented in Twitter. ([#199,](https://github.com/manuelcortez/TWBlue/issues/199) [#315](https://github.com/manuelcortez/TWBlue/issues/315))
|
* Fixed the way we use to count characters in Twitter. The new methods in TWBlue take into account special characters and URLS as documented in Twitter. ([#199,](https://github.com/manuelcortez/TWBlue/issues/199) [#315](https://github.com/manuelcortez/TWBlue/issues/315))
|
||||||
* Proxy support now works as expected.
|
* Proxy support now works as expected.
|
||||||
|
* Changed translation service from yandex.translate to Google Translator. ([#355,](https://github.com/manuelcortez/TWBlue/issues/355))
|
||||||
* And more. ([#352,](https://github.com/manuelcortez/TWBlue/issues/352))
|
* And more. ([#352,](https://github.com/manuelcortez/TWBlue/issues/352))
|
||||||
|
|
||||||
## Changes in version 0.95
|
## Changes in version 0.95
|
||||||
|
@ -16,7 +16,9 @@ futures
|
|||||||
winpaths
|
winpaths
|
||||||
PySocks
|
PySocks
|
||||||
win_inet_pton
|
win_inet_pton
|
||||||
yandex.translate
|
# Install the latest RC of this lib
|
||||||
|
# see https://github.com/ssut/py-googletrans/issues/234
|
||||||
|
googletrans==4.0.0-rc1
|
||||||
idna<3,>=2.5
|
idna<3,>=2.5
|
||||||
chardet
|
chardet
|
||||||
urllib3
|
urllib3
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import logging
|
||||||
from googletrans import Translator, LANGUAGES
|
from googletrans import Translator, LANGUAGES
|
||||||
|
|
||||||
|
log = logging.getLogger("extras.translator")
|
||||||
|
|
||||||
|
# create a single translator instance
|
||||||
|
# see https://github.com/ssut/py-googletrans/issues/234
|
||||||
|
t = None
|
||||||
|
|
||||||
def translate(text="", target="en"):
|
def translate(text="", target="en"):
|
||||||
|
global t
|
||||||
|
log.debug("Received translation request for language %s, text=%s" % (target, text))
|
||||||
|
if t == None:
|
||||||
t = Translator()
|
t = Translator()
|
||||||
vars = dict(text=text, dst=target)
|
vars = dict(text=text, dest=target)
|
||||||
return t.translate(**vars).text
|
return t.translate(**vars).text
|
||||||
|
|
||||||
supported_langs = None
|
supported_langs = None
|
||||||
@ -103,4 +113,4 @@ languages = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def available_languages():
|
def available_languages():
|
||||||
return languages
|
return dict(sorted(languages.items(), key=lambda x: x[1]))
|
||||||
|
Loading…
Reference in New Issue
Block a user