Commit b6f26bf5 authored by Jean Rabreau's avatar Jean Rabreau
Browse files

馃悰 add translation method default value

parent 35a5a621
Pipeline #63738 passed with stages
in 3 minutes and 42 seconds
......@@ -85,7 +85,7 @@ export default {
if (options && !Array.isArray(rawValue)) {
const option = options.find(o => o.value === rawValue)
if (option) {
return this.getTranslation('label', option)
return this.getTranslation('label', option.id, rawValue)
}
}
return rawValue
......@@ -133,26 +133,26 @@ export default {
}
return cleanedValue
},
getDefaultTranslation(property, field) {
getDefaultTranslation(property, fieldId, defaultValue) {
try {
const translation = this.defaultMessages[field.id][property]
const translation = this.defaultMessages[fieldId][property]
return translation
? translation
: field.value
: defaultValue
}
catch (error) {
return field.value
return defaultValue
}
},
getTranslation(property, field) {
getTranslation(property, fieldId, defaultValue) {
try {
const translation = this.locales[this.$i18n.locale][field.id][property]
const translation = this.locales[this.$i18n.locale][fieldId][property]
return translation
? translation
: this.getDefaultTranslation(property, field)
: this.getDefaultTranslation(property, fieldId, defaultValue)
}
catch (error) {
return this.getDefaultTranslation(property, field)
return this.getDefaultTranslation(property, fieldId, defaultValue)
}
},
cleanFields(fields) {
......@@ -173,7 +173,7 @@ export default {
const component = FieldRenderer
const savedItemField = this.item.metadata.find(d => d.id === field.id)
field.label = this.getTranslation('label', field)
field.label = this.getTranslation('label', field.id, field.label)
acc.push({
data: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment