繁体   English   中英

为什么内部化不适用于 JHIpster 微服务应用程序

[英]Why internalization is not working with JHIpster Microservices application

我使用 jhipster 工具开发了一个 spring 启动微服务应用程序,我们有一个报价。html 形式包含产品的名称和详细信息我正在尝试将语言翻译应用于基于用户语言的名称和详细信息标签

为此,我对这些课程进行了更改

 @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());
        }
        
    }

在此位置添加语言消息文件

在此处输入图像描述

我像这样发送用户语言密钥作为请求参数

localhost:8080/api/pord/quotation?lang=de基于这个 lang 值,它应该从各自的消息文件中读取密钥

注意:问题是它总是从 messages_en.properties 文件中读取语言键

样品报价.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>

查看src/main/resources/templates/error.html模板,它包含th:lang="${#locale.language}"而您的模板不包含。

它可能不是解决方案,但它会通过显示语言的价值来帮助调试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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