vite-plugin-auto-trans-vue-i18n
v1.0.0
Published
A plugin based on vue-i18n automatic translation of i18n Chinese
Downloads
2
Readme
Usage
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import {autoUpdateI18n} from 'vite-plugin-auto-trans-i18n'
const URL = 'https://fanyi-api.baidu.com/api/trans/vip/translate'
const KEY = 'xxx'
const SALT = 'xxxx'
const APPID = 'xxxxx'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), autoUpdateI18n({
TRANSAPI: 'https://fanyi-api.baidu.com/api/trans/vip/translate',
KEY,
SALT,
APPID,
rootPath:'/src/i18n/',//Directory of documents for Chinese and English translations
zhFileName:'zh-CN.ts',//中文文件名
enFileName:'auto-en-US.ts',//英文文件名
})],
})
注册
import {register} from 'vite-plugin-auto-trans-i18n'
const app = createApp()
app.use(register({
locale: 'zh-CN',
legacy: true,
message:{
//.....
}
}))
zh-CN文件
export default {
home:{
homeButtons: {
add: '退出登录',
},
profileButtons:{
col:'我的收藏'
}
}
}
auto-en-US文件的内容将会根据zh-CN自动创建。请自行在注册时导入,如翻译结果不满足要求,覆盖即可。