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

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


Artifact [d20405d267]

Artifact d20405d267ea78bcad23b23a675940ff3f4f86ef:

Wiki page [PageTranslate] by mario 2020-06-07 13:23:57.
D 2020-06-07T13:23:57.542
L PageTranslate
N text/x-markdown
P 066c965e0596b86c830fbfdb5a2711724aaeb057
U mario
W 3877
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).
 * And is therefore **rather slow**.  
     <span style="background:yellow">(Writer freezes during process for long documents!)</span>
 * Still allows for text-selection mode translation (from [original extension](https://extensions.libreoffice.org/extensions/tradutorlibretext)).
  
### Test/Install

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


| Location | Features | Link |
--------------------------------
| Source repository | Newest package, <span style="color:red">Linux-only package</span>, no python dependencies | <a href="/pagetranslate/zip/PageTranslate.oxt?uuid=trunk&name=" style="width:120pt" class="button download green">pagetranslate.oxt</a> |
| LibreOffice Extensions | Older/stable versions, bundles python `requests` library | [https://extensions.libreoffice.org/extensions/pagetranslate](https://extensions.libreoffice.org/extensions/pagetranslate) |
| OpenOffice Extensions | Full releases, AOO/LO/Windows compatible (bundles `translate`+`requests`) | [https://extensions.openoffice.org/en/project/pagetranslate](https://extensions.openoffice.org/en/project/pagetranslate) |


### Usage

 * Hit the <kbd>Tβ†’πŸ‡¬πŸ‡§</kbd> toolbar button to get entire document translated to English. Have some trust and patience for longer documents.
 * The second button <kbd>🏴</kbd> translates to the local/system language.
 * Or select a paragraph, to get a partial translation.
 * Alternatively pick a menu entry from <kbd>Extras</kbd> > <kbd>PageTranslate</kbd>.
 * The <kbd>β†’System lang</kbd> entry refers to your OpenOffice/Desktop setting.
 * Whereas <kbd>β†’ Paragraph locale</kbd> respects the text language as set in the Writer status bar.
 * Configure [options in <kbd>Tools</kbd>β†’<kbd>Options</kbd>β†’<kbd>Language Settings</kbd>β†’<kbd>PageTranslate</kbd>](wiki/options)

### Caveats

 * <s>Does not yet support anything but Writer documents. (Structure is entirely distinct for Draw/Impress).</s>
 * 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.
 * <s>Not sure if the toolbar icons work at all, or if that's a bug in the Linux version of LibreOffice.</s>
 * OpenOffice support is somewhat preliminary still (albeit it's mostly Python 2.7 fallbacks and XCU variations).
 * For direct content.xml translations, there's an inconvenient tool in off/. (Each office document .odt/.odc is a zip file. Extract the content.xml, apply the script, then repackage the content.xml into the .odc)

### ToDo

 * <s>Finalize DeepL web translation mode (for testing really).</s> 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.)
 * <s>Unfortunately not sure yet how to [bundle `requests`](wiki/pythonpath).</s>
 * <s>Nor how to craft an [options/settings page](wiki/OptionsDialog).</s>
 * <s>Support for [TextFrames](https://www.openoffice.org/api/docs/common/ref/com/sun/star/text/TextFrame.html)</s>
 * Figure out if [getText()](https://www.openoffice.org/api/docs/common/ref/com/sun/star/text/XTextDocument.html#getText) provides for some XML serialization, <s>or how to traverse [Paragraphs](https://www.openoffice.org/api/docs/common/ref/com/sun/star/text/TextContent.html) piece by piece (super slow mode: retain more formatting).</s>


Z a658210e8e05073ad97ec4f4b3dd4fb4