Announcement Announcement Module
Collapse
No announcement yet.
Setting a default country for the locale Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting a default country for the locale

    [Question]
    Can I set a default country for SpringLocalizationContext?

    [Context]
    A few days ago I noticed that the <fmt:formatNumber> JSTL tag doesn't behave as expected in our application. It would always format a decimal number using , instead of . as "fraction delimiter" i.e. 69,00 instead of 69.00. I tried with <fmt:setLocale value="de_CH"/> but strangely this didn't seem to make a difference at all.

    Today I tracked it down to o.s.w.servlet.support.JstlUtils$SpringLocalization Context providing a locale without country when asked through getLocale()*. So, the language is set properly but the country is "". When formatting numbers I assume the language to be much less relevant than the country...

    The MVC config says
    Code:
    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
        <property name="defaultLocale" value="de"/>
    </bean>
    If I change defaultLocale to de_CH everything works fine. However, this means that I could never invoke the LocaleChangeInterceptor, which is currently configured like this
    Code:
    <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
        <property name="paramName" value="lang" />
    </bean>
    passing only language information i.e. I would always have to pass a complete Locale string. Since our application only supports the three Swiss locales (de_CH, fr_CH, it_CH) I was wondering whether I could somehow set a default country?

    Cheers,
    Marcel


    * org.apache.taglibs.standard.tag.common.fmt.BundleS upport.getLocalizationContext(PageContext) asks the page context for an object named javax.servlet.jsp.jstl.fmt.localizationContext. This object is an instance of JstlUtils$SpringLocalizationContext.
Working...
X