UNPKG

i18n-auto-react

Version:

基于百度翻译API服务的自动翻译插件

30 lines (27 loc) 844 B
import { d as getConfiguration } from '../utils/index.js'; import { i as i18nPlugin } from '../utils/parser.js'; function i18nAutoPlugin() { let config = getConfiguration(); return { name: 'vite-plugin-i18n-parser', enforce: 'pre', transform: function (code, file) { if (!/node_modules/.test(file) && /.(js|ts|tsx|jsx)$/.test(file)) { let res = i18nPlugin(code, { ...(config || {}), filePath: file, // @ts-ignore emitWarning: this.warn.bind(this), isVite: true }); if (res) return res; } return { code, map: null }; } }; } export { i18nAutoPlugin };