Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Framework Localization always reads from en (English) file
    primarykey
    data
    text
    <p>I have followed the tutorial below to set up localization for my web app. </p> <p><a href="http://viralpatel.net/blogs/spring-3-mvc-internationalization-i18n-localization-tutorial-example/" rel="nofollow">http://viralpatel.net/blogs/spring-3-mvc-internationalization-i18n-localization-tutorial-example/</a></p> <p>I have three properties files: messages_en_properties, messages_es.properties, and messages_zh_CN.properties</p> <p>Each file has the following line:</p> <p>loging.name=(Username translated to the corresponding language)</p> <p>In my .jsp file I set my table data to display the username using the following line:</p> <pre><code>&lt;td&gt;&lt;spring:message code = "login.name" text = "Default Text"/&gt;&lt;/td&gt; </code></pre> <p>This works, but it only will ever read from my English properties file. I have tried setting the locale manually in the .jsp file to zh_CN and es but I still receive the English file values. I have even tried setting the locale to a country for a file I do not have and it still displays the text from the English file, and not the default text. I am positive the locale is actually being changed since the browser will ask if I would like the page translated.</p> <p>Here is the part of my code that sets up the localeChangeInterceptor.</p> <pre><code>&lt;beans:bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt; &lt;beans:property name="paramName" value="lang" /&gt; &lt;/beans:bean&gt; &lt;beans:bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"&gt; &lt;beans:property name="interceptors"&gt; &lt;beans:ref bean="localeChangeInterceptor" /&gt; &lt;/beans:property&gt; &lt;/beans:bean&gt; </code></pre> <p>Also tried changing to the following...</p> <pre><code>&lt;mvc:interceptors&gt; &lt;beans:bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt; </code></pre> <p> </p> <pre><code>&lt;beans:bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"&gt; &lt;beans:property name="defaultLocale" value="en" /&gt; &lt;/beans:bean&gt; &lt;beans:bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"&gt; &lt;/beans:bean&gt; </code></pre> <p>Any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload