Alireza Fattahi Alireza Fattahi - 1 year ago 75
Java Question

Struts 2 (version 2.3.28) only accepts registered locales

In Struts 2 version 2.3.28, the

interceptor only accepts the locales which are registered to jvm, the list which is returned by

Well, although I can extend the list of available Java Locales, as mentioned How to extend the list of available Java Locales, is it any short way that set this interceptor to accept all strings as locale (for example
) ?!

Just a note: Setting the default locale to
<constant name="struts.locale" value="fa_IR" />
) works fine.

Answer Source

No, you have to create your own interceptor that extends i18n and override this method

 protected Locale getLocaleFromParam(Object requestedLocale) {
        Locale locale = null;
        if (requestedLocale != null) {
            locale = (requestedLocale instanceof Locale) ?
                    (Locale) requestedLocale :
                    LocalizedTextUtil.localeFromString(requestedLocale.toString(), null);
            if (locale != null && LOG.isDebugEnabled()) {
                LOG.debug("applied request locale=#0", locale);

        if (locale == null) {
            locale = Locale.getDefault();
        return locale;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download