diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/elementmodel/LanguageUtilsTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/elementmodel/LanguageUtilsTest.java new file mode 100644 index 000000000..58de58105 --- /dev/null +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/elementmodel/LanguageUtilsTest.java @@ -0,0 +1,37 @@ +package org.hl7.fhir.r5.elementmodel; + +import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.test.utils.TestingUtilities; +import org.hl7.fhir.utilities.i18n.LanguageFileProducer; +import org.hl7.fhir.utilities.i18n.PoGetTextProducer; +import org.hl7.fhir.utilities.tests.ResourceLoaderTests; +import org.junit.jupiter.api.Test; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + + +class LanguageUtilsTest implements ResourceLoaderTests { + + @Test + void importFromTranslations() throws Exception { + + IWorkerContext context = TestingUtilities.getSharedWorkerContext(); + + org.hl7.fhir.r5.elementmodel.JsonParser jp = new org.hl7.fhir.r5.elementmodel.JsonParser(context); + InputStream resource = getResourceAsInputStream("languageUtils", "CodeSystem-answer.json"); + Element element = jp.parseSingle(resource, null); + + PoGetTextProducer lp = new PoGetTextProducer(); + List res = new ArrayList<>(); + res.addAll(lp.loadSource(getResourceAsInputStream("languageUtils", "CodeSystem-answer.po"))); + + LanguageUtils languageUtils = new LanguageUtils(context); + int result = languageUtils.importFromTranslations(element, res, null); + + assert result == 3; + + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/test/resources/languageUtils/CodeSystem-answer.json b/org.hl7.fhir.r5/src/test/resources/languageUtils/CodeSystem-answer.json new file mode 100644 index 000000000..550bd355c --- /dev/null +++ b/org.hl7.fhir.r5/src/test/resources/languageUtils/CodeSystem-answer.json @@ -0,0 +1,33 @@ +{ + "resourceType": "CodeSystem", + "status": "active", + "content": "complete", + "name": "BasicAnswer", + "id": "basic-answer", + "title": "Administration-Method", + "description": "Basic answers for any kind of questions.", + "url": "https://example.com/CodeSystem/basic-answer", + "concept": [ + { + "code": "ok", + "display": "OK", + "definition": "KO" + }, + { + "code": "yes", + "display": "Yes", + "definition": "seY" + }, + { + "code": "no", + "display": "No", + "definition": "oN" + } + ], + "language": "en", + "version": "0.1.0", + "date": "2024-04-07", + "publisher": "Sample", + "caseSensitive": false, + "count": 3 +} diff --git a/org.hl7.fhir.r5/src/test/resources/languageUtils/CodeSystem-answer.po b/org.hl7.fhir.r5/src/test/resources/languageUtils/CodeSystem-answer.po new file mode 100644 index 000000000..becb6026b --- /dev/null +++ b/org.hl7.fhir.r5/src/test/resources/languageUtils/CodeSystem-answer.po @@ -0,0 +1,37 @@ +# en -> it + +#: CanonicalResource.name +#. A natural language name identifying the code system. This name should be usable as an identifier for the module by machine processing applications such as code generation. +msgid "BasicAnswer" +msgstr "" + +#: CanonicalResource.title +#. A short, descriptive, user-friendly title for the code system. +msgid "Administration-Method" +msgstr "" + +#: CanonicalResource.publisher +#. The name of the organization or individual that published the code system. +msgid "Example Publisher" +msgstr "" + +#: CanonicalResource.description +#. A free text natural language description of the code system from a consumer's perspective. +msgid "Basic answers for any kind of questions." +msgstr "" + +#: CodeSystem.concept.display +#. A human readable string that is the recommended default way to present this concept to a user. +msgid "OK" +msgstr "OK" + +#: CodeSystem.concept.display +#. A human readable string that is the recommended default way to present this concept to a user. +msgid "Yes" +msgstr "Si" + +#: CodeSystem.concept.display +#. A human readable string that is the recommended default way to present this concept to a user. +msgid "No" +msgstr "No" +