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

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


Check-in [53081278cb]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use saxonb-xslt for help pages, add short usage/intro page.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:53081278cbb9f0bf3038df078f89cc50f06d5656
User & Date: mario 2020-06-11 18:49:39
Context
2020-06-12
04:42
Fix to dlg:help-url=โ€ฆ Now context-sensitive help pops up for F1 in settings window. (For LibreOffice before 7.0 at least) check-in: 29abf22448 user: mario tags: trunk
2020-06-11
18:49
Use saxonb-xslt for help pages, add short usage/intro page. check-in: 53081278cb user: mario tags: trunk
2020-06-10
05:10
Add help-uri=vnd.sun.star.help://help/vnd.include-once.pagetranslate/config.xhp?Language=en&โ€ฆ; doesn't work of course. check-in: 15c0def16d user: mario tags: trunk
Changes

Changes to Makefile.

1
2
3
4
5
6
7
8
..
11
12
13
14
15
16
17
18
all:	oxt install

install:
	unopkg remove vnd.include-once.pagetranslate
	unopkg add --log-file log.txt -s pagetranslate.oxt

oxt:
	version  --read pagetranslate.py  --incr  --write pagetranslate.py  --write description.xml
................................................................................
#pythonpath:

aoo:	oxt
	/opt/openoffice4/program/unopkg add pagetranslate.oxt
	/opt/openoffice4/program/soffice -writer

xhp:
	cd help/en/vnd.include-once.pagetranslate/ && xsltproc mallard2xhp.xsl config.page.xhp > config.xhp
|







 







|
1
2
3
4
5
6
7
8
..
11
12
13
14
15
16
17
18
all:	xhp oxt install

install:
	unopkg remove vnd.include-once.pagetranslate
	unopkg add --log-file log.txt -s pagetranslate.oxt

oxt:
	version  --read pagetranslate.py  --incr  --write pagetranslate.py  --write description.xml
................................................................................
#pythonpath:

aoo:	oxt
	/opt/openoffice4/program/unopkg add pagetranslate.oxt
	/opt/openoffice4/program/soffice -writer

xhp:
	make -C help/en/vnd.include-once.pagetranslate/

Changes to help/en/help.tree.

1
2
3

4
5
6
7
<?xml version="1.0" encoding="UTF-8"?>
<tree_view>
<help_section application="vnd.include-once.pagetranslate" id="idm49428" title="PageTranslate">

 <topic id="help/vnd.include-once.pagetranslate/config.xhp">Config options</topic>
 <topic id="help/vnd.include-once.pagetranslate/config.page.xhp">Config options (src)</topic>
</help_section>
</tree_view>



>

|


1
2
3
4
5
6
7
8
<?xml version="1.0" encoding="UTF-8"?>
<tree_view>
<help_section application="vnd.include-once.pagetranslate" id="idm49428" title="PageTranslate">
 <topic id="help/vnd.include-once.pagetranslate/usage.xhp">Usage</topic>
 <topic id="help/vnd.include-once.pagetranslate/config.xhp">Config options</topic>
 <topic id="help/vnd.include-once.pagetranslate/config.page">Config options (src)</topic>
</help_section>
</tree_view>

Added help/en/vnd.include-once.pagetranslate/Makefile.











>
>
>
>
>
1
2
3
4
5
all:	config.xhp usage.xhp

%.xhp:  %.page
	saxonb-xslt $*.page mallard2xhp.xsl > $*.xhp
	#xsltproc mallard2xhp.xsl config.page.xhp > config.xhp

Name change from help/en/vnd.include-once.pagetranslate/config.page.xhp to help/en/vnd.include-once.pagetranslate/config.page.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
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

<!--?xml-stylesheet href="./mallard2xhp.xsl" type="text/xsl"?-->
  <!--%origin%/help/en/vnd.include-once.pagetranslate/-->
<page
    xmlns="http://projectmallard.org/1.0/"
    type="guide" group="first"
    id="config">

<info>
    <link type="guide" xref="OptionsPageTranslate"/>
    <link type="index" xref="translation; pagetranslate; options"/>
    <desc>PageTranslate settings</desc>
</info>

