TerryZ / v-dialogs

A simple style useful dialog component collection for Vue
https://terryz.github.io/docs-vue3/dialog/
MIT License
130 stars 27 forks source link

error on vue-i18n #27

Closed RezaErfani67 closed 4 years ago

RezaErfani67 commented 4 years ago

i write this code

<div class="card-header rgba-stylish-strong text-white pt-1 pb-1">{{$t('sideMenu1')}}</div>

return below error image

TerryZ commented 4 years ago

I never use vue-i18n before, but you can try the code below:

i18n.js file for example

import Vue from 'vue'
import VueI18n from 'vue-i18n'

Vue.use(VueI18n);

const messages = {
  'en': {
    username: 'Chen',
    ...
  },
  'cn': {
    username: '陈',
    ...
  }
}

export default new VueI18n({
  locale: 'en', // set locale
  fallbackLocale: 'cn', // set fallback locale
  messages, // set locale messages
})

Your vue file

<template>
  <div v-text="i18n('username')"></div>
</template>

<script>
import i18n from './i18n'
export default {
  methods: {
    i18n (key) {
      return i18n.t(key)
    }
  }
}
</script>

Hope these can help you.

RezaErfani67 commented 4 years ago

yes... thanks a lot @TerryZ God Bless You