Reputation: 6444
Using thymeleaf i generate a page which content some javascript. The js is generated with thymeleaf in order to get some part of the java model into my page.
I know how to get some translation into my html using thymeleaf.
But now i want to get some of the thymeleaf translation into my generated js in order to centralize my translation effort.
Ideally i'd like to have a window.messages
variable which would contains all my translated messages. This var would be initialized in the genrated js script.
Any reference on this?
Upvotes: 2
Views: 2018
Reputation: 498
You can use
var window.messages = /*[[#{MESSAGE_FILE_TEXT}]]*/
or
var window.messages = /*[[${TEXT_FROM_CONTROLER}]]*/
Reference to documentation on script inlining
Upvotes: 5