more work on translations in IGs
This commit is contained in:
parent
43b85c8108
commit
0a03628e97
|
@ -21,6 +21,7 @@ import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingAdditiona
|
||||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent;
|
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent;
|
||||||
import org.hl7.fhir.r5.model.Extension;
|
import org.hl7.fhir.r5.model.Extension;
|
||||||
import org.hl7.fhir.r5.model.MarkdownType;
|
import org.hl7.fhir.r5.model.MarkdownType;
|
||||||
|
import org.hl7.fhir.r5.model.PrimitiveType;
|
||||||
import org.hl7.fhir.r5.model.Property;
|
import org.hl7.fhir.r5.model.Property;
|
||||||
import org.hl7.fhir.r5.model.Resource;
|
import org.hl7.fhir.r5.model.Resource;
|
||||||
import org.hl7.fhir.r5.model.StringType;
|
import org.hl7.fhir.r5.model.StringType;
|
||||||
|
@ -35,6 +36,7 @@ import org.hl7.fhir.utilities.i18n.LanguageFileProducer;
|
||||||
import org.hl7.fhir.utilities.i18n.LanguageFileProducer.LanguageProducerLanguageSession;
|
import org.hl7.fhir.utilities.i18n.LanguageFileProducer.LanguageProducerLanguageSession;
|
||||||
import org.hl7.fhir.utilities.i18n.LanguageFileProducer.TextUnit;
|
import org.hl7.fhir.utilities.i18n.LanguageFileProducer.TextUnit;
|
||||||
import org.hl7.fhir.utilities.i18n.LanguageFileProducer.TranslationUnit;
|
import org.hl7.fhir.utilities.i18n.LanguageFileProducer.TranslationUnit;
|
||||||
|
import org.hl7.fhir.utilities.json.model.JsonElement;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||||
|
@ -665,4 +667,30 @@ public class LanguageUtils {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasTranslation(org.hl7.fhir.r5.model.Element e, String lang) {
|
||||||
|
return getTranslation(e, lang) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTranslation(org.hl7.fhir.r5.model.Element e, String lang) {
|
||||||
|
for (Extension ext : e.getExtensionsByUrl(ToolingExtensions.EXT_TRANSLATION)) {
|
||||||
|
String l = ext.getExtensionString("lang");
|
||||||
|
String v = ext.getExtensionString("content");
|
||||||
|
if (langsMatch(l, lang) && v != null) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTranslationOrBase(PrimitiveType<?> e, String lang) {
|
||||||
|
for (Extension ext : e.getExtensionsByUrl(ToolingExtensions.EXT_TRANSLATION)) {
|
||||||
|
String l = ext.getExtensionString("lang");
|
||||||
|
String v = ext.getExtensionString("content");
|
||||||
|
if (langsMatch(l, lang) && v != null) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return e.primitiveValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,28 @@ import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||||
*/
|
*/
|
||||||
public class RenderingContext extends RenderingI18nContext {
|
public class RenderingContext extends RenderingI18nContext {
|
||||||
|
|
||||||
|
public static class RenderingContextLangs {
|
||||||
|
|
||||||
|
private RenderingContext defLangRC;
|
||||||
|
private Map<String, RenderingContext> langs = new HashMap<>();
|
||||||
|
|
||||||
|
public RenderingContextLangs(RenderingContext defLangRC) {
|
||||||
|
this.defLangRC = defLangRC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void seeLang(String lang, RenderingContext rc) {
|
||||||
|
this.langs.put(lang, rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RenderingContext get(String lang) {
|
||||||
|
if (lang == null || !langs.containsKey(lang)) {
|
||||||
|
return defLangRC;
|
||||||
|
} else {
|
||||||
|
return langs.get(lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// provides liquid templates, if they are available for the content
|
// provides liquid templates, if they are available for the content
|
||||||
public interface ILiquidTemplateProvider {
|
public interface ILiquidTemplateProvider {
|
||||||
String findTemplate(RenderingContext rcontext, DomainResource r);
|
String findTemplate(RenderingContext rcontext, DomainResource r);
|
||||||
|
|
|
@ -919,6 +919,19 @@ public class RenderingI18nContext extends I18nBase {
|
||||||
public static final String DATA_REND_ATT_DATA = "DATA_REND_ATT_DATA";
|
public static final String DATA_REND_ATT_DATA = "DATA_REND_ATT_DATA";
|
||||||
public static final String GENERAL_DATA_DISPLAY_PROPERTY = "GENERAL_DATA_DISPLAY_PROPERTY";
|
public static final String GENERAL_DATA_DISPLAY_PROPERTY = "GENERAL_DATA_DISPLAY_PROPERTY";
|
||||||
public static final String DATA_REND_CURRENCY = "DATA_REND_CURRENCY";
|
public static final String DATA_REND_CURRENCY = "DATA_REND_CURRENCY";
|
||||||
|
public static final String _NA = "_NA";
|
||||||
|
public static final String FMM_TABLE = "FMM_TABLE";
|
||||||
|
public static final String KIND_EXTENSION = "KIND_EXTENSION";
|
||||||
|
public static final String KIND_LOGICAL = "KIND_LOGICAL";
|
||||||
|
public static final String KIND_PROFILE = "KIND_PROFILE";
|
||||||
|
public static final String IP_NONE = "IP_NONE";
|
||||||
|
public static final String IP_NONE_EXT = "IP_NONE_EXT";
|
||||||
|
public static final String IP_INTRO = "IP_INTRO";
|
||||||
|
public static final String MATURITY_PUBLISHER = "MATURITY_PUBLISHER";
|
||||||
|
public static final String MATURITY_STATUS = "MATURITY_STATUS";
|
||||||
|
public static final String MATURITY_MATURITY = "MATURITY_MATURITY";
|
||||||
|
public static final String MATURITY_STDS_STATUS = "MATURITY_STDS_STATUS";
|
||||||
|
|
||||||
|
|
||||||
protected String getMessagesSourceFileName() {
|
protected String getMessagesSourceFileName() {
|
||||||
return "rendering-phrases";
|
return "rendering-phrases";
|
||||||
|
@ -937,4 +950,5 @@ public class RenderingI18nContext extends I18nBase {
|
||||||
public String formatPhrasePlural(Integer plural, String theMessage, Object... theMessageArguments) {
|
public String formatPhrasePlural(Integer plural, String theMessage, Object... theMessageArguments) {
|
||||||
return formatMessagePlural(plural, theMessage, theMessageArguments);
|
return formatMessagePlural(plural, theMessage, theMessageArguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -923,3 +923,15 @@ DATA_REND_ATT_URL = {0} @ {1}
|
||||||
DATA_REND_ATT_DATA = {0}: {1}
|
DATA_REND_ATT_DATA = {0}: {1}
|
||||||
GENERAL_DATA_DISPLAY_PROPERTY = {0}: {1}
|
GENERAL_DATA_DISPLAY_PROPERTY = {0}: {1}
|
||||||
DATA_REND_CURRENCY = {1} {0}
|
DATA_REND_CURRENCY = {1} {0}
|
||||||
|
_NA = n/a
|
||||||
|
FMM_TABLE = <table class="cols"><tbody><tr><td><a href="http://hl7.org/fhir/versions.html#maturity">Maturity Level</a>: {0}</td><td> <a href="{1}versions.html#std-process" title="Standard Status">{2}</a></td></tr></tbody></table>
|
||||||
|
KIND_EXTENSION = extension
|
||||||
|
KIND_LOGICAL = logical model
|
||||||
|
KIND_PROFILE = profile
|
||||||
|
IP_NONE = No use of external IP
|
||||||
|
IP_NONE_EXT = No use of external IP (other than from the FHIR specification)
|
||||||
|
IP_INTRO = This {0} includes IP covered under the following statements.
|
||||||
|
MATURITY_PUBLISHER = Publisher: {0}
|
||||||
|
MATURITY_STATUS = Status
|
||||||
|
MATURITY_MATURITY = Maturity Level: {0}
|
||||||
|
MATURITY_STDS_STATUS = Standards Status: {0}
|
||||||
|
|
Loading…
Reference in New Issue