<title>Translation settings</title>
<p>The options page can be found under Tools โ†’ Options โ†’ Language Settings โ†’ PageTranslate.</p>

<section id="service">
  <title>Translation service to use</title>
  <terms>
    <item>
      <title>โ˜‘ Google Translate</title>
      <p>That's the default, and suitable to both text selection and translating whole pages.
................................................................................
      <title>โ DeepL web</title>
      <p>Only makes sense for translating a single-paragraph / text selection, because it quickly
      blocks with "error 429 - too many requests" otherwise.</p>
    </item>
    <item>
      <title>โ DeepL per API</title>
      <p>Use the speedier API to translate documents. As of yet untested.
         Requires an API key and paid subscription. No XML mode yet, still translates
         each text segment/paragraph/sentence individually.

      </p>
    </item>
    <item>
      <title>โ Microsoft Translator</title>
      <p>Requires an authorization key, and a `pip install translate` system package.

      Not tested within PageTranslate yet.</p>
    </item>
    <item>
      <title>โ MyMemory</title>
      <p>Should have an email address in the according input box (though optional).
      Also requires `pip install translate`, unless the full OpenOffice plugin bundle
      was installed.

      </p>
    </item>
    <item>
      <title>โ Command line tool</title>
      <p>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.)

      </p>
    </item>
  </terms>
</section>

<section id="flags">
  <title>Operation flags</title>
  <terms>
    <item>
      <title>โ quick linebreak handling</title>
      <p>Might speed up table processing with Google Translate, as it avoids sending each newline-split sentence separately.</p>


    </item>
    <item>
      <title>โ also iterate over TextFrames</title>
      <p>handles floating textframes / subdocuments.</p>

    </item>
    <item>
      <title>โ super slow mode</title>
      <p>iterates over paragraph segments, to keep more inline formatting - but seriously harms mid-sentence translations. Not very useful in practice.</p>

    </item>
    <item>
      <title>โ˜‘ debug mode</title>
      <p>Will fill up the /tmp/pagetranslate-libreoffice.txt log file quicker.</p>

    </item>
  </terms>
</section>

</page>
>
|













|







 







|
|
>





>






|
>







|
>










|
>
>



|
>



|
>



|
>





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
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
<?xml version="1.0"?>
<?xml-stylesheet href="./mallard2xhp.xsl" type="text/xsl"?>
  <!--%origin%/help/en/vnd.include-once.pagetranslate/-->
<page
    xmlns="http://projectmallard.org/1.0/"
    type="guide" group="first"
    id="config">

<info>
    <link type="guide" xref="OptionsPageTranslate"/>
    <link type="index" xref="translation; pagetranslate; options"/>
    <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>.</p>

<section id="service">
  <title>Translation service to use</title>
  <terms>
    <item>
      <title>โ˜‘ Google Translate</title>
      <p>That's the default, and suitable to both text selection and translating whole pages.
................................................................................
      <title>โ DeepL web</title>
      <p>Only makes sense for translating a single-paragraph / text selection, because it quickly
      blocks with "error 429 - too many requests" otherwise.</p>
    </item>
    <item>
      <title>โ DeepL per API</title>
      <p>Use the speedier API 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.
      </p>
    </item>
    <item>
      <title>โ Microsoft Translator</title>
      <p>Requires an authorization key, and a `pip install translate` system package.
      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>
    <item>
      <title>โ MyMemory</title>
      <p>Should have an email address in the according input box (though optional).
      Also requires `pip install translate`, unless the full OpenOffice plugin bundle
      was installed. Doesn't yield quite as good machine translations. But it's
      an open source service.
      </p>
    </item>
    <item>
      <title>โ Command line tool</title>
      <p>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 <cmd>translate-cli</cmd> you might need
      the <var>-p</var> provider option as well.
      </p>
    </item>
  </terms>
</section>

