LibreOffice plugin to pipe whole Writer documents through Google Translate, that ought to keep most of the page formatting.

⌈⌋ ⎇ branch:  PageTranslate


Artifact [ab56d8cf2d]

Artifact ab56d8cf2d9897505017d166692d67789dab96c5:

  • File test/assign.py — part of check-in [314a6459fe] at 2022-10-24 20:39:48 on branch trunk — move linebreak/quick into options, condense pluginconf.gui.window() invocation (user: mario size: 1049)

# encoding: utf-8
import translationbackends as tb

# less static
kw = {
    "lang": "en",
    "from": "auto",
    "quick": 0,
    "quick": 0,
    "debug": 1,
    "mode": "page",
    "api_key": "",
    "email": "",
    "cmd": "",
}

def _ab(backend):
    kw["backend"] = backend
    return tb.assign_service(kw)
    

def google():
    assert isinstance(_ab("google translate"), tb.GoogleWeb)
    assert isinstance(_ab("google ajax"), tb.GoogleAjax)

def other():
    assert isinstance(_ab("Argos"), tb.ArgosNmt)
    assert isinstance(_ab("Duck"), tb.DuckDuckGo)

def deep():
    for name in "DT: Google", "Pons Dict", "DT: Libre":
        assert isinstance(_ab(name), tb.DeepTranslator)
    assert isinstance(_ab("DTA: Any"), tb.DeepTransApi)

def classes():
    assert len(tb.BackendUtils.subclasses()) >= 10

def dec_silence():
    func = tb.BackendUtils.silence(lambda x: undef)
    func(2)

def dec_from_words():
    ls = []
    func = tb.BackendUtils.from_words(lambda text: ls.append(text))
    func("one two three")
    assert len(ls) == 3