简体   繁体   中英

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

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

Note: The issue is it is always reading language keys from messages_en.properties file

sample quotation.html file

<!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.

It's probably not the solution but it will help debugging by showing the value of lanaguage.

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