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

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


Check-in [7b8ef174e0]

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

Overview
Comment:Fix GogoleAjax to rejoin split up ssentences (from nested list).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7b8ef174e02bc6f6c0fc10d0f55a2e3adda7775f
User & Date: mario 2021-06-02 16:44:24
Context
2021-06-02
16:44
New error note check-in: 6cf288401b user: mario tags: trunk
16:44
Fix GogoleAjax to rejoin split up ssentences (from nested list). check-in: 7b8ef174e0 user: mario tags: trunk
2021-05-31
23:22
document config: options where used check-in: 83b827c27b user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to pythonpath/httprequests.py.

58
59
60
61
62
63
64
65
66
67
68
69
            return self
    
    http = fake_requests()
    log.info("using fake_requests() for now")

# headers
http.headers.update({
    "User-Agent": "Mozilla/5.0 (X11; Linux; LibreOffice/7.0), TradutorLibreText/1.3+PageTranslate/1.8",
    "Accept-Language": "*; q=1.0",
    "Accept-Encoding": "utf-8"
})








|




58
59
60
61
62
63
64
65
66
67
68
69
            return self
    
    http = fake_requests()
    log.info("using fake_requests() for now")

# headers
http.headers.update({
    "User-Agent": "Mozilla/5.0 (X11; Linux; LibreOffice/7.2), PageTranslate/1.9",
    "Accept-Language": "*; q=1.0",
    "Accept-Encoding": "utf-8"
})

Changes to pythonpath/translationbackends.py.

133
134
135
136
137
138
139


140
141
142
143
144
145
146
147
                "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,







>
>
|







133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
                "sl": self.params["from"],
                "tl": self.params["lang"],
                "dt": "t",
                "q": text
            }
        )
        if r.status_code == 200:
            r = r.json()   # request result should be JSON, else client was probably blocked
            #log.debug("'" + text + "' ==> " + repr(r))
            text = "".join([s[0] for s in r[0]])  # result is usually wrapped in three lists [[[u"translated text", u"original", None, None, 3, None, None, [[]] โ†’ one per sentence
        else:
            log.debug("AJAX ERROR: " + repr(r))
        return text


# DeepL online translator
#  ยท will easily yield HTTP 429 Too many requests,