[英]Why internalization is not working with JHIpster Microservices application
I developed one spring boot microservice application using jhipster tool and we have one quotation.html form it contains name and details of the product I am trying to apply langauage translations to the name and details labels based user language
我使用 jhipster 工具开发了一个 spring 启动微服务应用程序,我们有一个报价。html 形式包含产品的名称和详细信息我正在尝试将语言翻译应用于基于用户语言的名称和详细信息标签
for that i made changes in these classes为此,我对这些课程进行了更改
@Configuration
public class LocaleConfiguration implements WebMvcConfigurer {
@Bean
public LocaleResolver localeResolver() {
SessionLocaleResolver slr = new SessionLocaleResolver();
slr.setDefaultLocale(Locale.US);
return slr;
}
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
lci.setParamName("lang");
return lci;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(localeChangeInterceptor());
}
}
added language messages files at this location在此位置添加语言消息文件
i am sending user language key as request param like this
我像这样发送用户语言密钥作为请求参数
localhost:8080/api/pord/quotation?lang=de
based on this lang value it shoud read keys from respective messages file localhost:8080/api/pord/quotation?lang=de
基于这个 lang 值,它应该从各自的消息文件中读取密钥
Note: The issue is it is always reading language keys from messages_en.properties file
注意:问题是它总是从 messages_en.properties 文件中读取语言键
sample quotation.html file
样品报价.html 文件
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<body>
<div class="page-content container-fluid">
<div class="title">
<h3>
<center>
<th:block>
<span th:text="#{invoice.quotation}"></span >
</th:block>
</center>
</h3
</div>
</body>
</html>
Have a look at src/main/resources/templates/error.html
template it includes th:lang="${#locale.language}"
while your template does not.查看
src/main/resources/templates/error.html
模板,它包含th:lang="${#locale.language}"
而您的模板不包含。
It's probably not the solution but it will help debugging by showing the value of lanaguage.它可能不是解决方案,但它会通过显示语言的价值来帮助调试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.