0

I have a json file filled with tranlations I am trying to use those translation.

First this is how I am trying to call the translation.

import messages from './i18n/messages.json

export default {
  ...
  methods:{
   data: {
     messages
   },
   loginUser() {
     if(login){
       this.messages('LOGIN_SUCCESS')
     }
   }
  }
}

But in order to do this, I don't know how to make this.messages('TOKEN') work.

I never worked on translation code so I am asking if you just the list of translation (messages.json) file, how would you retrieve data from it to show the text?

hidar
  • 5,449
  • 15
  • 46
  • 70
  • Did you try vue-i18n? https://github.com/kazupon/vue-i18n – ittus Mar 24 '18 at 01:10
  • That is what I am using, I just don't know how to fetch messages by token – hidar Mar 24 '18 at 01:17
  • 3
    I think you can get message easily if your configuration is correct `this.message = this.$t('LOGIN_SUCCESS')` https://kazupon.github.io/vue-i18n/en/interpolation.html#basic-usage – ittus Mar 24 '18 at 01:21

0 Answers0