diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index 8b75abbcc..aed8018b4 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -1311,6 +1311,6 @@ public abstract class BaseWorkerContext implements IWorkerContext { @Override public void setValidationMessageLanguage(Locale locale) { - i18Nmessages = ResourceBundle.getBundle("Messages", locale ); + i18Nmessages = ResourceBundle.getBundle("Messages", locale); } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/IResourceValidator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/IResourceValidator.java index 8f2ec973c..bc99d7a0b 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/IResourceValidator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/IResourceValidator.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.List; +import java.util.Locale; import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRFormatError; @@ -68,7 +69,9 @@ public interface IResourceValidator { Element fetch(Object appContext, String url) throws FHIRFormatError, DefinitionException, FHIRException, IOException; ReferenceValidationPolicy validationPolicy(Object appContext, String path, String url); - boolean resolveURL(Object appContext, String path, String url) throws IOException, FHIRException; + boolean resolveURL(Object appContext, String path, String url) throws IOException, FHIRException; + + void setLocale(Locale locale); } public enum BestPracticeWarningLevel { diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java index 0e8d93ecc..3e5a1d91d 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java @@ -139,6 +139,8 @@ POSSIBILITY OF SUCH DAMAGE. */ public class ValidationEngine implements IValidatorResourceFetcher { + + public class ScanOutputItem { private String ref; private ImplementationGuide ig; @@ -240,6 +242,7 @@ public class ValidationEngine implements IValidatorResourceFetcher { private Set loadedIgs = new HashSet<>(); private IValidatorResourceFetcher fetcher; private boolean assumeValidRestReferences; + private Locale locale; private class AsteriskFilter implements FilenameFilter { String dir; @@ -1269,6 +1272,7 @@ public class ValidationEngine implements IValidatorResourceFetcher { validator.setNoInvariantChecks(isNoInvariantChecks()); validator.setValidationLanguage(language); validator.setAssumeValidRestReferences(assumeValidRestReferences); + validator.getContext().setLocale(locale); validator.setFetcher(this); return validator; } @@ -1592,6 +1596,11 @@ public class ValidationEngine implements IValidatorResourceFetcher { return false; } + @Override + public void setLocale(Locale locale) { + this.locale = locale; + } + public void handleOutput(Resource r, String output, String version) throws Exception { if (output.startsWith("http://") || output.startsWith("http://")) { ByteArrayOutputStream bs = new ByteArrayOutputStream(); diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/Validator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/Validator.java index 408ed8739..e69c96e96 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/Validator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/Validator.java @@ -55,6 +55,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -195,6 +196,8 @@ public class Validator { System.out.println(" Produce additional information about the loading/validation process"); System.out.println("-recurse"); System.out.println(" Look in subfolders when -ig refers to a folder"); + System.out.println("-locale"); + System.out.println(" Specifies the locale/language of the validation result messages (eg.: de-DE"); System.out.println("-sct"); System.out.println(" Specify the edition of SNOMED CT to use. Valid Choices:"); System.out.println(" intl | us | uk | au | nl | ca | se | dk | es"); @@ -399,6 +402,7 @@ public class Validator { boolean anyExtensionsAllowed = true; boolean hintAboutNonMustSupport = false; boolean recursive = false; + Locale locale = null; List profiles = new ArrayList(); EngineMode mode = EngineMode.VALIDATION; String output = null; @@ -477,6 +481,12 @@ public class Validator { throw new Error("Snomed edition '"+s+"' not known"); } else if (args[i].equals("-recurse")) { recursive = true; + } else if (args[i].equals("-locale")) { + if (i+1 == args.length) { + throw new Error("Specified -locale without indicating locale"); + } else { + locale = new Locale(args[++i]); + } } else if (args[i].equals("-strictExtensions")) { anyExtensionsAllowed = false; } else if (args[i].equals("-hintAboutNonMustSupport")) { @@ -585,6 +595,7 @@ public class Validator { validator.setHintAboutNonMustSupport(hintAboutNonMustSupport); validator.setAnyExtensionsAllowed(anyExtensionsAllowed); validator.setLanguage(lang); + validator.setLocale(locale); validator.setSnomedExtension(snomedCT); validator.setAssumeValidRestReferences(assumeValidRestReferences); diff --git a/org.hl7.fhir.validation/src/main/resources/Messages_de_DE.properties b/org.hl7.fhir.validation/src/main/resources/Messages_de.properties similarity index 99% rename from org.hl7.fhir.validation/src/main/resources/Messages_de_DE.properties rename to org.hl7.fhir.validation/src/main/resources/Messages_de.properties index 3ede37a93..bbfbb87fd 100644 --- a/org.hl7.fhir.validation/src/main/resources/Messages_de_DE.properties +++ b/org.hl7.fhir.validation/src/main/resources/Messages_de.properties @@ -10,8 +10,7 @@ Bundle_BUNDLE_Entry_NoProfile=Kein Profil für die contained Ressource vom Typ " Bundle_BUNDLE_Entry_NotFound="{0}" konnte nicht in bundle ({1}) gefunden werden Bundle_BUNDLE_Entry_Orphan=Entry {0} ist nicht durch Traversierung, vom ersten Bundle-Entry ausgehend, erreichbar Bundle_BUNDLE_Entry_Type=Der type "{0}" ist nicht gültig - hier sind keine Ressourcen erlaubt -Bundle_BUNDLE_Entry_Type2=Der type "{0}" ist nicht gültig - muss {1} sein\ - +Bundle_BUNDLE_Entry_Type2=Der type "{0}" ist nicht gültig - muss {1} sein Bundle_BUNDLE_Entry_Type3=Der type "{0}" ist nicht gültig - muss einer von {1} sein Bundle_BUNDLE_FullUrl_Missing=Es besteht eine relative Reference innerhalb des Bundle, dessen Eintrag eine fullUrl fehlt Bundle_BUNDLE_FullUrl_NeedVersion=Einträge, die mit fullURL {0} übereinstimmen, sollten meta/versionId deklarieren, da versionsspezifische Referenzen vorhanden sind. diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java index efc8fce7e..fa37ab52a 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java @@ -427,6 +427,11 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour return !url.contains("example.org"); } + @Override + public void setLocale(Locale locale) { + //do nothing + } + @Override public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { IResourceValidator val = TestingUtilities.context(version).newValidator();