diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java index 379d229e3..c671d79e5 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java @@ -1513,7 +1513,7 @@ public class Element extends Base implements NamedItem { ext.addElement("valueCode").setValue(lang); ext = t.addElement("extension"); - ext.addElement("url").setValue("value"); + ext.addElement("url").setValue("content"); ext.addElement("valueString").setValue(translation); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/LanguageUtils.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/LanguageUtils.java index ef3997297..6bdee88d7 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/LanguageUtils.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/LanguageUtils.java @@ -385,9 +385,9 @@ public class LanguageUtils { String v = null; for (Element subExt : ext.getChildren()) { if ("Extension".equals(subExt.fhirType()) && "lang".equals(subExt.getNamedChildValue("url"))) { - lang = subExt.getNamedChildValue("value"); + l = subExt.getNamedChildValue("value"); } - if ("Extension".equals(subExt.fhirType()) && "lang".equals(subExt.getNamedChildValue("content"))) { + if ("Extension".equals(subExt.fhirType()) && "content".equals(subExt.getNamedChildValue("url"))) { v = subExt.getNamedChildValue("value"); } } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/ResourceLanguageFileBuilderTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/ResourceLanguageFileBuilderTests.java index e1f1cfa40..2f4b7e0ca 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/ResourceLanguageFileBuilderTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/ResourceLanguageFileBuilderTests.java @@ -24,7 +24,7 @@ public class ResourceLanguageFileBuilderTests { ctxt.cacheResource(new JsonParser().parse(TestingUtilities.loadTestResourceStream("r5", "languages", "StructureDefinition-ed-translatable.json"))); ctxt.cacheResource(new JsonParser().parse(TestingUtilities.loadTestResourceStream("r5", "languages", "StructureDefinition-sd-translatable.json"))); lang.setProfile(ctxt.fetchResource(StructureDefinition.class, "http://hl7.org/tests/fhir/StructureDefinition/sd-translatable")); - lang.prepare(new XLIFFProducer(Utilities.path("[tmp]", "language")), ctxt, "en", "fr"); + lang.prepare(new XLIFFProducer("[tmp]", "language", false), ctxt, "en", "fr"); lang.build(res); } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/JsonLangFileProducer.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/JsonLangFileProducer.java index 0dcac92d0..84a98163c 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/JsonLangFileProducer.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/JsonLangFileProducer.java @@ -13,8 +13,8 @@ import org.hl7.fhir.utilities.json.parser.JsonParser; public class JsonLangFileProducer extends LanguageFileProducer { - public JsonLangFileProducer(String folder) { - super(folder); + public JsonLangFileProducer(String rootFolder, String folderName, boolean useLangFolder) { + super(rootFolder, folderName, useLangFolder); } public JsonLangFileProducer() { @@ -102,7 +102,7 @@ public class JsonLangFileProducer extends LanguageFileProducer { } private String getFileName(String id, String baseLang) throws IOException { - return Utilities.path(getFolder(), id+"-"+baseLang+".json"); + return Utilities.path(getRootFolder(), getFolderName(), id+"-"+baseLang+".json"); } @Override @@ -132,7 +132,7 @@ public class JsonLangFileProducer extends LanguageFileProducer { entry.add("source", tu.getSrcText()); entry.add("target", tu.getTgtText()); } - TextFile.stringToFile(JsonParser.compose(json, true), Utilities.path(getFolder(), filename)); + TextFile.stringToFile(JsonParser.compose(json, true), getTargetFileName(targetLang, filename)); } } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/LanguageFileProducer.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/LanguageFileProducer.java index 3d9ac32ec..4af92f8ae 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/LanguageFileProducer.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/LanguageFileProducer.java @@ -8,6 +8,7 @@ import java.util.Map; import javax.xml.parsers.ParserConfigurationException; +import org.hl7.fhir.utilities.Utilities; import org.xml.sax.SAXException; @@ -143,21 +144,41 @@ public abstract class LanguageFileProducer { public abstract void finish() throws IOException; } - private String folder; + private String rootFolder; + private String folderName; + private boolean useLangFolder; - public LanguageFileProducer(String folder) { + public LanguageFileProducer(String rootFolder, String folderName, boolean useLangFolder) { super(); - this.folder = folder; + this.rootFolder = rootFolder; + this.folderName = folderName; + this.useLangFolder = useLangFolder; } public LanguageFileProducer() { super(); } - public String getFolder() { - return folder; + + public String getRootFolder() { + return rootFolder; } + public String getFolderName() { + return folderName; + } + + public boolean isUseLangFolder() { + return useLangFolder; + } + + + protected String getTargetFileName(String targetLang, String filename) throws IOException { + return Utilities.path(getRootFolder(), isUseLangFolder() ? targetLang : ".", getFolderName(), filename); + } + + + public abstract LanguageProducerSession startSession(String id, String baseLang) throws IOException; public abstract void finish(); diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/PoGetTextProducer.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/PoGetTextProducer.java index ac03ae5fe..266417d9e 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/PoGetTextProducer.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/PoGetTextProducer.java @@ -15,8 +15,8 @@ public class PoGetTextProducer extends LanguageFileProducer { private int filecount; private boolean incLangInFilename; - public PoGetTextProducer(String folder) { - super(folder); + public PoGetTextProducer(String rootFolder, String folderName, boolean useLangFolder) { + super(rootFolder, folderName, useLangFolder); } public PoGetTextProducer() { @@ -142,7 +142,7 @@ public class PoGetTextProducer extends LanguageFileProducer { } private String getFileName(String id, String baseLang, String targetLang) throws IOException { - return Utilities.path(getFolder(), id+(incLangInFilename ? "-"+baseLang+"-"+targetLang+".po" : "")); + return Utilities.path(getRootFolder(), getFolderName(), id+(incLangInFilename ? "-"+baseLang+"-"+targetLang+".po" : "")); } public boolean isIncLangInFilename() { @@ -171,7 +171,7 @@ public class PoGetTextProducer extends LanguageFileProducer { ln(po, "msgstr \""+(tu.getTgtText() == null ? "" : stripEoln(tu.getTgtText()))+"\""); ln(po, ""); } - TextFile.stringToFile(po.toString(), Utilities.path(getFolder(), filename)); + TextFile.stringToFile(po.toString(), getTargetFileName(targetLang, filename)); } private String stripEoln(String s) { diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/XLIFFProducer.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/XLIFFProducer.java index 63de24767..6847a85b6 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/XLIFFProducer.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/XLIFFProducer.java @@ -39,7 +39,7 @@ public class XLIFFProducer extends LanguageFileProducer { ln(" "); ln(" "); ln(""); - TextFile.stringToFile(xml.toString(), Utilities.path(getFolder(), id+".xliff")); + TextFile.stringToFile(xml.toString(), Utilities.path(getRootFolder(), getFolderName(), id+".xliff")); filecount++; } @@ -80,8 +80,8 @@ public class XLIFFProducer extends LanguageFileProducer { private int filecount; - public XLIFFProducer(String folder) { - super(folder); + public XLIFFProducer(String rootFolder, String folderName, boolean useLangFolder) { + super(rootFolder, folderName, useLangFolder); } public XLIFFProducer() { @@ -163,7 +163,7 @@ public class XLIFFProducer extends LanguageFileProducer { ln(xml, " "); ln(xml, " "); ln(xml, ""); - TextFile.stringToFile(xml.toString(), Utilities.path(getFolder(), filename)); + TextFile.stringToFile(xml.toString(), getTargetFileName(targetLang, filename)); } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java index 85601b0b5..524c04bf5 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ValidationService.java @@ -619,9 +619,9 @@ public class ValidationService { private void transformLangExtract(CliContext cliContext, ValidationEngine validator) throws IOException { String dst = cliContext.getOutput(); Utilities.createDirectory(dst); - PoGetTextProducer po = new PoGetTextProducer(Utilities.path(dst)); - XLIFFProducer xliff = new XLIFFProducer(Utilities.path(dst)); - JsonLangFileProducer jl = new JsonLangFileProducer(Utilities.path(dst)); + PoGetTextProducer po = new PoGetTextProducer(dst, ".", false); + XLIFFProducer xliff = new XLIFFProducer(dst, ".", false); + JsonLangFileProducer jl = new JsonLangFileProducer(dst, ".", false); List refs = new ArrayList<>(); ValidatorUtils.parseSources(cliContext.getSources(), refs, validator.getContext());