/** * This code is currently common to all {@link ViewHandlingStrategy} instances. * * @see ViewHandler#calculateLocale(javax.faces.context.FacesContext) */ public Locale calculateLocale(FacesContext context) { Util.notNull("context", context); Locale result = null; // determine the locales that are acceptable to the client based on the // Accept-Language header and the find the best match among the // supported locales specified by the client. Iterator<Locale> locales = context.getExternalContext().getRequestLocales(); while (locales.hasNext()) { Locale perf = locales.next(); result = findMatch(context, perf); if (result != null) { break; } } // no match is found. if (result == null) { if (context.getApplication().getDefaultLocale() == null) { result = Locale.getDefault(); } else { result = context.getApplication().getDefaultLocale(); } } return result; }