Revision history [back]

click to hide/show revision 1
initial version

answered 2014-01-13 07:08:05 +0800

chillworld gravatar image chillworld flag of Belgium

https://github.com/chillw...

we do this in our project (but can't really remember now where we have messagebox for testing)

@Command("setLocale")
public void setLocale(@BindingParam("locale") String locale) {
    Locales.setThreadLocal(Locales.getLocale(locale));
    Executions.getCurrent().getSession().setAttribute(Attributes.PREFERRED_LOCALE,
            Locales.getLocale(locale));
    Executions.sendRedirect(null);
}

(only difference is the setThreadLocal)

Greetz chill. Hope this can be use for you.

we do The only thing I see in mine project that could make a difference is this in our project (but can't really remember now where we have messagebox for testing)the xml :

@Command("setLocale")
public void setLocale(@BindingParam("locale") String locale) {
<bean id="localeChangeInterceptor"
 Locales.setThreadLocal(Locales.getLocale(locale));
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
 Executions.getCurrent().getSession().setAttribute(Attributes.PREFERRED_LOCALE,
<property name="paramName" value="lang" />
</bean>

<bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="en" />
</bean>

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
    <property name="interceptors">
 <ref bean="localeChangeInterceptor" />
 Locales.getLocale(locale));
    Executions.sendRedirect(null);
}
</property>
</bean>

(only difference is the setThreadLocal)

Greetz chill. Hope this can be use for you.

The only thing I see in mine project that could make a difference is this in the xml :

<bean id="localeChangeInterceptor"
    class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    <property name="paramName" value="lang" />
</bean>

<bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="en" />
</bean>

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
    <property name="interceptors">
        <ref bean="localeChangeInterceptor" />
    </property>
</bean>

edit :

After a while searching I found also this :

Labels.reset();

in : http://www.zkoss.org/javadoc/6.5.2/zk/org/zkoss/util/resource/Labels.html#reset())

Greetz chill.

The only thing I see in mine project that could make a difference is this in the xml :

<bean id="localeChangeInterceptor"
:
 Edit Subodh: This below line of config may be used when you are using Spring with ZK If only ZK Do not need to write below line of code.
 <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
     <property name="paramName" value="lang" />
</bean>
value="lang"/>
    </bean>

<bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="en" />
</bean>

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
    <property name="interceptors">
        <ref bean="localeChangeInterceptor" />
    </property>
</bean>

edit :

After a while searching I found also this :

Labels.reset();

in : http://www.zkoss.org/javadoc/6.5.2/zk/org/zkoss/util/resource/Labels.html#reset())

Greetz chill.

The only thing I see in mine project that could make a difference is this in the xml : Edit Subodh: This below line of config may be used when you are using Spring with ZK If only ZK Do not need to write below line of code. code.

<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> <property name="paramName" value="lang"/> </bean>

<bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="en" />
</bean>

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
    <property name="interceptors">
        <ref bean="localeChangeInterceptor" />
    </property>
</bean>

edit :

After a while searching I found also this :

Labels.reset();

in : http://www.zkoss.org/javadoc/6.5.2/zk/org/zkoss/util/resource/Labels.html#reset())

Greetz chill.

The only thing I see in mine project that could make a difference is this in the xml : :

Edit Subodh: This below line of config may be used when you are using Spring with ZK If only ZK Do not need to write below line of code.

code. <bean id="localeChangeInterceptor" id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> <property name="paramName" value="lang"/> </bean>

value="lang" />
    </bean>

    <bean id="localeResolver"
     class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
     <property name="defaultLocale" value="en" />
 </bean>

 <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
     <property name="interceptors">
         <ref bean="localeChangeInterceptor" />
     </property>
 </bean>

edit :

After a while searching I found also this :

Labels.reset();

in : http://www.zkoss.org/javadoc/6.5.2/zk/org/zkoss/util/resource/Labels.html#reset())

Greetz chill.

The only thing I see in mine project that could make a difference is this in the xml :

Edit Subodh: This below line of config may be used when you are using Spring with ZK If only ZK Do not need to write below line of code.

<bean id="localeChangeInterceptor"
        class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
        <property name="paramName" value="lang" />
    </bean>

    <bean id="localeResolver"
        class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
        <property name="defaultLocale" value="en" />
    </bean>

    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
        <property name="interceptors">
            <ref bean="localeChangeInterceptor" />
        </property>
    </bean>

edit :

After a while searching I found also this :

Labels.reset();

in : http://www.zkoss.org/javadoc/6.5.2/zk/org/zkoss/util/resource/Labels.html#reset())

Greetz chill.

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More