Check-in [e257d8dd7d]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add alternative "GoogleApis Ajax Translate" endpoint. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e257d8dd7debf7b2bee5535a9c9a7e05 |
User & Date: | mario 2021-05-31 14:48:43 |
Context
2021-05-31
| ||
23:22 | document config: options where used check-in: 83b827c27b user: mario tags: trunk | |
14:48 | Add alternative "GoogleApis Ajax Translate" endpoint. check-in: e257d8dd7d user: mario tags: trunk | |
10:39 | Add papago translator from D-T check-in: aeeab5bf1f user: mario tags: trunk | |
Changes
Changes to OptionsDialog.xdl.
︙ | ︙ | |||
13 14 15 16 17 18 19 | <dlg:checkbox dlg:id="slow" dlg:tab-index="2" dlg:left="10" dlg:top="113" dlg:width="109" dlg:height="10" dlg:help-text="Split sentences on formatting prior translation (= more roundtrips, less cohesive sentence structure / translation)" dlg:help-url="HIDID" dlg:value="slow mode (more inline formatting)" dlg:checked="false"/> <dlg:fixedline dlg:id="FixedLine1" dlg:tab-index="6" dlg:left="5" dlg:top="75" dlg:width="117" dlg:height="9" dlg:value="Options"/> <dlg:fixedline dlg:id="FixedLine3" dlg:tab-index="7" dlg:left="5" dlg:top="5" dlg:width="117" dlg:height="7" dlg:value="Service"/> <dlg:fixedline dlg:id="FixedLine2" dlg:tab-index="8" dlg:left="131" dlg:top="5" dlg:width="115" dlg:height="8" dlg:value="Parameters"/> <dlg:fixedline dlg:id="Label1" dlg:tab-index="9" dlg:left="137" dlg:top="20" dlg:width="23" dlg:height="8" dlg:value="API key "/> <dlg:fixedline dlg:id="Label2" dlg:tab-index="10" dlg:left="137" dlg:top="42" dlg:width="28" dlg:height="8" dlg:printable="false" dlg:value="Email adr "/> <dlg:fixedline dlg:id="Label3" dlg:tab-index="11" dlg:left="137" dlg:top="64" dlg:width="30" dlg:height="8" dlg:value="Command "/> | | > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <dlg:checkbox dlg:id="slow" dlg:tab-index="2" dlg:left="10" dlg:top="113" dlg:width="109" dlg:height="10" dlg:help-text="Split sentences on formatting prior translation (= more roundtrips, less cohesive sentence structure / translation)" dlg:help-url="HIDID" dlg:value="slow mode (more inline formatting)" dlg:checked="false"/> <dlg:fixedline dlg:id="FixedLine1" dlg:tab-index="6" dlg:left="5" dlg:top="75" dlg:width="117" dlg:height="9" dlg:value="Options"/> <dlg:fixedline dlg:id="FixedLine3" dlg:tab-index="7" dlg:left="5" dlg:top="5" dlg:width="117" dlg:height="7" dlg:value="Service"/> <dlg:fixedline dlg:id="FixedLine2" dlg:tab-index="8" dlg:left="131" dlg:top="5" dlg:width="115" dlg:height="8" dlg:value="Parameters"/> <dlg:fixedline dlg:id="Label1" dlg:tab-index="9" dlg:left="137" dlg:top="20" dlg:width="23" dlg:height="8" dlg:value="API key "/> <dlg:fixedline dlg:id="Label2" dlg:tab-index="10" dlg:left="137" dlg:top="42" dlg:width="28" dlg:height="8" dlg:printable="false" dlg:value="Email adr "/> <dlg:fixedline dlg:id="Label3" dlg:tab-index="11" dlg:left="137" dlg:top="64" dlg:width="30" dlg:height="8" dlg:value="Command "/> <dlg:menulist dlg:id="backend" dlg:tab-index="12" dlg:left="10" dlg:top="20" dlg:width="105" dlg:height="14" dlg:help-text="Which translation service to use. (Some might require an API key, or email address.)" dlg:spin="true" dlg:linecount="20"> <dlg:menupopup> <dlg:menuitem dlg:value="Google Translate"/> <dlg:menuitem dlg:value="MyMemory"/> <dlg:menuitem dlg:value="PONS Text Translation"/> <dlg:menuitem dlg:value="command line tool"/> <dlg:menuitem dlg:value="DeepL API"/> <dlg:menuitem dlg:value="DeepL Free API"/> <dlg:menuitem dlg:value="DeepL web interface"/> <dlg:menuitem dlg:value="Google Ajax Translate API"/> <dlg:menuitem dlg:value="TP: Microsoft Translator"/> <dlg:menuitem dlg:value="DT: QCRI Machine Translation"/> <dlg:menuitem dlg:value="DT: Yandex Translation"/> <dlg:menuitem dlg:value="DT: Papago Web Translator"/> <dlg:menuitem dlg:value="DT: Pons Dictionary"/> <dlg:menuitem dlg:value="DT: Linguee Dictionary"/> <dlg:menuitem dlg:value="DT: DeepL Free API"/> |
︙ | ︙ | |||
57 58 59 60 61 62 63 | <dlg:menupopup> <dlg:menuitem dlg:value="translate-cli -o -f auto -t {lang} {text}"/> <dlg:menuitem dlg:value="deep_translator -trans "google" -src "auto" -tg {lang} -txt {text}"/> <dlg:menuitem dlg:value="trans -sl {from} {text} {lang}"/> <dlg:menuitem dlg:value="dingonyms --en-fr {text}"/> </dlg:menupopup> </dlg:combobox> | | | 58 59 60 61 62 63 64 65 66 67 | <dlg:menupopup> <dlg:menuitem dlg:value="translate-cli -o -f auto -t {lang} {text}"/> <dlg:menuitem dlg:value="deep_translator -trans "google" -src "auto" -tg {lang} -txt {text}"/> <dlg:menuitem dlg:value="trans -sl {from} {text} {lang}"/> <dlg:menuitem dlg:value="dingonyms --en-fr {text}"/> </dlg:menupopup> </dlg:combobox> <dlg:img dlg:style-id="0" dlg:id="logo" dlg:tab-index="23" dlg:left="200" dlg:top="135" dlg:width="40" dlg:height="40" dlg:src="vnd.sun.star.extension://vnd.include-once.pagetranslate/icons/flags.png"/> </dlg:bulletinboard> </dlg:window> |
Changes to help/en/vnd.include-once.pagetranslate/config.page.
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 | <desc>PageTranslate settings</desc> </info> <title>Translation settings</title> <p>The options page can be found under <guiseq><gui>Tools</gui> <gui>Options</gui> <gui>🗔</gui> <gui>Language Settings</gui> <gui>PageTranslate</gui></guiseq>. <media type="image" src="https://fossil.include-once.org/pagetranslate/raw/d35739991b9e453b352ca83e44c2f7f5c7383927?m=image/png" mime="image/png" /> </p> <section id="service"> <title>Translation service to use</title> | > > | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <desc>PageTranslate settings</desc> </info> <title>Translation settings</title> <p>The options page can be found under <guiseq><gui>Tools</gui> <gui>Options</gui> <gui>🗔</gui> <gui>Language Settings</gui> <gui>PageTranslate</gui></guiseq>. Or per shortcut in <guiseq><gui>Tools</gui><gui>PageTranslate</gui><gui>Options</gui></guiseq>. <media type="image" src="https://fossil.include-once.org/pagetranslate/raw/d35739991b9e453b352ca83e44c2f7f5c7383927?m=image/png" mime="image/png" /> </p> <section id="service"> <title>Translation service to use</title> <p>Machine translations can vary wildly between different services. Which is why PageTranslate provides multiple backends for choice and as fallback:</p> <terms> <item> <title>Google Translate</title> <p><link href="https://translate.google.com/">Google Translate</link> is the default option, and suitable to both text selection and translating whole pages. Provides pretty good machine translations. It incurs some delays for longer texts, as each 1900 characters |
︙ | ︙ | |||
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | <p>Utilizes web scraping on the <link href="https://www.deepl.com/translator/">DeepL online translator</link>. Only suitable for testing and translating single paragraphs or text selection, because it quickly blocks with "error 429 - too many requests". It's also kinda redundant now that there's a Free API option.</p> </item> </terms> <p>Some are provided via <link href="https://pypi.org/project/translate/">translate-python</link> (TP):</p> <terms> <item> <title>Microsoft Translator</title> <p>Requires an authorization key. There's also a free/test <link href="https://azure.microsoft.com/en-us/pricing/details/cognitive-services/translator/">subscription for an API key</link>. Not tested within PageTranslate yet.</p> </item> </terms> <p>And more via <link href="https://pypi.org/project/deep-translator/">deep-translator</link> (DT). These won't work in OpenOffice 4.x due to its Python 2.7 runtime:</p> <terms> <item> <title>Yandex Translation</title> <p>Also requires its own <link | > > > > > > > | | | > > > > > | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | <p>Utilizes web scraping on the <link href="https://www.deepl.com/translator/">DeepL online translator</link>. Only suitable for testing and translating single paragraphs or text selection, because it quickly blocks with "error 429 - too many requests". It's also kinda redundant now that there's a Free API option.</p> </item> <item> <title>GoogleApis Ajax Translate</title> <p>Is basically just an alternative endpoint for Google Translate, which due to JSON/AJAX might work faster or more reliably even. (But it might just as well get blocked sooner for clients like this. This is built in merely as another fallback option.)</p> </item> </terms> <p>Some are provided via <link href="https://pypi.org/project/translate/">translate-python</link> (TP):</p> <terms> <item> <title>Microsoft Translator</title> <p>Requires an authorization key. There's also a free/test <link href="https://azure.microsoft.com/en-us/pricing/details/cognitive-services/translator/">subscription for an API key</link>. Not tested within PageTranslate yet.</p> </item> </terms> <p>And more via <link href="https://pypi.org/project/deep-translator/">deep-translator</link> (DT). These won't work in OpenOffice 4.x due to its Python 2.7 runtime:</p> <terms> <item> <title>Yandex Translation</title> <p>Also requires its own <link href="https://translate.yandex.com/">API key</link>. (Unclear if you can still get one though). It's supposed to support automatic language detection, and provides a vast range of target languages.</p> </item> <item> <title>QCRI Machine Translation</title> <p>Requires a <link href="https://mt.qcri.org/api/">free API key</link>, and only supports Arabic/Spanish/English translations. Also doesn't support auto-detection, and probably needs the From-To selection.</p> </item> <item> <title>Papago Web Translator</title> <p>Might be based on DeepL. Requires a client_id and secret_key in the API field - separated by colon [<cmd>c123:pw678</cmd>].</p> </item> <item> <title>Linguee Dictionary</title> <p>Performs word-wise <link href="https://www.linguee.com/">translation</link> lookups, so not suitable for translating whole documents, but just text selections. Albeit PageTranslate will split up sentences and pipe each word through the service; that won't yield a readable machine translation. |
︙ | ︙ | |||
136 137 138 139 140 141 142 | <title>Parameters</title> <terms> <item> <title>API key</title> <p>You can set an API or OAuth key for services that require one. The same input field serves for all backends, so you can't switch between them without also changing this entry first. (Not a common use case | | > | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | <title>Parameters</title> <terms> <item> <title>API key</title> <p>You can set an API or OAuth key for services that require one. The same input field serves for all backends, so you can't switch between them without also changing this entry first. (Not a common use case to have multiple API subscriptions really. And ideally this would utilize <file>.netrc</file>, but nobody cares about standardization anymore.)</p> </item> <item> <title>Email adr</title> <p>An email address is only required by MyMemory. And strictly speaking it's not even required; it just allows for more translations.</p> </item> |
︙ | ︙ | |||
207 208 209 210 211 212 213 214 215 216 217 | <title>select</title> <p> Always brings up the explicit From→To🗺 language selection popup (useful for MyMemory or Pons backends).</p> </item> <item> <title>en, de, it, fr, ...</title> <p> You can set this field to any two-letter language code - to be used as default target. </p> </item> </terms> </section> </page> | > > > > | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | <title>select</title> <p> Always brings up the explicit From→To🗺 language selection popup (useful for MyMemory or Pons backends).</p> </item> <item> <title>en, de, it, fr, ...</title> <p> You can set this field to any two-letter language code - to be used as default target. </p> </item> <item> <title>mri-debug</title> <p> Requires the MRI extension, and brings up an introspection dialog on the document when invoked. </p> </item> </terms> </section> </page> |
Changes to help/en/vnd.include-once.pagetranslate/config.xhp.
1 2 3 4 5 6 7 8 9 | <?xml version="1.0" encoding="UTF-8"?> <helpdocument version="1.0"> <meta> <topic id="topic_d1e3" indexer="include" status="PUBLISH"> <title xml-lang="en" id="title_d1e3">Translation settings</title> <filename>/help/vnd.include-once.pagetranslate/config.xhp</filename> </topic> <history> <created date="2020-02-02T22:22:22"/> | | > > > | | | > | | | | | | | | | | | | | | | > > > > > > > > | | | | | | | | | | | | | > > > > > > | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | <?xml version="1.0" encoding="UTF-8"?> <helpdocument version="1.0"> <meta> <topic id="topic_d1e3" indexer="include" status="PUBLISH"> <title xml-lang="en" id="title_d1e3">Translation settings</title> <filename>/help/vnd.include-once.pagetranslate/config.xhp</filename> </topic> <history> <created date="2020-02-02T22:22:22"/> <lastedited date="2021-05-31T16:48:01.821+02:00"/> </history> </meta> <body> <bookmark id="bm_d1e7" branch="hid/vnd.include-once.pagetranslate:OptionsPageTranslate" xml-lang="en"> <bookmark_value>PageTranslate settings</bookmark_value> </bookmark> <bookmark id="helpindex_d1e9" branch="index" xml-lang="en"> <bookmark_value>translation; pagetranslate; options</bookmark_value> </bookmark> <paragraph id="hd_d1e15" role="heading" level="1" xml-lang="en">Translation settings</paragraph> <paragraph id="par_d1e18" role="paragraph" xml-lang="en">The options page can be found under <item type="gui">Tools</item> <item type="gui">Options</item> <item type="gui">🗔</item> <item type="gui">Language Settings</item> <item type="gui">PageTranslate</item>. Or per shortcut in <item type="gui">Tools</item> <item type="gui">PageTranslate</item> <item type="gui">Options</item>. <!--xsl:skipped=<media>--> </paragraph> <paragraph id="sect_d1e47" role="section" xml-lang="en"> <paragraph id="hd_d1e49" role="heading" level="2" xml-lang="en">Translation service to use</paragraph> <paragraph id="par_d1e52" role="paragraph" xml-lang="en">Machine translations can vary wildly between different services. Which is why PageTranslate provides multiple backends for choice and as fallback:</paragraph> <list id="terms_d1e55" xml-lang="en"> <listitem id="item_d1e57" xml-lang="en"> <emph>Google Translate</emph> <br/> <paragraph id="par_d1e62" role="paragraph" xml-lang="en"> <link href="https://translate.google.com/">Google Translate</link> is the default option, and suitable to both text selection and translating whole pages. Provides pretty good machine translations. It incurs some delays for longer texts, as each 1900 characters (sentences/paragraphs) have to be transfered individually (managed automatically, no user interaction necessary).</paragraph> </listitem> <listitem id="item_d1e68" xml-lang="en"> <emph>MyMemory</emph> <br/> <paragraph id="par_d1e73" role="paragraph" xml-lang="en">For <link href="https://mymemory.translated.net/">MyMemory</link> you should specify an email address in the according input box (though it's optional, it unlocks more requests). No longer requires the python-translate module, but <item type="fileitem">langdetect</item> (for supplying the correct source language). Which is why it sometimes fails, and possibly requires the Tools → PageTranslate → From ➜ To option. Doesn't yield quite as good machine translations. But it's an open source service. </paragraph> </listitem> <listitem id="item_d1e83" xml-lang="en"> <emph>PONS Text Translation</emph> <br/> <paragraph id="par_d1e88" role="paragraph" xml-lang="en">With <link href="https://en.pons.com/text-translation">Pons</link> you can also translate whole text documents. This service however requires an explicit source language (From→To dialog). Autodetection in PageTranslate is somewhat frail. (Note that this is distinct from the Pons Dict support in deep-translator.)</paragraph> </listitem> <listitem id="item_d1e95" xml-lang="en"> <emph>Command line tool</emph> <br/> <paragraph id="par_d1e100" role="paragraph" xml-lang="en">Allows to send each text paragraph to a local application. To use it, set the command in the according input field again. Placeholders are `{lang}` for the target language, and `{text}` for the paragaphs or current text section. (Both get automatically escaped). For <item type="command">translate-cli</item> you might need the <item type="variable">-p</item> provider option or a prepared <item type="fileitem">~/.python-translate.cfg</item> for API keys. </paragraph> </listitem> <listitem id="item_d1e113" xml-lang="en"> <emph>DeepL API</emph> <br/> <paragraph id="par_d1e118" role="paragraph" xml-lang="en">Utilizes the speedier <link href="https://www.deepl.com/pro">DeepL Pro API</link> to translate documents. As of yet untested. Requires an API key and paid subscription. No XML mode (to retain full inline formatting) yet, still translates each text segment/paragraph/sentence individually.</paragraph> </listitem> <listitem id="item_d1e126" xml-lang="en"> <emph>DeepL Free API</emph> <br/> <paragraph id="par_d1e131" role="paragraph" xml-lang="en">You can now get a free API key for limited usage (500K characters per month - around 1 or 2 documents per day). This secondary API might not be as well maintained. And signup still requires a credit card (use one of the privacy or temporary online credit card services).</paragraph> </listitem> <listitem id="item_d1e135" xml-lang="en"> <emph>DeepL web interface</emph> <br/> <paragraph id="par_d1e140" role="paragraph" xml-lang="en">Utilizes web scraping on the <link href="https://www.deepl.com/translator/">DeepL online translator</link>. Only suitable for testing and translating single paragraphs or text selection, because it quickly blocks with "error 429 - too many requests". It's also kinda redundant now that there's a Free API option.</paragraph> </listitem> <listitem id="item_d1e147" xml-lang="en"> <emph>GoogleApis Ajax Translate</emph> <br/> <paragraph id="par_d1e152" role="paragraph" xml-lang="en">Is basically just an alternative endpoint for Google Translate, which due to JSON/AJAX might work faster or more reliably even. (But it might just as well get blocked sooner for clients like this. This is built in merely as another fallback option.)</paragraph> </listitem> </list> <paragraph id="par_d1e157" role="paragraph" xml-lang="en">Some are provided via <link href="https://pypi.org/project/translate/">translate-python</link> (TP):</paragraph> <list id="terms_d1e163" xml-lang="en"> <listitem id="item_d1e165" xml-lang="en"> <emph>Microsoft Translator</emph> <br/> <paragraph id="par_d1e170" role="paragraph" xml-lang="en">Requires an authorization key. There's also a free/test <link href="https://azure.microsoft.com/en-us/pricing/details/cognitive-services/translator/">subscription for an API key</link>. Not tested within PageTranslate yet.</paragraph> </listitem> </list> <paragraph id="par_d1e179" role="paragraph" xml-lang="en">And more via <link href="https://pypi.org/project/deep-translator/">deep-translator</link> (DT). These won't work in OpenOffice 4.x due to its Python 2.7 runtime:</paragraph> <list id="terms_d1e185" xml-lang="en"> <listitem id="item_d1e187" xml-lang="en"> <emph>Yandex Translation</emph> <br/> <paragraph id="par_d1e192" role="paragraph" xml-lang="en">Also requires its own <link href="https://translate.yandex.com/">API key</link>. (Unclear if you can still get one though). It's supposed to support automatic language detection, and provides a vast range of target languages.</paragraph> </listitem> <listitem id="item_d1e199" xml-lang="en"> <emph>QCRI Machine Translation</emph> <br/> <paragraph id="par_d1e204" role="paragraph" xml-lang="en">Requires a <link href="https://mt.qcri.org/api/">free API key</link>, and only supports Arabic/Spanish/English translations. Also doesn't support auto-detection, and probably needs the From-To selection.</paragraph> </listitem> <listitem id="item_d1e211" xml-lang="en"> <emph>Papago Web Translator</emph> <br/> <paragraph id="par_d1e216" role="paragraph" xml-lang="en">Might be based on DeepL. Requires a client_id and secret_key in the API field - separated by colon [<item type="command">c123:pw678</item>].</paragraph> </listitem> <listitem id="item_d1e223" xml-lang="en"> <emph>Linguee Dictionary</emph> <br/> <paragraph id="par_d1e228" role="paragraph" xml-lang="en">Performs word-wise <link href="https://www.linguee.com/">translation</link> lookups, so not suitable for translating whole documents, but just text selections. Albeit PageTranslate will split up sentences and pipe each word through the service; that won't yield a readable machine translation. </paragraph> </listitem> <listitem id="item_d1e235" xml-lang="en"> <emph>Pons Dictonary</emph> <br/> <paragraph id="par_d1e240" role="paragraph" xml-lang="en">Also is more of a <link href="https://de.pons.com/">dictionary</link> than a translation service. Suitable for text-selections, but probably not paragraphs or whole documents. PageTranslate will split-process longer selections word-wise through the Pons Translation interface.</paragraph> </listitem> </list> <paragraph id="par_d1e248" role="paragraph" xml-lang="en">Some DT: entries are duplicates, and could be used as fallback / in case of errors.</paragraph> </paragraph> <paragraph id="sect_d1e252" role="section" xml-lang="en"> <paragraph id="hd_d1e254" role="heading" level="2" xml-lang="en">Parameters</paragraph> <list id="terms_d1e257" xml-lang="en"> <listitem id="item_d1e259" xml-lang="en"> <emph>API key</emph> <br/> <paragraph id="par_d1e264" role="paragraph" xml-lang="en">You can set an API or OAuth key for services that require one. The same input field serves for all backends, so you can't switch between them without also changing this entry first. (Not a common use case to have multiple API subscriptions really. And ideally this would utilize <item type="fileitem">.netrc</item>, but nobody cares about standardization anymore.)</paragraph> </listitem> <listitem id="item_d1e271" xml-lang="en"> <emph>Email adr</emph> <br/> <paragraph id="par_d1e276" role="paragraph" xml-lang="en">An email address is only required by MyMemory. And strictly speaking it's not even required; it just allows for more translations.</paragraph> </listitem> <listitem id="item_d1e280" xml-lang="en"> <emph>Command</emph> <br/> <paragraph id="par_d1e285" role="paragraph" xml-lang="en">This field defines the CLI tool to use for translating. Placeholders can be noted with {text} curly braces, or shell $lang and %from% percent syntax. The Python <link href="https://pypi.org/project/translate/">translate</link> or <link href="https://pypi.org/project/deep-translator/">deep-translator</link> packages provide following CLI wrappers:</paragraph> </listitem> </list> </paragraph> <paragraph id="sect_d1e311" role="section" xml-lang="en"> <paragraph id="hd_d1e313" role="heading" level="2" xml-lang="en">Options / Flags</paragraph> <list id="terms_d1e316" xml-lang="en"> <listitem id="item_d1e318" xml-lang="en"> <emph>❏ quick linebreak handling</emph> <br/> <paragraph id="par_d1e323" role="paragraph" xml-lang="en">Might speed up table processing with Google Translate, as it avoids sending each newline-split sentence separately. It simply conjoins multiple lines temporarily with <item type="command">"/#§/"</item> in place of a linebreak (and then rejoins them), so there are less requests. Primarily helps with tables, but less for documents with lengthy paragraphs.</paragraph> </listitem> <listitem id="item_d1e330" xml-lang="en"> <emph>❏ also iterate over TextFrames</emph> <br/> <paragraph id="par_d1e335" role="paragraph" xml-lang="en">Handles normal and floating TextFrames. Those are essentially subdocuments in a Writer page. But you probably don't need this option for standard office documents.</paragraph> </listitem> <listitem id="item_d1e339" xml-lang="en"> <emph>❏ super slow mode</emph> <br/> <paragraph id="par_d1e344" role="paragraph" xml-lang="en">Iterates over paragraph segments, to keep more inline formatting - but seriously harms mid-sentence translations. And currently the formatting still bleeds into adjoining paragraph segments, so not very useful in practice yet.</paragraph> </listitem> <listitem id="item_d1e348" xml-lang="en"> <emph>☑ debug mode</emph> <br/> <paragraph id="par_d1e353" role="paragraph" xml-lang="en">Will fill up the <item type="fileitem">/tmp/pagetranslate-libreoffice.txt</item> log file quicker. Currently the debug mode is enabled by default anyway.</paragraph> </listitem> </list> </paragraph> <paragraph id="sect_d1e362" role="section" xml-lang="en"> <paragraph id="hd_d1e364" role="heading" level="2" xml-lang="en">🏴 button default behaviour/target language</paragraph> <list id="terms_d1e367" xml-lang="en"> <listitem id="item_d1e369" xml-lang="en"> <emph>locale</emph> <br/> <paragraph id="par_d1e374" role="paragraph" xml-lang="en"> Per default uses the Office/system language as target. </paragraph> </listitem> <listitem id="item_d1e378" xml-lang="en"> <emph>paragraph</emph> <br/> <paragraph id="par_d1e383" role="paragraph" xml-lang="en"> Uses the "paragraph" locale as set in the Writer/language status bar. </paragraph> </listitem> <listitem id="item_d1e387" xml-lang="en"> <emph>select</emph> <br/> <paragraph id="par_d1e392" role="paragraph" xml-lang="en"> Always brings up the explicit From→To🗺 language selection popup (useful for MyMemory or Pons backends).</paragraph> </listitem> <listitem id="item_d1e396" xml-lang="en"> <emph>en, de, it, fr, ...</emph> <br/> <paragraph id="par_d1e401" role="paragraph" xml-lang="en"> You can set this field to any two-letter language code - to be used as default target. </paragraph> </listitem> <listitem id="item_d1e405" xml-lang="en"> <emph>mri-debug</emph> <br/> <paragraph id="par_d1e410" role="paragraph" xml-lang="en"> Requires the MRI extension, and brings up an introspection dialog on the document when invoked. </paragraph> </listitem> </list> </paragraph> </body> </helpdocument> |
Changes to help/en/vnd.include-once.pagetranslate/project.xhp.
1 2 3 4 5 6 7 8 9 | <?xml version="1.0" encoding="UTF-8"?> <helpdocument version="1.0"> <meta> <topic id="topic_d1e1" indexer="include" status="PUBLISH"> <title xml-lang="en" id="title_d1e1">Project</title> <filename>/help/vnd.include-once.pagetranslate/project.xhp</filename> </topic> <history> <created date="2020-02-02T22:22:22"/> | | | | < | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <?xml version="1.0" encoding="UTF-8"?> <helpdocument version="1.0"> <meta> <topic id="topic_d1e1" indexer="include" status="PUBLISH"> <title xml-lang="en" id="title_d1e1">Project</title> <filename>/help/vnd.include-once.pagetranslate/project.xhp</filename> </topic> <history> <created date="2020-02-02T22:22:22"/> <lastedited date="2021-05-31T16:28:05.091+02:00"/> </history> </meta> <body> <link href="vnd.include-once.pagetranslate/index.xhp"/> <paragraph id="hd_d1e8" role="heading" level="1" xml-lang="en">Project</paragraph> <paragraph id="par_d1e11" role="paragraph" xml-lang="en">More information on this extension can be found in the development and source code repository:</paragraph> <paragraph id="par_d1e14" role="paragraph" xml-lang="en">@link[seealso >>https://fossil.include-once.org/pagetranslate/] @title Link https://fossil.include-once.org/pagetranslate/</paragraph> <paragraph id="par_d1e17" role="paragraph" xml-lang="en">It's sort of feature complete for the intended purposes. But shouldn't be considered stable or finished. However, there's unlikely to be enough user interest for more releases.</paragraph> <paragraph id="par_d1e21" role="paragraph" xml-lang="en">The development package should only be used on Linux installations, for there is little Python support on Windows. Also take in mind that the OpenOffice package is slightly better equipped with Python dependencies, yet may have some issues with the older Python 2.7 in AOO. Development versions of LibreOffice on the other hand might yield errors for SSL support.</paragraph> </body> </helpdocument> |
Changes to pythonpath/translationbackends.py.
︙ | ︙ | |||
114 115 116 117 118 119 120 121 122 123 124 125 126 127 | text = "\n\n".join(self.translate(text) for text in text.split("\n\n")) else: # use temporary placeholder `/#§/` text = self.translate(text.replace("\n\n", u"/#§/")) text = re.sub(rx.breakln, "\n\n", text) return text # DeepL online translator # · will easily yield HTTP 429 Too many requests, # so probably not useful for multi-paragraph translation anyway (just text selections) # · uses some kind of json-rpc # # data origins: | > > > > > > > > > > > > > > > > > > > > | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | text = "\n\n".join(self.translate(text) for text in text.split("\n\n")) else: # use temporary placeholder `/#§/` text = self.translate(text.replace("\n\n", u"/#§/")) text = re.sub(rx.breakln, "\n\n", text) return text # variant that uses the AJAX or API interface class google_ajax(google): # request text translation from google def fetch(self, text, dst_lang="en", src_lang='auto'): r = http.get( url="https://translate.googleapis.com/translate_a/single", params={ "client": "gtx", "sl": self.params["from"], "tl": self.params["lang"], "dt": "t", "q": text } ) if r.status_code == 200: text = r.json()[0][0][0] # result is usually wrapped in three lists [[[u"translated text", u"original", None, None, 3, None, None, [[]],... else: log.debug("AJAX ERROR: " + repr(r)) return text # DeepL online translator # · will easily yield HTTP 429 Too many requests, # so probably not useful for multi-paragraph translation anyway (just text selections) # · uses some kind of json-rpc # # data origins: |
︙ | ︙ | |||
559 560 561 562 563 564 565 | # maps a pagetranslate.t.* object (in main module), # according to configured backend (now a string) def assign_service(params): w = params.get("backend", "Google") map = { | > | | 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | # maps a pagetranslate.t.* object (in main module), # according to configured backend (now a string) def assign_service(params): w = params.get("backend", "Google") map = { "^google$ | ^google [\s\-_] translate$": google, "^google.*ajax": google_ajax, "^deepl [\s_] web": deepl_web, "^deepl [\s_] (api|pro)": deepl_api, "^deepl \s free": deepl_free_api, "^mymemory | translated\.net": mymemory, "^pons \s text": pons, "^command | ^CLI | tool | program": cli, "^microsoft | translate[_-]py | ^T-?P: | \(T-?P\)": translate_python, |
︙ | ︙ |