Refactor localized message helper method

This commit is contained in:
davioooh 2018-04-30 19:50:44 +02:00
parent 16fa704a17
commit f64d556610
2 changed files with 6 additions and 3 deletions

View File

@ -159,12 +159,15 @@ public final class AbilityUtils {
public static String getLocalizedMessage(String messageCode, Locale locale, Object...arguments) {
ResourceBundle bundle;
if(locale == null){
bundle = ResourceBundle.getBundle("default_messages");
bundle = ResourceBundle.getBundle("messages", Locale.ROOT);
}else {
try {
bundle = ResourceBundle.getBundle("messages", locale);
bundle = ResourceBundle.getBundle(
"messages",
locale,
ResourceBundle.Control.getNoFallbackControl(ResourceBundle.Control.FORMAT_PROPERTIES));
} catch (MissingResourceException e) {
bundle = ResourceBundle.getBundle("default_messages");
bundle = ResourceBundle.getBundle("messages", Locale.ROOT);
}
}
String message = bundle.getString(messageCode);