i'm using thymeleaf in classic maven project (no spring) , can't find in documentation simple way acces externalized internationalisation string from java code like, e.g rails' t() function.
i found the following tutorial seems overengineered i'm trying do.
the thymeleaf documentations (http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#a-multi-language-welcome) says default configuration use properties files.
this standard message resolver expects find messages /web-inf/templates/home.html in .properties files in same folder , same name template, like:
- /web-inf/templates/home_en.properties english texts.
- /web-inf/templates/home_es.properties spanish language texts.
- /web-inf/templates/home_pt_br.properties portuguese (brazil) language texts.
- /web-inf/templates/home.properties default texts (if locale not matched).
the properties file home_es.properties has entry like
home.welcome=¡bienvenido nuestra tienda de comestibles! and use like:
<p th:text="#{home.welcome}">welcome our grocery store!</p>
Comments
Post a Comment