code: private Configuration getLanguageConfigurationForLocale(Optional<String> language) {
  
          // if language is null we return the default language.
          if (!language.isPresent()) {
              return langToKeyAndValuesMapping.get("");
          }
  
          // Check if we get a registered mapping for the language input string.
          // At that point the language may be either language-country or only country.
          // extract multiple languages from Accept-Language header
          String[] languages = language.get().split(",");
          for (String l: languages){
              l = l.trim();
              // Ignore the relative quality factor in Accept-Language header
              if (l.contains(";")){
                  l = l.split(";")[0];
              }
              Configuration configuration = langToKeyAndValuesMapping.get(l);
              if (configuration != null) {
                  return configuration;
              }
  
              // If we got a two part language code like "en-US" we split it and
              // search only for the language "en".
              if (l.contains("-")) {
                  String[] array = l.split("-");
                  String languageWithoutCountry = array[0];
                  // Modify country code to upper case for IE and Firefox
                  if(array.length > 1){
                      String country = array[1];
                      String languageWithUpperCaseCountry = languageWithoutCountry + "-" + country.toUpperCase();
                      configuration = langToKeyAndValuesMapping.get(languageWithUpperCaseCountry);
                      if (configuration != null) {
                          return configuration;
                      }
                  }
                  configuration = langToKeyAndValuesMapping
                          .get(languageWithoutCountry);
  
                  if (configuration != null) {
  
                      return configuration;
                  }
  
              }
          }
  
          // Oops. Nothing found. We return the default language (by convention guaranteed to work).
          return langToKeyAndValuesMapping.get("");
  
      }
docs: Retrieves the matching language file from an arbitrary one or two part
  locale String ("en-US", or "en" or "de"...).
  <p>
  
  @param language
  A two or one letter language code such as "en-US" or "en" or
  "en-US,en;q=0.8,de;q=0.6".
  @return The matching configuration from the hashmap. Or the default
  mapping if no one has been found.