1.1.27 • Published 2 years ago

vue-automatic-i18n v1.1.27

Weekly downloads
-
License
ISC
Repository
github
Last release
2 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

2 years ago

1.1.26

2 years ago

1.1.25

2 years ago

1.1.24

2 years ago

1.1.23

2 years ago

1.1.22

2 years ago

1.1.21

2 years ago

1.1.19

2 years ago

1.1.18

2 years ago

1.1.17

2 years ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago