mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-07 21:38:15 +00:00
Use BCP 47 language tag instead of Java Locale toString
This commit is contained in:
parent
70b7e58ef8
commit
ff153b5621
@ -186,8 +186,8 @@ public class ResourceWrapperR4 extends ResourceWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void markLanguage(XhtmlNode x, Locale locale) {
|
public void markLanguage(XhtmlNode x, Locale locale) {
|
||||||
x.setAttribute("lang", locale.toString());
|
x.setAttribute("lang", locale.toLanguageTag());
|
||||||
x.setAttribute("xml:lang", locale.toString());
|
x.setAttribute("xml:lang", locale.toLanguageTag());
|
||||||
x.addTag(0, "hr");
|
x.addTag(0, "hr");
|
||||||
x.addTag(0, "p").b().tx(locale.getDisplayName());
|
x.addTag(0, "p").b().tx(locale.getDisplayName());
|
||||||
x.addTag(0, "hr");
|
x.addTag(0, "hr");
|
||||||
|
@ -186,8 +186,8 @@ public class ResourceWrapperR4B extends ResourceWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void markLanguage(XhtmlNode x, Locale locale) {
|
public void markLanguage(XhtmlNode x, Locale locale) {
|
||||||
x.setAttribute("lang", locale.toString());
|
x.setAttribute("lang", locale.toLanguageTag());
|
||||||
x.setAttribute("xml:lang", locale.toString());
|
x.setAttribute("xml:lang", locale.toLanguageTag());
|
||||||
x.addTag(0, "hr");
|
x.addTag(0, "hr");
|
||||||
x.addTag(0, "p").b().tx(locale.getDisplayName());
|
x.addTag(0, "p").b().tx(locale.getDisplayName());
|
||||||
x.addTag(0, "hr");
|
x.addTag(0, "hr");
|
||||||
|
@ -312,7 +312,7 @@ public class DataRenderer extends Renderer implements CodeResolver {
|
|||||||
if (JurisdictionUtilities.isJurisdiction(system)) {
|
if (JurisdictionUtilities.isJurisdiction(system)) {
|
||||||
return JurisdictionUtilities.displayJurisdiction(system+"#"+code);
|
return JurisdictionUtilities.displayJurisdiction(system+"#"+code);
|
||||||
}
|
}
|
||||||
ValidationResult t = getContext().getWorker().validateCode(getContext().getTerminologyServiceOptions().withLanguage(context.getLocale().toString().replace("_", "-")).withVersionFlexible(true), system, version, code, null);
|
ValidationResult t = getContext().getWorker().validateCode(getContext().getTerminologyServiceOptions().withLanguage(context.getLocale().toLanguageTag()).withVersionFlexible(true), system, version, code, null);
|
||||||
|
|
||||||
if (t != null && t.getDisplay() != null)
|
if (t != null && t.getDisplay() != null)
|
||||||
return t.getDisplay();
|
return t.getDisplay();
|
||||||
|
@ -189,8 +189,8 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void markLanguage(XhtmlNode x) {
|
public void markLanguage(XhtmlNode x) {
|
||||||
x.setAttribute("lang", context.getLocale().toString());
|
x.setAttribute("lang", context.getLocale().toLanguageTag());
|
||||||
x.setAttribute("xml:lang", context.getLocale().toString());
|
x.setAttribute("xml:lang", context.getLocale().toLanguageTag());
|
||||||
x.addTag(0, "hr");
|
x.addTag(0, "hr");
|
||||||
x.addTag(0, "p").b().tx(context.getLocale().getDisplayName());
|
x.addTag(0, "p").b().tx(context.getLocale().getDisplayName());
|
||||||
x.addTag(0, "hr");
|
x.addTag(0, "hr");
|
||||||
|
@ -827,7 +827,7 @@ public class RenderingContext extends RenderingI18nContext {
|
|||||||
|
|
||||||
public String getTranslated(PrimitiveType<?> t) {
|
public String getTranslated(PrimitiveType<?> t) {
|
||||||
if (locale != null) {
|
if (locale != null) {
|
||||||
String v = ToolingExtensions.getLanguageTranslation(t, locale.toString());
|
String v = ToolingExtensions.getLanguageTranslation(t, locale.toLanguageTag());
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
@ -842,7 +842,7 @@ public class RenderingContext extends RenderingI18nContext {
|
|||||||
if (locale != null) {
|
if (locale != null) {
|
||||||
for (ResourceWrapper e : t.extensions(ToolingExtensions.EXT_TRANSLATION)) {
|
for (ResourceWrapper e : t.extensions(ToolingExtensions.EXT_TRANSLATION)) {
|
||||||
String l = e.extensionString("lang");
|
String l = e.extensionString("lang");
|
||||||
if (l != null && l.equals(locale.toString())) {
|
if (l != null && l.equals(locale.toLanguageTag())) {
|
||||||
String v = e.extensionString("content");
|
String v = e.extensionString("content");
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
return v;
|
return v;
|
||||||
@ -855,7 +855,7 @@ public class RenderingContext extends RenderingI18nContext {
|
|||||||
|
|
||||||
public StringType getTranslatedElement(PrimitiveType<?> t) {
|
public StringType getTranslatedElement(PrimitiveType<?> t) {
|
||||||
if (locale != null) {
|
if (locale != null) {
|
||||||
StringType v = ToolingExtensions.getLanguageTranslationElement(t, locale.toString());
|
StringType v = ToolingExtensions.getLanguageTranslationElement(t, locale.toLanguageTag());
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
@ -872,13 +872,13 @@ public class RenderingContext extends RenderingI18nContext {
|
|||||||
if (b instanceof org.hl7.fhir.r5.model.Element) {
|
if (b instanceof org.hl7.fhir.r5.model.Element) {
|
||||||
org.hl7.fhir.r5.model.Element e = (org.hl7.fhir.r5.model.Element) b;
|
org.hl7.fhir.r5.model.Element e = (org.hl7.fhir.r5.model.Element) b;
|
||||||
if (locale != null) {
|
if (locale != null) {
|
||||||
String v = ToolingExtensions.getLanguageTranslation(e, locale.toString());
|
String v = ToolingExtensions.getLanguageTranslation(e, locale.toLanguageTag());
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
// no? then see if the tx service can translate it for us
|
// no? then see if the tx service can translate it for us
|
||||||
try {
|
try {
|
||||||
ValidationResult t = getContext().validateCode(getTerminologyServiceOptions().withLanguage(locale.toString()).withVersionFlexible(true),
|
ValidationResult t = getContext().validateCode(getTerminologyServiceOptions().withLanguage(locale.toLanguageTag()).withVersionFlexible(true),
|
||||||
codeSystem, null, e.primitiveValue(), null);
|
codeSystem, null, e.primitiveValue(), null);
|
||||||
if (t.isOk() && t.getDisplay() != null) {
|
if (t.isOk() && t.getDisplay() != null) {
|
||||||
return t.getDisplay();
|
return t.getDisplay();
|
||||||
@ -903,7 +903,7 @@ public class RenderingContext extends RenderingI18nContext {
|
|||||||
|
|
||||||
if (locale != null) {
|
if (locale != null) {
|
||||||
try {
|
try {
|
||||||
ValidationResult t = getContext().validateCode(getTerminologyServiceOptions().withLanguage(locale.toString()).withVersionFlexible(true), codeSystem, null, code, null);
|
ValidationResult t = getContext().validateCode(getTerminologyServiceOptions().withLanguage(locale.toLanguageTag()).withVersionFlexible(true), codeSystem, null, code, null);
|
||||||
if (t.isOk() && t.getDisplay() != null) {
|
if (t.isOk() && t.getDisplay() != null) {
|
||||||
return t.getDisplay();
|
return t.getDisplay();
|
||||||
}
|
}
|
||||||
@ -916,13 +916,13 @@ public class RenderingContext extends RenderingI18nContext {
|
|||||||
|
|
||||||
public String getTranslatedCode(Enumeration<?> e, String codeSystem) {
|
public String getTranslatedCode(Enumeration<?> e, String codeSystem) {
|
||||||
if (locale != null) {
|
if (locale != null) {
|
||||||
String v = ToolingExtensions.getLanguageTranslation(e, locale.toString());
|
String v = ToolingExtensions.getLanguageTranslation(e, locale.toLanguageTag());
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
// no? then see if the tx service can translate it for us
|
// no? then see if the tx service can translate it for us
|
||||||
try {
|
try {
|
||||||
ValidationResult t = getContext().validateCode(getTerminologyServiceOptions().withLanguage(locale.toString()).withVersionFlexible(true),
|
ValidationResult t = getContext().validateCode(getTerminologyServiceOptions().withLanguage(locale.toLanguageTag()).withVersionFlexible(true),
|
||||||
codeSystem, null, e.getCode(), null);
|
codeSystem, null, e.getCode(), null);
|
||||||
if (t.isOk() && t.getDisplay() != null) {
|
if (t.isOk() && t.getDisplay() != null) {
|
||||||
return t.getDisplay();
|
return t.getDisplay();
|
||||||
@ -952,7 +952,7 @@ public class RenderingContext extends RenderingI18nContext {
|
|||||||
if (url.equals(ToolingExtensions.EXT_TRANSLATION)) {
|
if (url.equals(ToolingExtensions.EXT_TRANSLATION)) {
|
||||||
Base e1 = ext.getExtensionValue("lang");
|
Base e1 = ext.getExtensionValue("lang");
|
||||||
|
|
||||||
if (e1 != null && e1.primitiveValue() != null && e1.primitiveValue().equals(locale.toString())) {
|
if (e1 != null && e1.primitiveValue() != null && e1.primitiveValue().equals(locale.toLanguageTag())) {
|
||||||
e1 = ext.getExtensionValue("content");
|
e1 = ext.getExtensionValue("content");
|
||||||
if (e1 != null && e1.isPrimitive()) {
|
if (e1 != null && e1.isPrimitive()) {
|
||||||
return e1.primitiveValue();
|
return e1.primitiveValue();
|
||||||
@ -962,7 +962,7 @@ public class RenderingContext extends RenderingI18nContext {
|
|||||||
}
|
}
|
||||||
// no? then see if the tx service can translate it for us
|
// no? then see if the tx service can translate it for us
|
||||||
try {
|
try {
|
||||||
ValidationResult t = getContext().validateCode(getTerminologyServiceOptions().withLanguage(locale.toString()).withVersionFlexible(true),
|
ValidationResult t = getContext().validateCode(getTerminologyServiceOptions().withLanguage(locale.toLanguageTag()).withVersionFlexible(true),
|
||||||
codeSystem, null, e.primitiveValue(), null);
|
codeSystem, null, e.primitiveValue(), null);
|
||||||
if (t.isOk() && t.getDisplay() != null) {
|
if (t.isOk() && t.getDisplay() != null) {
|
||||||
return t.getDisplay();
|
return t.getDisplay();
|
||||||
|
@ -415,8 +415,8 @@ public abstract class ResourceWrapper {
|
|||||||
public abstract String getId();
|
public abstract String getId();
|
||||||
|
|
||||||
public void markLanguage(XhtmlNode x, Locale locale) {
|
public void markLanguage(XhtmlNode x, Locale locale) {
|
||||||
x.setAttribute("lang", locale.toString());
|
x.setAttribute("lang", locale.toLanguageTag());
|
||||||
x.setAttribute("xml:lang", locale.toString());
|
x.setAttribute("xml:lang", locale.toLanguageTag());
|
||||||
x.addTag(0, "hr");
|
x.addTag(0, "hr");
|
||||||
x.addTag(0, "p").b().tx(locale.getDisplayName());
|
x.addTag(0, "p").b().tx(locale.getDisplayName());
|
||||||
x.addTag(0, "hr");
|
x.addTag(0, "hr");
|
||||||
|
@ -192,8 +192,8 @@ public class ResourceWrapperModel extends ResourceWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void markLanguage(XhtmlNode x, Locale locale) {
|
public void markLanguage(XhtmlNode x, Locale locale) {
|
||||||
x.setAttribute("lang", locale.toString());
|
x.setAttribute("lang", locale.toLanguageTag());
|
||||||
x.setAttribute("xml:lang", locale.toString());
|
x.setAttribute("xml:lang", locale.toLanguageTag());
|
||||||
x.addTag(0, "hr");
|
x.addTag(0, "hr");
|
||||||
x.addTag(0, "p").b().tx(locale.getDisplayName());
|
x.addTag(0, "p").b().tx(locale.getDisplayName());
|
||||||
x.addTag(0, "hr");
|
x.addTag(0, "hr");
|
||||||
|
@ -175,8 +175,8 @@ public class ResourceWrapperNative extends ResourceWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void markLanguage(XhtmlNode x, Locale locale) {
|
public void markLanguage(XhtmlNode x, Locale locale) {
|
||||||
x.setAttribute("lang", locale.toString());
|
x.setAttribute("lang", locale.toLanguageTag());
|
||||||
x.setAttribute("xml:lang", locale.toString());
|
x.setAttribute("xml:lang", locale.toLanguageTag());
|
||||||
x.addTag(0, "hr");
|
x.addTag(0, "hr");
|
||||||
x.addTag(0, "p").b().tx(locale.getDisplayName());
|
x.addTag(0, "p").b().tx(locale.getDisplayName());
|
||||||
x.addTag(0, "hr");
|
x.addTag(0, "hr");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user