diff --git a/li.strolch.utils/src/main/java/li/strolch/utils/I18nMessage.java b/li.strolch.utils/src/main/java/li/strolch/utils/I18nMessage.java index 7e574273f..c5f7b531c 100644 --- a/li.strolch.utils/src/main/java/li/strolch/utils/I18nMessage.java +++ b/li.strolch.utils/src/main/java/li/strolch/utils/I18nMessage.java @@ -49,6 +49,10 @@ public class I18nMessage { return this.values.get(key); } + public String getMessage(ResourceBundle bundle) { + return formatMessage(bundle); + } + public String getMessage() { return formatMessage(); } @@ -68,17 +72,22 @@ public class I18nMessage { return this.message; } - try { - String string = this.bundle.getString(this.key); - this.message = StringHelper.replacePropertiesIn(this.values, EMPTY, string); - } catch (MissingResourceException e) { - logger.error("Key " + this.key + " is missing in bundle " + this.bundle.getBaseBundleName()); - this.message = this.key; - } - + this.message = formatMessage(this.bundle); return this.message; } + public String formatMessage(ResourceBundle bundle) { + try { + String string = bundle.getString(this.key); + return StringHelper.replacePropertiesIn(this.values, EMPTY, string); + } catch (MissingResourceException e) { + String baseName = bundle.getBaseBundleName(); + String languageTag = bundle.getLocale().toLanguageTag(); + logger.error("Key " + this.key + " is missing in bundle " + baseName + " for locale " + languageTag); + return this.key; + } + } + public T accept(I18nMessageVisitor visitor) { return visitor.visit(this); }