Utilizes translationbackends in trivial from→to texteditor
Project description
tk-translate is a PySimpleGUI variant of PageTranslate. It provides a terse GUI to get some text translated using one of the various services from PT or Deep-Translator. Albeit it has no config dialog, thus won't pacify API-key requirements. It's mostly just meant for testing.
Presents two input boxes, some buttons, for plain text translations. Usage:
- Insert text into left input
- Select backend
- Change target language
- Hit translate
Defaults must be edited in tk_translate/init.py conf={}. dingonyms output doesn't look as useful in a plain text field. Other CLI tools can be edited in the combobox however.
translationbackends usage
There's two options to instantiate the backends. The default
assign_service()
expects a dictionary of parameters, one
of which decides on the instance used:
import tk_translate.translationbackends as tb
service = tb.assign_service({
"backend": "DeepL Web",
"from": "auto",
"lang": "en",
"quick": 1,
})
engl = service.translate("¿Donde esta la pizza?")
While the individual classes also would allow keyword arguments:
service = tb.GoogleAjax(lang="en")
text = service.linebreakwise(text)
Using from= does require a syntax workaround however:
service = tb.PonsWeb(lang="en", **{"from": "it"})
Which works as well for all arguments. (Most being optional.)
MyMemory benefits from an email=
, while the commercial providers
want an api_key=
.
deep-translator
With two exceptions, deep-translator
is the better option. translationbackends
merely retains some
Python2 compatiblility (for good old OpenOffice). Instantiating it
from tb.DeepTranslator(backend="Yandex")
required a second name
lookup in TB.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for tk_translate-0.1.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e7a183ecde9950be8e841a2dfeb05a0cf188a84c3b1dd1d55d16230277e33fb |
|
MD5 | 12eb7ef7a96936b02b3d6d7c1efad5ae |
|
BLAKE2b-256 | b7574b14bbd796edfc139cc213c3fe662de83be86a853dfae2666e6167e2a760 |