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!

I made a wordpress plug-in for DeepL. It adds a simple JavaScript button to every input field and if you click it it will load the Textfield content to DeepL, gets translation and then it fills the input with that translation. Super easy in my opinion. And at the end you have complete control on all your fields… maybe wen can port this tool to Kirby too … it’s just a JS that appends to input fields …

1 Like

Okay, six days later … i coded a plugin and released it today in a pre-version 0.1.

Please feel free to test it

3 Likes

Just tried it today. Works like a charm!

Is there a way to also make a page’s title translatable?

Congrats on the great plugin, and thank you!

1 Like

Thanks @fabianhemmert – I got some pull request in the last months and will try to come back working on it a bit more. In the meantime i was working on a chrome browser plugin for right-click to translate any textarea/input field with deepl in chrome. it works also in kirby and is not bound to any special blueprints or plugins etc. give it a try and send me feedback if you want!

Works great!

One thing I noticed right away that it wouldn’t let me go CMD-Z to undo the translation (at least not after clicking outside the text box) - but amazing how well it worked!

Assignable shortcuts would be fantastic, as it can easily turn into a lot of clicking :wink: