String language = languagePreferences.getProperty(friend, defaultLanguage);
return greet(language, friend);
}
public String greet(String language, String friend) {
MessageFormat greeting = greetings.get(language);
if (greeting == null) {
Locale locale = new Locale(language);
return "Sorry, I don't speak " + locale.getDisplayLanguage() + ".";
}
return greeting.format(new Object[]{friend});
}