<section id="flags">
  <title>Operation flags</title>
  <terms>
    <item>
      <title>โ quick linebreak handling</title>
      <p>Might speed up table processing with Google Translate, as it avoids sending each newline-split sentence separately.
      It simply conjoins multiple lines temporarily with <cmd>"/#ยง/"</cmd> in place of a
      linebreak (and then rejoins them), so there are less requests.</p>
    </item>
    <item>
      <title>โ also iterate over TextFrames</title>
      <p>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.</p>
    </item>
    <item>
      <title>โ super slow mode</title>
      <p>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.</p>
    </item>
    <item>
      <title>โ˜‘ debug mode</title>
      <p>Will fill up the <file>/tmp/pagetranslate-libreoffice.txt</file> log file quicker.
      Currently the debug mode is enabled by default anyway.</p>
    </item>
  </terms>
</section>

</page>

Changes to help/en/vnd.include-once.pagetranslate/config.xhp.

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
<?xml version="1.0"?>
<helpdocument version="1.0">
  <meta>
    <topic id="topic_idm1" indexer="include" status="PUBLISH">
      <title xml-lang="en" id="title_idm1">Translation settings</title>
      <filename>/help/vnd.include-once.pagetranslate/config.xhp</filename>
    </topic>
    <history>
      <created date="2020-02-02T22:22:22"/>
      <lastedited date="2020-02-02T22:22:22"/>
    </history>
  </meta>
  <body>




    <bookmark id="bm_idm3" branch="hid/vnd.include-once.pagetranslate:OptionsPageTranslate" xml-lang="en"><bookmark_value>PageTranslate settings</bookmark_value></bookmark>


    <bookmark id="helpindex_idm4" branch="index" xml-lang="en"><bookmark_value>translation; pagetranslate; options</bookmark_value></bookmark>
    <!--xsl:skipped=<desc>-->



<paragraph id="hd_idm6" role="heading" level="1" xml-lang="en">Translation settings</paragraph>
<paragraph id="par_idm7" role="paragraph" xml-lang="en">The options page can be found under Tools โ†’ Options โ†’ Language Settings โ†’ PageTranslate.</paragraph>


<paragraph id="sect_idm8" role="section" xml-lang="en">
  <paragraph id="hd_idm9" role="heading" level="2" xml-lang="en">Translation service to use</paragraph>
  <list id="terms_idm10" xml-lang="en">



    <listitem id="item_idm11" xml-lang="en"><paragraph id="hd_idm11" role="heading" level="6" xml-lang="en">โ˜‘ Google Translate</paragraph>That's the default, 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).</listitem>




    <listitem id="item_idm14" xml-lang="en"><paragraph id="hd_idm14" role="heading" level="6" xml-lang="en">โ DeepL web</paragraph>Only makes sense for translating a single-paragraph / text selection, because it quickly
      blocks with "error 429 - too many requests" otherwise.</listitem>




    <listitem id="item_idm17" xml-lang="en"><paragraph id="hd_idm17" role="heading" level="6" xml-lang="en">โ DeepL per API</paragraph>Use the speedier API to translate documents. As of yet untested.
         Requires an API key and paid subscription. No XML mode yet, still translates
         each text segment/paragraph/sentence individually.


      </listitem>



    <listitem id="item_idm20" xml-lang="en"><paragraph id="hd_idm20" role="heading" level="6" xml-lang="en">โ Microsoft Translator</paragraph>Requires an authorization key, and a `pip install translate` system package.

      Not tested within PageTranslate yet.</listitem>




    <listitem id="item_idm23" xml-lang="en"><paragraph id="hd_idm23" role="heading" level="6" xml-lang="en">โ MyMemory</paragraph>Should have an email address in the according input box (though optional).
      Also requires `pip install translate`, unless the full OpenOffice plugin bundle
      was installed.



      </listitem>



    <listitem id="item_idm26" xml-lang="en"><paragraph id="hd_idm26" role="heading" level="6" xml-lang="en">โ Command line tool</paragraph>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.)


      </listitem>
  </list>
</paragraph>

