Text translations within JavaScript libraries

Hello all,
as a Kirby newbie, unfortunately I can’t find a solution to create multilingual texts that are integrated in a JavaScript. An example are form queries that are processed with AJAX. The corresponding texts are directly integrated in a JavaScript library, e.g. “Your input is incorrect, please correct your input”.
Is there already a manual for this?
Thanks a lot!

What do you mean with JavaScript library? Does this mean you don’t have control over these text snippets because third party?

Yes, I mean third-party .js libraries, e.g. a lightbox gallery. There labels are integrated directly in the JS code (“next image”, “close”, “zoom in” etc.). Can such texts be implemented multilingually with Kirby, or does this have to be solved otherwise? Many thanks for the support.

Your third party JavaScript libraries have nothing to do with Kirby. As a PHP application, the Kirby code runs on the server, while your JS scripts run on the frontend in the browser.

Thank you very much for the quick reply. I have suspected that I have to choose a different solution approach for this.

Don’t know what libraries you are using, e.g. for form validation (and if you even need them), but usually there should be a way to disable such error messages (and then to show your own depending on success or failure) or to configure such strings.

You can always generate a JavaScript code block that assigns the translations to a variable, add it to the bottom of the page, and then use them in your JavaScript…

1 Like