code: @Override
      public Locale calculateLocale(FacesContext facesContext)
      {
          Application application = facesContext.getApplication();
          for (Iterator<Locale> requestLocales = facesContext.getExternalContext().getRequestLocales(); requestLocales
                  .hasNext();)
          {
              Locale requestLocale = requestLocales.next();
              for (Iterator<Locale> supportedLocales = application.getSupportedLocales(); supportedLocales.hasNext();)
              {
                  Locale supportedLocale = supportedLocales.next();
                  // higher priority to a language match over an exact match
                  // that occurs further down (see JSTL Reference 1.0 8.3.1)
                  if (requestLocale.getLanguage().equals(supportedLocale.getLanguage())
                          && (supportedLocale.getCountry() == null || supportedLocale.getCountry().length() == 0))
                  {
                      return supportedLocale;
                  }
                  else if (supportedLocale.equals(requestLocale))
                  {
                      return supportedLocale;
                  }
              }
          }
  
          Locale defaultLocale = application.getDefaultLocale();
          return defaultLocale != null ? defaultLocale : Locale.getDefault();
      }
docs: Get the locales specified as acceptable by the original request, compare them to the
  locales supported by this Application and return the best match.