Hi there,
I am facing a problem concerning the internationalization of my app.
Here is my messages config :
@Configuration
public class MessageConfig {
@Bean
public LocaleResolver localeResolver() {
CookieLocaleResolver localeResolver = new CookieLocaleResolver();
localeResolver.setDefaultLocale(Locale.ENGLISH);
localeResolver.setDefaultTimeZone(TimeZone.getTimeZone("UTC"));
return localeResolver;
}
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor localeChangeInterceptor
= new LocaleChangeInterceptor();
localeChangeInterceptor.setParamName("language");
return localeChangeInterceptor;
}
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(localeChangeInterceptor());
}
@Bean("messageSource")
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource =
new ResourceBundleMessageSource();
messageSource.setBasenames("language/messages");
messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}
}
Here is the prop file :
... other.names=Other names ...
and the xhtml file:
...<tr>
<td><h:outputText value="#{messageSource['other.names']}"
rendered="#{mainController.selectedMember != null}" /></td>....
Note that the message.properties file is under resources/language
In the controller, messageSource.getMessage("other.names",null, locale) is working but not in xhtml.
Can you guess what is wrong ?
Thanks in advance