Answer the question
In order to leave comments, you need to log in
How to localize object fields?
I have an array of objects from which I print out the v-for field names:
info: [
{
name: 'Name',
value: '',
pattern: /^[a-zA-Z ]{2,30}$/
},
]
Answer the question
In order to leave comments, you need to log in
a) Localize in the template itself, store the i18n label in name.
b) Give an array from the computed property.
c) Generate an array in the data() function before putting it in the data object. (when changing the locale - will not be updated)
...
In general, I added a key to each object, by which I look for the desired text in the dictionary
{
name: '',
value: '',
pattern: /^[a-zA-Z ]{2,30}$/,
key: 'nameTxt'
},
ru: {
nameTxt: 'Имя',
phoneTxt: 'Телефон',
emailTxt: 'Электронный адрес',
someField1Txt: 'Дополнительное поле 1',
someField2Txt: 'Дополнительное поле 2',
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question