Metadata-Version: 2.1
Name: tk_translate
Version: 0.5
Summary: Utilizes translationbackends in trivial from→to texteditor
Home-page: https://fossil.include-once.org/pagetranslate/
License: MITL
Keywords: translation
Requires-Python: >= 3.8
Description-Content-Type: text/markdown
Classifier: License :: OSI Approved :: MIT License
Classifier: Development Status :: 4 - Beta
Requires-Dist: PySimpleGUI (>=4.37)
Requires-Dist: requests

**tk-translate** is a PySimpleGUI variant of
[PageTranslate](https://fossil.include-once.org/pagetranslate/).
It provides a terse GUI to get some text translated using one of the various
services from PT or Deep-Translator. It's mostly just meant for testing.

![🗔](https://fossil.include-once.org/pagetranslate/raw/24ddd787008?m=image/png)

Presents two input boxes, some buttons, for plain text translations.
Usage:

* Insert text into left input
* Select backend
* Change target language
* Hit translate

There's also a **[File] mode** which allows Office document / `content.xml`
(best with DeepL) or text file translations. The output target is implied
to be `filename.LANG.ext`.
Other CLI translation tools can be edited into the combobox here. (The
dingonyms output doesn't look quite as useful in a plain text field).
Defaults can now be set in the **[⛭] settings dialog**.

## 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](https://pypi.org/project/deep-translator/)
is the better option. `translationbackends` merely retains some
Python2 compatibility (for good old OpenOffice). Instantiating it
from `tb.DeepTranslator(backend="Yandex")` requires a second name
lookup in TB (`backend=` best prefixed with `'DT: LibreTranslate'`).