<paragraph id="sect_idm29" role="section" xml-lang="en">
  <paragraph id="hd_idm30" role="heading" level="2" xml-lang="en">Operation flags</paragraph>
  <list id="terms_idm31" xml-lang="en">



    <listitem id="item_idm32" xml-lang="en"><paragraph id="hd_idm32" role="heading" level="6" xml-lang="en">โ quick linebreak handling</paragraph>Might speed up table processing with Google Translate, as it avoids sending each newline-split sentence separately.</listitem>
    <listitem id="item_idm35" xml-lang="en"><paragraph id="hd_idm35" role="heading" level="6" xml-lang="en">โ also iterate over TextFrames</paragraph>handles floating textframes / subdocuments.</listitem>












    <listitem id="item_idm38" xml-lang="en"><paragraph id="hd_idm38" role="heading" level="6" xml-lang="en">โ super slow mode</paragraph>iterates over paragraph segments, to keep more inline formatting - but seriously harms mid-sentence translations. Not very useful in practice.</listitem>
    <listitem id="item_idm41" xml-lang="en"><paragraph id="hd_idm41" role="heading" level="6" xml-lang="en">โ˜‘ debug mode</paragraph>Will fill up the /tmp/pagetranslate-libreoffice.txt log file quicker.</listitem>








  </list>
</paragraph>

</body>
</helpdocument>
|

|
|
|
|
|
|
|
|
|
|
|

<
>
>
|
>
>
|
<
>

<
|
<
>

|
|
|
>
>
>
|


|
>
>
>
>
|
|
>
>
>
>
|
|
|
>
>
|
>
>
>
|
>
|
>
>
>
>
|

<
>
>
>
|
>
>
>
|


|
>
>
|
|
|

|
|
|
>
>
>
|
<
>
>
>
>
>
>
>
>
>
>
>
>
|
<
>
>
>
>
>
>
>
>
|
|

|
|
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
<?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="2020-06-11T17:44:44.269+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>.</paragraph>

      <paragraph id="sect_d1e37" role="section" xml-lang="en">
         <paragraph id="hd_d1e39" role="heading" level="2" xml-lang="en">Translation service to use</paragraph>
         <list id="terms_d1e42" xml-lang="en">
            <listitem id="item_d1e44" xml-lang="en">
               <emph>โ˜‘ Google Translate</emph>
               <br/>
               <paragraph id="par_d1e49" role="paragraph" xml-lang="en">That's the default, 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_d1e53" xml-lang="en">
               <emph>โ DeepL web</emph>
               <br/>
               <paragraph id="par_d1e58" role="paragraph" xml-lang="en">Only makes sense for translating a single-paragraph / text selection, because it quickly
      blocks with "error 429 - too many requests" otherwise.</paragraph>
            </listitem>
            <listitem id="item_d1e62" xml-lang="en">
               <emph>โ DeepL per API</emph>
               <br/>
               <paragraph id="par_d1e67" role="paragraph" xml-lang="en">Use the speedier API 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_d1e71" xml-lang="en">
               <emph>โ Microsoft Translator</emph>
               <br/>
               <paragraph id="par_d1e76" role="paragraph" xml-lang="en">Requires an authorization key, and a `pip install translate` system package.
      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>
            <listitem id="item_d1e83" xml-lang="en">
               <emph>โ MyMemory</emph>
               <br/>
               <paragraph id="par_d1e88" role="paragraph" xml-lang="en">Should have an email address in the according input box (though optional).
      Also requires `pip install translate`, unless the full OpenOffice plugin bundle

      was installed. Doesn't yield quite as good machine translations. But it's
      an open source service.
      </paragraph>
            </listitem>
            <listitem id="item_d1e93" xml-lang="en">
               <emph>โ Command line tool</emph>
               <br/>
               <paragraph id="par_d1e98" 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 as well.
      </paragraph>
            </listitem>
         </list>
      </paragraph>

      <paragraph id="sect_d1e110" role="section" xml-lang="en">
         <paragraph id="hd_d1e112" role="heading" level="2" xml-lang="en">Operation flags</paragraph>
         <list id="terms_d1e115" xml-lang="en">
            <listitem id="item_d1e117" xml-lang="en">
               <emph>โ quick linebreak handling</emph>
               <br/>
               <paragraph id="par_d1e122" 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.</paragraph>
            </listitem>
            <listitem id="item_d1e129" xml-lang="en">
               <emph>โ also iterate over TextFrames</emph>
               <br/>
               <paragraph id="par_d1e134" 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_d1e138" xml-lang="en">
               <emph>โ super slow mode</emph>
               <br/>
               <paragraph id="par_d1e143" 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_d1e147" xml-lang="en">
               <emph>โ˜‘ debug mode</emph>
               <br/>
               <paragraph id="par_d1e152" 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>

   </body>
