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

βŒˆβŒ‹ βŽ‡ branch:  PageTranslate

sample keyboard bindings (disabled in manifest.xml however)
mario authored 698 days ago last checkin a0244ed81
πŸ“‚ META-INF sample keyboard bindings (disabled in manifest.xml however)β€Ήβ€Ί 698 days ago
πŸ“‚ dingonyms Add `selectonly` mode as per user request.β€Ήβ€Ί 1096 days ago
πŸ“‚ help Add errors, update help treeβ€Ήβ€Ί 1421 days ago
πŸ“‚ icons resized, lighter blue tonesβ€Ήβ€Ί 1696 days ago
πŸ“‚ off Add more languages ('le continental submenus)β€Ήβ€Ί 1425 days ago
πŸ“‚ pkg-desc move license text to pkg-desc/β€Ήβ€Ί 1682 days ago
πŸ“‚ pythonpath freeze requestsβ€Ήβ€Ί 800 days ago
πŸ“‚ test basic system testsβ€Ήβ€Ί 801 days ago
πŸ“‚ tk_translate release as 2.1β€Ήβ€Ί 791 days ago
πŸ“„ Accelerators.xcu sample keyboard bindings (disabled in manifest.xml however)β€Ήβ€Ί 698 days ago
πŸ“„ Addons.xcu Added pt-BR (Brazilian-Portuguese) menu entryβ€Ήβ€Ί 1096 days ago
πŸ“„ Makefile release as 2.1β€Ήβ€Ί 791 days ago
πŸ“„ NEWS release as 2.1β€Ήβ€Ί 791 days ago
πŸ“„ OptionsDialog.xcu AOO compat. OptionsDialog XCU requires leaf name to equal handler ID.β€Ήβ€Ί 1675 days ago
πŸ“„ OptionsDialog.xdl test and fix systran and deepl, jettison deepl pro/api split (now decβ€Ήβ€Ί 801 days ago
πŸ“„ OptionsSchema.xcs add annotate optionβ€Ήβ€Ί 809 days ago
πŸ“„ description.xml release as 2.1β€Ήβ€Ί 791 days ago
πŸ“„ doc.py rough privacy judgementβ€Ήβ€Ί 799 days ago
πŸ“„ pagetranslate.py prepare for language list updates (seems shorter than default list hoβ€Ήβ€Ί 775 days ago
πŸ“„ pytest.ini basic system testsβ€Ήβ€Ί 801 days ago
πŸ“„ setup.py add little standalone toolβ€Ήβ€Ί 806 days ago

PageTranslate

OpenOffice/LibreOffice extension that translates whole documents, whilst retaining some formatting.

  • Iterates over paragraphs / text segments / and tables (only linebreaks kept)
  • Utilizes Google translate (or DeepL, Microsoft Translate, MyMemory, PONS, or Yandex/Qcri/Linguee).
  • And is therefore rather slow.
    (Writer freezes during process for long documents!)
  • Still allows for text-selection mode translation (from original extension).

Install

Download the package file, and import it in LibreOffice via Tools β†’ Extension Manager β†’ Add.

Location Features Link
Source
repository
Newest package, Linux-only, no bundled python dependencies pagetranslate.oxt
LibreOffice Extensions Older/stable versions, bundles python requests library https://extensions.libreoffice.org/extensions/pagetranslate
OpenOffice Extensions Full releases, AOO/LO/Windows compatible (bundles deep-translator+requests) https://extensions.openoffice.org/en/project/pagetranslate

For using the unbundled/development package, you should install Python dependencies on your system:
pip3 install -U requests deep-translator six

Usage

  • Hit the Tβ†’πŸ‡¬πŸ‡§ toolbar button to get entire document translated to English. Have some trust and patience for longer documents.
  • The second button 🏴 translates to the local/system language.
  • Or select a paragraph, to get a partial translation.
  • Alternatively pick a menu entry from Tools > PageTranslate.
  • The β†’System lang entry refers to your OpenOffice/Desktop setting.
  • Whereas β†’ Paragraph locale respects the text language as set in the Writer status bar.
  • A manual selection dialog is brought up by the From ➜ To πŸ—Ί menu entry. (Best used in MyMemory mode)
  • Configure options in Toolsβ†’PageTranslateβ†’Options...

Services

service brief summary lang_detect error msgs api keyπŸ”‘ test quali prvcy
ArgosNmt Language combos hinge on trained models langdetect popup - +++++++ +++++
CommandLine Diverse backends mixed log - +++++
DeepTransApi Online interface API mixed popup - ++++
DeepTranslator Diverse services, text + dictionary mixed popup - +++++
DeeplApi High quality AI translation, 15 langs auto popup required + +++
DeeplWeb 15 langs, screen scraping access auto popup - +++++
DuckDuckGo 85 languages, MS Translte w/ privacy auto popup - +++++++++ ++++
GoogleAjax alternative/faster interface auto log - +++++++++
GoogleCloud commercial GTrans variant auto popup required +
GoogleWeb broadest language support (130) auto log - ++++++++++
LibreTranslate online instaces of Argos/OpenNMT langdetect popup required +++++++
MyMemory Dictionary-based, 140 languages langdetect popup - +++++
PonsWeb 35 languages, screen scraping+API auto log - +++++ +
SysTran professional service, 50 languages auto popup required ++ ++++

Caveats

  • Generally you want to download the extension package from AOO. Those are usually full releases (2 to 20MB). The smaller package only makes sense for Linux/LibreOffice installations, because then you can automatically utilize local Python modules (pip install requests deep-translator).
  • The plugin is also likely to crash (won't affect Writer) when encountering complex documents (embedded drawings, Calc sheets, OLE elements, etc). It's only been tested with flow text and text tables.
  • Generally there's a log file in /tmp.
  • Empty options page after update:
    • If the plugin doesn't show up in Toolsβ†’Options anymore, or the settings page is empty, then an update bug happened.
    • You'll have to clean up the extensions cache:
      rm -r ~/.config/libreoffice/4/user/uno_packages/cache/
    • Just the cache dir. Then reinstall. But note that this might strip any other installed extensions (not sure).
    • Optionally also clean up rm -r ~/.config/libreoffice/4/user/extensions/tmp/
  • For runtime bugs see help/…/errors.duck

Extras

Two subprojects here are dingonyms and a standalone PageTranslate: tk_translate.

ToDo

  • Figure out if para.CharLocale can be set to target language after translation.
  • Consider lingva inclusion (but a Google Web proxy).
  • Unify internal API lang=/source= handling, extract .skip() check, and outsource some of the common processing to main.
  • Integrate deep-translator backends (Yandex, QCRI, Pons, Linguee) and language mapping. Perhaps offer as alternative to T-P and internal variants.
  • Finalize DeepL web translation mode (for testing really). The API mode is untested, but likely faster because longer paragraphs can be translated at once. And reportedly it yields smoother/more natural translations. (No XML block translation yet.)
  • Unfortunately not sure yet how to bundle requests.
  • Nor how to craft an options/settings page.
  • Support for TextFrames
  • Figure out if getText() provides for some XML serialization, or how to traverse Paragraphs piece by piece (super slow mode: retain more formatting).
  • Does not yet support anything but Writer documents. (Structure is entirely distinct for Draw/Impress).
  • Not sure if the toolbar icons work at all, or if that's a bug in the Linux version of LibreOffice.