Closed dadepo closed 9 years ago
I note that you are using I18nHelper
to change the language. In case of handlebars.java + Spring Framework should be used a special helper MessageSourceHelper
for it.
Replace i18n
to message
in .hbs file
example
<span> {{i18n "lang-value"}} </span>
<span> {{message "lang-value"}} </span>
Yes indeed. That was the omission I made. Thanks for pointing this out!!!
I'm glad I could help :-)
Not sure yet if this is a bug in handlebars-spring-boot-starter, or in jknack.handlebars. But it seems when using handlebars-spring-boot-starter, and the locale is set to something else apart from English, the loading of the other language bundle fails.
Steps to reproduce:
Expected: Since the locale is es, the message bundle for Spanish should be loaded.
Current Behaviour. Exception: 20:40:11.993 [http-nio-8081-exec-1] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.github.jknack.handlebars.HandlebarsException: classpath:website/website.hbs:12:31: java.util.MissingResourceException: Can't find bundle for base name messages, locale en_US classpath:website/website.hbs:12:31] with root cause java.util.MissingResourceException: Can't find bundle for base name messages, locale en_US at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564) ~[na:1.8.0_45] at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387) ~[na:1.8.0_45] at java.util.ResourceBundle.getBundle(ResourceBundle.java:1082) ~[na:1.8.0_45] at com.github.jknack.handlebars.helper.DefI18nSource.(I18nHelper.java:347)
Seems bundle for English is always loaded.
Tried this with spring-boot-starter-freemarker and everything works fine.