Skip to content

Internationalization

Language Configuration

The FormMaking uses vue-i18n@8.x for multi-language support.

The FormMaking supports both Simplified Chinese (zh-CN) and English (en-US). By default, Simplified Chinese is used. If you want to use English, you need to configure as follows:

javascript
Vue.use(FormMaking, {lang: 'en-US'})

If you are using FormMaking in Html, the configuration is as follows:

vue
<script>
  Vue.use(FormMaking, {
    lang: 'en-US'
  })
  new Vue({
    el: '#app'
  })
</script>

Used in Multilingual Projects

javascript
import Vue from 'vue'
import Element from 'element-ui'
import FormMaking from 'form-making'
import VueI18n from 'vue-i18n'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'

Vue.use(VueI18n)

const messages = {
  'en-US': {
    message: 'hello',
    ...enLocale
  },
  'zh-CN': {
    message: '你好',
    ...zhLocale
  }
}

// Create VueI18n instance with options
const i18n = new VueI18n({
  locale: 'zh-CN', // set locale
  messages, // set locale messages
})

Vue.use(Element, {
  i18n: (key, value) => i18n.t(key, value)
})

Vue.use(FormMaking, {lang: 'zh-CN', i18n})

new Vue({
  i18n,
  render: h => h(App)
}).$mount('#app')