mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-07 18:25:45 +08:00
Support Option Traslation (#821)
* support trastation * minimal changes Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
This commit is contained in:
parent
a967a1f942
commit
cc7fc71fe1
@ -42,7 +42,6 @@
|
||||
size="medium"
|
||||
style="width: 100%;"
|
||||
filterable
|
||||
@change="getTranslation"
|
||||
>
|
||||
<!-- <el-option
|
||||
key="blank-option"
|
||||
@ -58,17 +57,35 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$t('field.container.codeTranslation')"
|
||||
:label="$t('field.codeTranslation') + fieldAttributes.name"
|
||||
:required="true"
|
||||
>
|
||||
<el-input
|
||||
v-model="translatedValue"
|
||||
:disabled="isEmptyValue(langValue)"
|
||||
@change="changeTranslationValue"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<br>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<samp style="float: right; padding-right: 10px;">
|
||||
<el-button
|
||||
type="danger"
|
||||
class="custom-button-address-location"
|
||||
icon="el-icon-close"
|
||||
@click="close()"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="custom-button-address-location"
|
||||
icon="el-icon-check"
|
||||
@click="changeTranslationValue(translatedValue)"
|
||||
/>
|
||||
</samp>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
@ -110,7 +127,7 @@ export default {
|
||||
const values = this.$store.getters.getTranslationByLanguage({
|
||||
containerUuid: this.fieldAttributes.containerUuid,
|
||||
language: this.langValue,
|
||||
recordUuid: this.recordUuid
|
||||
recordUuid: this.fieldAttributes.recordUuid
|
||||
})
|
||||
if (this.isEmptyValue(values)) {
|
||||
return undefined
|
||||
@ -131,6 +148,7 @@ export default {
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTranslation()
|
||||
let langMatch = this.languageList.find(itemLanguage => {
|
||||
return itemLanguage.languageISO === getLanguage()
|
||||
})
|
||||
@ -151,7 +169,7 @@ export default {
|
||||
this.isLoading = true
|
||||
this.$store.dispatch('getTranslationsFromServer', {
|
||||
containerUuid: this.fieldAttributes.containerUuid,
|
||||
recordUuid: this.recordUuid,
|
||||
recordUuid: this.fieldAttributes.recordUuid,
|
||||
tableName: this.fieldAttributes.tableName,
|
||||
language: this.langValue
|
||||
})
|
||||
@ -164,8 +182,14 @@ export default {
|
||||
containerUuid: this.fieldAttributes.containerUuid,
|
||||
language: this.langValue,
|
||||
columnName: this.fieldAttributes.columnName,
|
||||
recordUuid: this.fieldAttributes.recordUuid,
|
||||
value
|
||||
})
|
||||
this.close()
|
||||
},
|
||||
close() {
|
||||
this.$children[0].visible = false
|
||||
this.$store.commit('changeShowRigthPanel', false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@
|
||||
<div v-if="option.name !== $t('language')" style="margin-right: 5%;padding-top: 3%;">
|
||||
<i :class="option.icon" style="font-weight: bolder;" />
|
||||
</div>
|
||||
<div v-else style="margin-right: 5%">
|
||||
<div v-else style="margin-right: 5%; padding-left: 8%;">
|
||||
<svg-icon :icon-class="option.icon" style="margin-right: 5px;" />
|
||||
</div>
|
||||
<div>
|
||||
|
@ -330,7 +330,7 @@ export default {
|
||||
info: 'Information',
|
||||
calculator: 'Calculator',
|
||||
preference: 'Preference',
|
||||
codeTranslation: 'Traduccion de Codigo',
|
||||
codeTranslation: 'Translation Of ',
|
||||
container: {
|
||||
help: 'Help',
|
||||
description: 'Description'
|
||||
|
@ -306,7 +306,7 @@ export default {
|
||||
info: 'Informacion',
|
||||
calculator: 'Calculadora',
|
||||
preference: 'Preferencia',
|
||||
codeTranslation: 'Traduccion de Codigo',
|
||||
codeTranslation: 'Traduccion de ',
|
||||
container: {
|
||||
help: 'Ayuda',
|
||||
description: 'Descripción'
|
||||
|
@ -93,8 +93,7 @@ const languageControl = {
|
||||
console.warn(translationResponse)
|
||||
return
|
||||
}
|
||||
|
||||
const { values, uuid } = translationResponse.translationsList[0]
|
||||
const { values, uuid, language } = translationResponse.translationsList[0]
|
||||
dispatch('setTranslation', {
|
||||
containerUuid,
|
||||
tableName,
|
||||
@ -116,6 +115,7 @@ const languageControl = {
|
||||
containerUuid,
|
||||
language,
|
||||
columnName,
|
||||
recordUuid,
|
||||
value
|
||||
}) {
|
||||
return new Promise(resolve => {
|
||||
@ -125,7 +125,6 @@ const languageControl = {
|
||||
const translationSelected = translationData.translations.find(itemTranslation => {
|
||||
return itemTranslation.language === language
|
||||
})
|
||||
|
||||
const values = translationSelected.values
|
||||
// not change value
|
||||
if (values[columnName] === value) {
|
||||
@ -133,9 +132,9 @@ const languageControl = {
|
||||
return value
|
||||
}
|
||||
|
||||
requestUpdateEntity({
|
||||
return requestUpdateEntity({
|
||||
tableName: `${translationData.tableName}_Trl`, // '_Trl' is suffix for translation tables
|
||||
recordUuid: translationSelected.uuid,
|
||||
recordUuid,
|
||||
attributesList: [{
|
||||
columnName,
|
||||
value
|
||||
@ -151,6 +150,7 @@ const languageControl = {
|
||||
newValues
|
||||
})
|
||||
resolve(newValues)
|
||||
return newValues
|
||||
})
|
||||
.catch(error => {
|
||||
console.warn(`Error Update Translation ${error.message}. Code: ${error.code}.`)
|
||||
|
Loading…
x
Reference in New Issue
Block a user