</helpdocument>

Changes to help/en/vnd.include-once.pagetranslate/mallard2xhp.xsl.

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
..
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?xml version="1.0" encoding="UTF-8"?><!--
/**
 * api: xslt
 * type: transform
 * title: mallard to xhp
 * description: transform help to openoffice xhp
 * version: 0.2

 *
 * Crude mapping from mallard help file to OpenOffice helpdocument/xhp.
 * Only handles paragraphs, titles, lists, sections. No media/images.
 * And info <link>s are just mapped to type=index or bookmark (type=guide)
 * entries, but type=seealso and href= links in the body kept as is.
 * No help.tree generation obviously.
 *
 */-->
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:m="http://projectmallard.org/1.0/" exclude-result-prefixes="m">

<!-- cfg -->
<xsl:variable name="package" select="'vnd.include-once.pagetranslate'"/>

<xsl:variable name="fileref" select="concat('/help/',$package,'/config.xhp')"/><!-- select="base-uri()" -->

<xsl:output mode="xml" indent="yes"/>

<!-- new document carcass -->
<xsl:template match="/m:page">
  <helpdocument version="1.0">
  <meta>
    <topic id="topic_{generate-id()}" indexer="include" status="PUBLISH">
      <title xml-lang="en" id="title_{generate-id()}"><xsl:value-of select="//m:title"/></title>
      <filename><xsl:value-of select="$fileref"/></filename>
    </topic>
    <history>
      <!--created date="{current-dateTime()}"></created>
      <lastedited date="{current-dateTime()}"></lastedited-->
      <created date="2020-02-02T22:22:22"></created>
      <lastedited date="2020-02-02T22:22:22"></lastedited>
    </history>
  </meta>
  <body>
     <xsl:apply-templates/>
  </body>
  </helpdocument>
</xsl:template>

<!-- paragraphs / sections -->



<xsl:template match="m:p">
  <paragraph id="par_{generate-id()}" role="paragraph" xml-lang="en">
    <xsl:value-of select="."/>

  </paragraph>
</xsl:template>
<xsl:template match="m:title">
  <paragraph id="hd_{generate-id()}" role="heading" level="{count(ancestor::*)}" xml-lang="en">
    <xsl:value-of select="."/>
  </paragraph>
</xsl:template>
<xsl:template match="m:section|m:note">


  <paragraph id="sect_{generate-id()}" role="section" xml-lang="en">





    <xsl:apply-templates/>
  </paragraph>






</xsl:template>

<!-- lists -->
<xsl:template match="m:terms">
  <list id="terms_{generate-id()}" xml-lang="en">





    <xsl:apply-templates/>
  </list>
</xsl:template>
<xsl:template match="m:item">
  <listitem id="item_{generate-id()}" xml-lang="en">


    <paragraph id="hd_{generate-id()}" role="heading" level="6" xml-lang="en"><xsl:value-of select="m:title"/></paragraph>
    <xsl:value-of select="m:p"/>
  </listitem>
</xsl:template>
<xsl:template match="m:list">
  <list bullet="disc" type="ordered">
    <xsl:apply-templates/>


  </list>
</xsl:template>

<!-- meta -->
<xsl:template match="m:link">
<xsl:choose>
  <!-- meta links -->
  <xsl:when test="@type='guide'">
................................................................................
  </xsl:when>
  <xsl:when test="@href">
    <link href="{@href}"><xsl:value-of select="."/></link>
  </xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="m:info">
    <xsl:apply-templates match="m:link"/>
</xsl:template>

<!-- remove all else -->
<xsl:template match="*">
  <xsl:comment>xsl:skipped=<xsl:value-of select="concat('&lt;', name(), '&gt;')"/></xsl:comment>
</xsl:template>

</xsl:stylesheet>





|
|
>








|





>
|
>
|






|



|
|
<
<








|
>
>
>


<
>








>
>
|
>
>
>
>
>
|
<
>
>
>
>
>
>




|
>
>
>
>
>





>
>
|
|
<
|
<
|
|
>
>
|







 







