[英]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. 我想知道是否可以使用application.properties文件而不是用代码配置Spring Boot如何处理国际化。
For example: To define a LocaleChangeInterceptor
I have to declare a bean like this: 例如:要定义
LocaleChangeInterceptor
我必须像这样声明一个bean:
<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: 但是,查看文档中最常用的属性后,仅显示了可以配置为国际化的3个值:
# 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.
它只是一个bean定义,并且是完全可选的,因此我宁愿将其保留在Java中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.