In Spring Boot 2.6.0 java 8 application configuration class has content:
@Configuration
public class Internationalization implements WebMvcConfigurer {
// localeResolver, localeChangeInterceptor, addInterceptors
@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource messageSource
= new ResourceBundleMessageSource();
messageSource.setBasename("lang/messages");
messageSource.setDefaultEncoding("ISO-8859-2");
return messageSource;
}
}
messages_pl.properties content
lang.change=Zmiana języka
switch.en=Przełącz na angielski
switch.pl=Przełącz na polski
pick.date=Wybierz rok i miesiąc
main.header=Nagłówek głównej strony
on the web page with ?lang=pl parameter and <meta charset="ISO-8859-2"> is presented with thymeleaf :
Nag?ówek g?ównej strony
Wybierz rok i miesi?c
Zmiana j?zyka: Prze??cz na angielski Prze??cz na polski
change to UTF-8 change doesn't help
Nag?�wek g?�wnej strony
Wybierz rok i miesi?c
Zmiana j?zyka: Prze??cz na angielski Prze??cz na polski
1 Answer 1
spring.messages.basename=lang/messages
spring.messages.encoding=UTF-8
spring.mvc.locale-resolver=accept-header
try adding these, let spring boot handle the configuration automatically
also, i suggest to prevent using iso encoding since most browser doesnt support or kind of overrides this. Going with UTF-8 is much better as it does what ISO does (correct me if im wrong)
4 Comments
web.locale-resolver: accept_header ?Explore related questions
See similar questions with these tags.
font-family: Tahoma, Verdana, sans-serif;