简体   繁体   中英

Configure internationalization from application.properties in spring boot

I was wondering if I can configure how spring boot handles internationalization using the application.properties file instead of writing it in code.

For example: To define a LocaleChangeInterceptor I have to declare a bean like this:

<bean id="localeChangeInterceptor"
      class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    <property name="paramName" value="lang" />
</bean>

However, a look at the most used properties in the documentation shows only 3 values that can be configured for internationalization:

# INTERNATIONALIZATION (MessageSourceAutoConfiguration)
spring.messages.basename=messages
spring.messages.cache-seconds=-1
spring.messages.encoding=UTF-8

So is there a way to achieve this? is there a convention on how to map this to a properties file?

is there a convention on how to map this to a properties file?

No there isn't. It's only a single bean definition and it's entirely optional, so I would prefer to leave that in Java.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM