Hello,
I have a webapp with property-files for german and english. The user can choose the language and all is working fine. If the accept-language is english the english messages are used (at the first visit), if it is german, the german ones are used and if the user selects one, his desired are used. But now I would like to have some kind of 'fallback-locale'. If I define a defaultLocale, for example 'en', this is used even if the accept-language is german (that means a user on a german system needs change the language). And when I don't define it, I have no idea which language is used when the accept-language is something we don't support (maybe spanish or so). I tested a little bit and most of the time the webapp was displayed in german but sometimes in english. Is there a possibillity to define such a 'fallback-locale'? Since I havn't found a property for this I tried to implement a workaround but that resulted in really strange behavior...
Sometimes the exception was thrown, but sometimes simply the german property-file was used... Am I missing something?Code:try { ApplicationContext ac = getApplicationContext(); logger.info("test: " + ac.getMessage("label.locale", new Object[] {}, request.getLocale())); } catch (NoSuchMessageException nsm_e) { WebUtils.setSessionAttribute(req, SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, Locale.ENGLISH); }
applicationContext.xml contains:
Would be great if someone can help me...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.SessionLocaleResolver"> <!-- <property name="defaultLocale" value="en" /> --> </bean> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="interceptors"> <list> <ref local="localeChangeInterceptor"/> </list> </property> </bean>
molly


Reply With Quote