|








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
...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?xml version="1.0" encoding="UTF-8"?><!--
/**
 * api: xslt
 * type: transform
 * title: mallard to xhp
 * description: converts help .page to openoffice .xhp
 * version: 0.3
 * depends: bin:saxonb-xslt
 *
 * Crude mapping from mallard help file to OpenOffice helpdocument/xhp.
 * Only handles paragraphs, titles, lists, sections. No media/images.
 * And info <link>s are just mapped to type=index or bookmark (type=guide)
 * entries, but type=seealso and href= links in the body kept as is.
 * No help.tree generation obviously.
 *
 */-->
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:m="http://projectmallard.org/1.0/" exclude-result-prefixes="m">

<!-- cfg -->
<xsl:variable name="package" select="'vnd.include-once.pagetranslate'"/>
<xsl:variable name="filenam" select="replace(replace(base-uri(), '^.+/', ''), '(\.\w+){1,2}$', '.xhp')"/>
<xsl:variable name="fileref" select="concat('/help/',$package,'/',$filenam)"/>
<xsl:variable name="maptype" select="'gui=gui key=keystroke kbd=keystroke dialog=dialog ins=added del=removed span=span input=input output=output var=variable cmd=command app=menuitem sys=menuitem file=fileitem'"/>
<xsl:output indent="yes"/>

<!-- new document carcass -->
<xsl:template match="/m:page">
  <helpdocument version="1.0">
  <meta>
    <topic id="topic_{generate-id()}" indexer="include" status="PUBLISH">
      <title xml-lang="en" id="title_{generate-id()}"><xsl:value-of select="(//m:title)[1]"/></title>
      <filename><xsl:value-of select="$fileref"/></filename>
    </topic>
    <history>
      <created date="2020-02-02T22:22:22"></created>
      <lastedited date="{current-dateTime()}"></lastedited>


    </history>
  </meta>
  <body>
     <xsl:apply-templates/>
  </body>
  </helpdocument>
</xsl:template>

<!-- text nodes / paragraphs / sections -->
<xsl:template match="text()">
  <xsl:value-of select="."/>
</xsl:template>
<xsl:template match="m:p">
  <paragraph id="par_{generate-id()}" role="paragraph" xml-lang="en">

    <xsl:apply-templates/>
  </paragraph>
</xsl:template>
<xsl:template match="m:title">
  <paragraph id="hd_{generate-id()}" role="heading" level="{count(ancestor::*)}" xml-lang="en">
    <xsl:value-of select="."/>
  </paragraph>
</xsl:template>
<xsl:template match="m:section|m:note">
  <xsl:choose>
    <xsl:when test="@style">
      <paragraph id="sect_{generate-id()}" role="{@style}" xml-lang="en"><xsl:apply-templates/></paragraph>
    </xsl:when>
    <xsl:otherwise>
      <paragraph id="sect_{generate-id()}" role="{local-name()}" xml-lang="en"><xsl:apply-templates/></paragraph>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- inline -->
<xsl:template match="m:em"> <emph><xsl:apply-templates/></emph> </xsl:template>
<xsl:template match="m:guiseq|m:keyseq"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="m:gui|m:kbd|m:key|m:dialog|m:ins|m:del|m:span|m:input|m:output|m:var|m:cmd|m:app|m:sys|m:file">
  <item type="{replace($maptype, concat('^.*', local-name(), '=(\w+).*$'), '$1')}"><xsl:apply-templates/></item>
</xsl:template>

<!-- lists -->
<xsl:template match="m:terms">
  <list id="{local-name()}_{generate-id()}" xml-lang="en">
    <xsl:apply-templates/>
  </list>
</xsl:template>
<xsl:template match="m:list|m:steps|m:tree">
  <list bullet="disc" type="ordered">
    <xsl:apply-templates/>
  </list>
</xsl:template>
<xsl:template match="m:item">
  <listitem id="item_{generate-id()}" xml-lang="en">
    <xsl:choose>
      <xsl:when test="m:title">
        <emph><xsl:value-of select="m:title"/></emph><br/>
        <xsl:apply-templates select="m:p"/>

      </xsl:when>

      <xsl:otherwise>
        <xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>
  </listitem>
