Refactor localized message helper method
This commit is contained in:
parent
97a4c0031b
commit
7ff5be3a72
@ -181,12 +181,15 @@ public final class AbilityUtils {
|
|||||||
public static String getLocalizedMessage(String messageCode, Locale locale, Object...arguments) {
|
public static String getLocalizedMessage(String messageCode, Locale locale, Object...arguments) {
|
||||||
ResourceBundle bundle;
|
ResourceBundle bundle;
|
||||||
if(locale == null){
|
if(locale == null){
|
||||||
bundle = ResourceBundle.getBundle("default_messages");
|
bundle = ResourceBundle.getBundle("messages", Locale.ROOT);
|
||||||
}else {
|
}else {
|
||||||
try {
|
try {
|
||||||
bundle = ResourceBundle.getBundle("messages", locale);
|
bundle = ResourceBundle.getBundle(
|
||||||
|
"messages",
|
||||||
|
locale,
|
||||||
|
ResourceBundle.Control.getNoFallbackControl(ResourceBundle.Control.FORMAT_PROPERTIES));
|
||||||
} catch (MissingResourceException e) {
|
} catch (MissingResourceException e) {
|
||||||
bundle = ResourceBundle.getBundle("default_messages");
|
bundle = ResourceBundle.getBundle("messages", Locale.ROOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String message = bundle.getString(messageCode);
|
String message = bundle.getString(messageCode);
|
||||||
|
Loading…
Reference in New Issue
Block a user