private String translate(Object messageObject, Locale locale) {
if (null == messageObject) {
return null;
}
String message = messageObject.toString();
ResourceBundle bundleEn = ResourceBundle.getBundle(getResourceBundleName(), Locale.ENGLISH);
ResourceBundle bundle = bundleEn;
if (null != locale) {
try {
bundle = ResourceBundle.getBundle(getResourceBundleName(), locale);
} catch (MissingResourceException mre) {
// ignore, bundle is already set to English
}
}
Object obj;
try {
obj = bundle.getObject(message);
} catch (MissingResourceException mre) {
obj = bundleEn.getObject(message);
}
if (null != obj && obj instanceof String) {
return (String) obj;