possible fix
This commit is contained in:
parent
8e908da1ab
commit
973ab9e56f
|
@ -296,7 +296,10 @@ public class LanguageUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Element c : element.getChildren()) {
|
|
||||||
|
// Create a copy of the children collection before iterating
|
||||||
|
List<Element> childrenCopy = new ArrayList<>(element.getChildren());
|
||||||
|
for (Element c : childrenCopy) {
|
||||||
if (!c.getName().equals("designation")) {
|
if (!c.getName().equals("designation")) {
|
||||||
t = t + importFromTranslations(element, c, translations, usedUnits);
|
t = t + importFromTranslations(element, c, translations, usedUnits);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
package org.hl7.fhir.r5.elementmodel;
|
package org.hl7.fhir.r5.elementmodel;
|
||||||
|
|
||||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||||
|
import org.hl7.fhir.r5.formats.JsonCreatorDirect;
|
||||||
|
import org.hl7.fhir.r5.test.utils.CompareUtilities;
|
||||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||||
import org.hl7.fhir.utilities.i18n.LanguageFileProducer;
|
import org.hl7.fhir.utilities.i18n.LanguageFileProducer;
|
||||||
import org.hl7.fhir.utilities.i18n.PoGetTextProducer;
|
import org.hl7.fhir.utilities.i18n.PoGetTextProducer;
|
||||||
import org.hl7.fhir.utilities.tests.ResourceLoaderTests;
|
import org.hl7.fhir.utilities.tests.ResourceLoaderTests;
|
||||||
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
class LanguageUtilsTest implements ResourceLoaderTests {
|
class LanguageUtilsTest implements ResourceLoaderTests {
|
||||||
|
@ -27,11 +32,24 @@ class LanguageUtilsTest implements ResourceLoaderTests {
|
||||||
List<LanguageFileProducer.TranslationUnit> res = new ArrayList<>();
|
List<LanguageFileProducer.TranslationUnit> res = new ArrayList<>();
|
||||||
res.addAll(lp.loadSource(getResourceAsInputStream("languageUtils", "CodeSystem-answer.po")));
|
res.addAll(lp.loadSource(getResourceAsInputStream("languageUtils", "CodeSystem-answer.po")));
|
||||||
|
|
||||||
|
List<ValidationMessage> lvm = new ArrayList<>();
|
||||||
|
lvm.add(new ValidationMessage());
|
||||||
LanguageUtils languageUtils = new LanguageUtils(context);
|
LanguageUtils languageUtils = new LanguageUtils(context);
|
||||||
int result = languageUtils.importFromTranslations(element, res, null);
|
int result = languageUtils.importFromTranslations(element, res, lvm);
|
||||||
|
|
||||||
|
Writer generatedResource = new StringWriter();
|
||||||
|
jp.compose(element, new JsonCreatorDirect(generatedResource, false, false));
|
||||||
|
|
||||||
assert result == 3;
|
assert result == 3;
|
||||||
|
|
||||||
|
InputStream translatedResource = getResourceAsInputStream("languageUtils", "CodeSystem-answer-translated.json");
|
||||||
|
String text = new BufferedReader(new InputStreamReader(translatedResource))
|
||||||
|
.lines()
|
||||||
|
.collect(Collectors.joining("\n"));
|
||||||
|
|
||||||
|
String msg = CompareUtilities.checkJsonSrcIsSame("", generatedResource.toString(),text, null);
|
||||||
|
Assertions.assertNull(msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"resourceType" : "CodeSystem",
|
||||||
|
"id" : "basic-answer",
|
||||||
|
"language" : "en",
|
||||||
|
"url" : "https://example.com/CodeSystem/basic-answer",
|
||||||
|
"version" : "0.1.0",
|
||||||
|
"name" : "BasicAnswer",
|
||||||
|
"title" : "Administration-Method",
|
||||||
|
"status" : "active",
|
||||||
|
"date" : "2024-04-07",
|
||||||
|
"publisher" : "Sample",
|
||||||
|
"description" : "Basic answers for any kind of questions.",
|
||||||
|
"caseSensitive" : false,
|
||||||
|
"content" : "complete",
|
||||||
|
"count" : 3,
|
||||||
|
"concept" : [ {
|
||||||
|
"code" : "ok",
|
||||||
|
"display" : "OK",
|
||||||
|
"designation" : [ {
|
||||||
|
"language" : "it",
|
||||||
|
"value" : "OK"
|
||||||
|
} ]
|
||||||
|
}, {
|
||||||
|
"code" : "yes",
|
||||||
|
"display" : "Yes",
|
||||||
|
"designation" : [ {
|
||||||
|
"language" : "it",
|
||||||
|
"value" : "Si"
|
||||||
|
} ]
|
||||||
|
}, {
|
||||||
|
"code" : "no",
|
||||||
|
"display" : "No",
|
||||||
|
"designation" : [ {
|
||||||
|
"language" : "it",
|
||||||
|
"value" : "No"
|
||||||
|
} ]
|
||||||
|
} ]
|
||||||
|
}
|
|
@ -10,18 +10,15 @@
|
||||||
"concept": [
|
"concept": [
|
||||||
{
|
{
|
||||||
"code": "ok",
|
"code": "ok",
|
||||||
"display": "OK",
|
"display": "OK"
|
||||||
"definition": "KO"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"code": "yes",
|
"code": "yes",
|
||||||
"display": "Yes",
|
"display": "Yes"
|
||||||
"definition": "seY"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"code": "no",
|
"code": "no",
|
||||||
"display": "No",
|
"display": "No"
|
||||||
"definition": "oN"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"language": "en",
|
"language": "en",
|
||||||
|
|
Loading…
Reference in New Issue