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

⌈⌋ ⎇ branch:  PageTranslate


addlang.py

File off/addlang.py from the latest check-in


#!/usr/bin/env python3


import sys

(bin, ln, title) = sys.argv

symbol = u"".join(([chr(ord("🇦")+ord(c)-ord("a")) for c in ln]))


xml = f"""
                    <node oor:name="M2{ln.upper()}" oor:op="replace">
                      <prop oor:name="Context" oor:type="xs:string"><value/></prop>
                      <prop oor:name="URL" oor:type="xs:string"><value>service:org.openoffice.comp.pyuno.pagetranslate?trigger&amp;lang={ln}</value></prop>
                      <prop oor:name="Title" oor:type="xs:string"><value/><value xml:lang="en-US">→{title} {symbol}</value></prop>
                      <prop oor:name="Target" oor:type="xs:string"><value>_self</value></prop>
                    </node>
"""
print(xml)