Home > Blockchain >  How translate an object taken from Api with vuejs
How translate an object taken from Api with vuejs

Time:12-17

I have these object taken from an Api

<div v-if="getError">
      <div v-for="(_errors, key) in getError">
       
        <b-alert show variant="danger" v-for="error in _errors">
          <h2>{{key.replace('contract_data.','')}} :</h2>
        <li>{{error}}</li>  </b-alert>
      
      </div>
    </div>

my question is how to translate these? i tried to do this:

<b-alert show variant="danger" v-for="error in _errors">
          <h2>{{$t('vue.' key).replace('contract_data.','')}} :</h2>
        <li>{{$t('error')}}</li>  </b-alert> 

but it doesn't works

CodePudding user response:

Exactly as @Seididieci mentioned on comment

$t('vue.' key.replace('contract_data.',''))

CodePudding user response:

const EXTERNAL_OBJECT = reactive({ name:"Bob", list:[{name:"Ivan"}] });

  • Related