Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In Struts 2 version 2.3.28, the i18n interceptor only accepts the locales which are registered to jvm, the list which is returned by Locale.getAvailableLocales().

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 fa_IR ) ?!

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
402 views
Welcome To Ask or Share your Answers For Others

1 Answer

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;
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...