/** * Gets a {@link Locale} instance by the value of the component attribute "locale" which can be String or {@link Locale} or null. * <p> * If NULL is passed the view root default locale is used. * * @param locale given locale * @return resolved Locale */ public static Locale resolveLocale(Object locale, String clientId) { Locale result = null; if (locale != null) { if (locale instanceof String) { result = toLocale((String) locale); } else if (locale instanceof java.util.Locale) { result = (java.util.Locale) locale; } else { throw new IllegalArgumentException("Type:" + locale.getClass() + " is not a valid locale type for: " + clientId); } } else { // default to the view local result = FacesContext.getCurrentInstance().getViewRoot().getLocale(); } return result; }
/** * Gets a {@link Locale} instance by the value of the component attribute "locale" which can be String or {@link Locale} or null. * <p> * If NULL is passed the view root default locale is used. * * @param locale given locale * @return resolved Locale */ public static Locale resolveLocale(Object locale, String clientId) { Locale result = null; if (locale != null) { if (locale instanceof String) { result = toLocale((String) locale); } else if (locale instanceof java.util.Locale) { result = (java.util.Locale) locale; } else { throw new IllegalArgumentException("Type:" + locale.getClass() + " is not a valid locale type for: " + clientId); } } else { // default to the view local result = FacesContext.getCurrentInstance().getViewRoot().getLocale(); } return result; }