From c2c10872e1c209eceef99b7052ef99da3beef31d Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 24 Jun 2020 15:06:27 +1000 Subject: [PATCH] Allow to suppress the warning message about unknown messages from translation layer --- .../org/hl7/fhir/utilities/i18n/I18nBase.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nBase.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nBase.java index 5d7a5e162..ee2656c2b 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nBase.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nBase.java @@ -14,6 +14,7 @@ public abstract class I18nBase { private Locale locale; private ResourceBundle i18nMessages; + private boolean warnAboutMissingMessages = false; public Locale getLocale() { if (Objects.nonNull(locale)) { @@ -47,8 +48,10 @@ public abstract class I18nBase { private boolean messageExistsForLocale(String message) { checkResourceBundleIsLoaded(); if (!i18nMessages.containsKey(message)) { - System.out.println("Attempting to localize message " + message + ", but no such equivalent message exists for" + - " the local " + getLocale()); + if (warnAboutMissingMessages ) { + System.out.println("Attempting to localize message " + message + ", but no such equivalent message exists for" + + " the local " + getLocale()); + } } return i18nMessages.containsKey(message); } @@ -78,4 +81,14 @@ public abstract class I18nBase { public void setValidationMessageLanguage(Locale locale) { i18nMessages = ResourceBundle.getBundle("Messages", locale); } + + public boolean isWarnAboutMissingMessages() { + return warnAboutMissingMessages; + } + + public void setWarnAboutMissingMessages(boolean warnAboutMissingMessages) { + this.warnAboutMissingMessages = warnAboutMissingMessages; + } + + } \ No newline at end of file