</xsl:template>

<!-- meta -->
<xsl:template match="m:link">
<xsl:choose>
  <!-- meta links -->
  <xsl:when test="@type='guide'">
................................................................................
  </xsl:when>
  <xsl:when test="@href">
    <link href="{@href}"><xsl:value-of select="."/></link>
  </xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="m:info">
    <xsl:apply-templates select="m:link"/>
</xsl:template>

<!-- remove all else -->
<xsl:template match="*">
  <xsl:comment>xsl:skipped=<xsl:value-of select="concat('&lt;', name(), '&gt;')"/></xsl:comment>
</xsl:template>

</xsl:stylesheet>

Added help/en/vnd.include-once.pagetranslate/usage.page.





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
<?xml version="1.0"?>
<?xml-stylesheet href="./mallard2xhp.xsl" type="text/xsl"?>
<page
    xmlns="http://projectmallard.org/1.0/"
    type="guide" group="first"
    id="usage">

<info>
    <link type="guide" xref=".uno:ToolsMenu\.uno:T3"/>
    <link type="index" xref="translate; pagetranslate"/>
    <desc>Document/Text translation</desc>
</info>

<title>Translating a document</title>
<p>PageTranslate provides two toolbar buttons and a menu <guiseq><gui>Tools</gui>
โ†’ <gui>PageTranslate</gui></guiseq> to get documents machine-translated.</p>

<p>The main button <key>Tโ†’๐Ÿ‡ฌ๐Ÿ‡ง</key> translates text to English. Whereas <key>๐Ÿด</key>
uses the local/Office language as target.</p>

<p>If a text portion is selected, then only that gets replaced. Otherwise, the extension
will traverse the whole Writer/Draw/Impress document, paragraph by paragraph, and substitute
each sentence.</p>
<warning><p>Which might take a while.</p></warning>

<p>There's some <link type="seealso" xref="config#service">options</link> to
change, nameley the used translation service (Google per default), or a few
performance flags.</p>

</page>

Added help/en/vnd.include-once.pagetranslate/usage.xhp.

















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
   <meta>
      <topic id="topic_d1e2" indexer="include" status="PUBLISH">
         <title xml-lang="en" id="title_d1e2">Translating a document</title>
         <filename>/help/vnd.include-once.pagetranslate/usage.xhp</filename>
      </topic>
      <history>
         <created date="2020-02-02T22:22:22"/>
         <lastedited date="2020-06-11T19:51:14.891+02:00"/>
      </history>
   </meta>
   <body>

      <bookmark id="bm_d1e6" branch="hid/vnd.include-once.pagetranslate:.uno:ToolsMenu\.uno:T3"
                xml-lang="en">
         <bookmark_value>Document/Text translation</bookmark_value>
      </bookmark>
      <bookmark id="helpindex_d1e8" branch="index" xml-lang="en">
         <bookmark_value>translate; pagetranslate</bookmark_value>
      </bookmark>

      <paragraph id="hd_d1e14" role="heading" level="1" xml-lang="en">Translating a document</paragraph>
      <paragraph id="par_d1e17" role="paragraph" xml-lang="en">PageTranslate provides two toolbar buttons and a menu <item type="gui">Tools</item>
โ†’ <item type="gui">PageTranslate</item> to get documents machine-translated.</paragraph>

      <paragraph id="par_d1e27" role="paragraph" xml-lang="en">The main button <item type="keystroke">Tโ†’๐Ÿ‡ฌ๐Ÿ‡ง</item> translates text to English. Whereas <item type="keystroke">๐Ÿด</item>
uses the local/Office language as target.</paragraph>

      <paragraph id="par_d1e36" role="paragraph" xml-lang="en">If a text portion is selected, then only that gets replaced. Otherwise, the extension
will traverse the whole Writer/Draw/Impress document, paragraph by paragraph, and substitute
each sentence.</paragraph>
      <!--xsl:skipped=<warning>-->

<paragraph id="par_d1e44" role="paragraph" xml-lang="en">There's some <link href="config#service">options</link> to
change, nameley the used translation service (Google per default), or a few
performance flags.</paragraph>

   </body>
</helpdocument>