Struts 2 (version 2.3.28) accepts only registered locales

In Struts 2 version 2.3.28, the interceptor i18nonly accepts locales registered in jvm, a list that is returned Locale.getAvailableLocales().

Well, although I can expand the list of available Java Locales, as mentioned. How to expand the list of available Java language locales , is this any shortcut that sets this interceptor to accept all strings as the locale (e.g. fa_IR) ?!

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

+2
source share
1 answer

No, you need to create your own interceptor that extends i18nand overrides 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;
    }
+1
source

Source: https://habr.com/ru/post/1656565/


All Articles