Deepl integration - auto-translate website

Hey… anyone ever thought about auto-translate website and/or panel using deepl-rest-api?
https://www.deepl.com/docs-api/translating-text/example/

Mostly interesting seems to be the point to interact with… where to hook?
not everything is rendered via kt()

I thought about such an integration once, but then I don’t really need it and don’t have time…

what do you think would be a good point to hook in? as far as i understand kirby correctly, the content is rendered on several ways

What do you mean? The way content is stored in the content files?

I think this whole thing is not so easy. Because you have to be careful to not accidentally translate stuff that may not be translated, like Kirbytag names etc.

This plugin could maybe be a starting point: GitHub - OblikStudio/kirby-memsource: Memsource integration for Kirby CMS

I was recently involved in a project using machine translation of a website (in a design role, so don’t know much about the DeepL integration itself; not a Kirby project). From what I observed, this can get very complex really quick.

Since translations often require a bit of cleaning up (even just for markup), it is essential to have some system in place where changing one sentence on a page does not erase all the manual fixes done to the rest of the translated content; so detecting changed sentences, sending only those to the translator (also saves money, AFAIK DeepL charges by characters) and then marking those sections as “not yet manually checked” in the translated version.

Just thinking out aloud:

If all you need is a fully-automated translation of the final result (and cost is not an issue due to small scale and ideally rarely changed content and design), easiest would probably be to translate, cache and send out the final rendered HTML. One approach could be to deal with the “translated” URLs via a route, which then returns pre-generated translated versions from such cache. Not very economical, though, as every change to headers/footers etc. would require a complete re-translation of all pages; this is more an approach for a site that is barely ever updated (e.g. an e-book type publication or the like).

The most elegant version would be to set up the target languages in Kirby and use page create/change hooks to update the language versions of the primary language’s content on the fly (depending on the speed of the API potentially with a backlog/cronjob setup instead of doing it synchronously). So you would actually fill the Kirby content files in the various languages with the auto-translated content, field by field. A significant challenge is that DeepL cannot deal with Markdown/Kirbytext, i.e. the content would have to be transformed to XML/HTML and then reverse with the API’s return.

yes… that’s exactly one part of the problem i was talking about.

@texnixe and @sebastiangreger
using deepL automaticaly, was just an idea that came to my mind… but it seems, that the energy to put into that complex idea, is hugh.

unless anyone is willing to put energy into this, our solution could be to implement an information-page which describes in different languages how to use deepL with our/a website from the enduser/visitor perspective.

@texnixe what was your solution?

I never needed a solution, it was just an idea I had when thinking about things I could do whenever I had too much time on my hand (so that means: never).

i deeply feel with you =)

Would this help to develop something similar as a plugin for Kirby?
Thanks!