1.1.27 • Published 3 years ago

vue-automatic-i18n v1.1.27

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

vue-automatic-i18n

Automatically translate vue 2 project with any translation api.

Usage

// main.ts
import VueI18n from 'vue-i18n'
import VueAutomaticI18n from 'vue-automatic-i18n'
Vue.use(VueI18n)
Vue.use(VueAutomaticI18n)
// vue.config.js
const { VueAutomaticI18nPlugin } = require('vue-automatic-i18n/dist/plugin')
module.exports = {
  configureWebpack: {
    plugins: [
      new VueAutomaticI18nPlugin({
        cbInit: async () => {
          // any initialization goes here
        },
        pathGlobs: ['src/**/*.vue'],
        // Use ISO-639-1 language code as locale names, refer to:
        // https://cloud.google.com/translate/docs/languages
        locales: ['en', 'zh-CN', 'zh-TW', 'ja', 'ko', 'it', 'fr', 'es', 'vi', 'tr', 'de', 'pt', 'ru'],
        // where you want to put all the generated locale files
        dist: 'src/i18n/locales',
        cbTrans: async (params) => {
          // params.content - source content
          // params.source - source locale code
          // params.target - target locale code
          // return the translated content by translation api, like Google Translate
        },
      })
    ]
  }
}
<template>
<div>
  {{ $i18nTrans({ en: 'Get started', 'zh-CN': '立刻开始' }) }}
  {{ $i18nTrans({ en: 'Get improved' }) }}
  {{ $i18nTrans({ 'zh-CN': '随意发挥' }) }}
  {{ $i18nTrans({ en: 'Write anything', 'zh-CN': '随意书写' }, { source: 'zh-CN' }) }}
<div>
</template>

Remeber to load the generated locale files in vue-i18n, refer to the doc at: https://kazupon.github.io/vue-i18n/guide/lazy-loading.html

1.1.27

3 years ago

1.1.26

3 years ago

1.1.25

3 years ago

1.1.24

3 years ago

1.1.23

3 years ago

1.1.22

3 years ago

1.1.21

3 years ago

1.1.19

3 years ago

1.1.18

3 years ago

1.1.17

3 years ago

1.1.16

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago