i18-fe-automator
Version:
前端代码提取中文并替换成$t函数
66 lines (65 loc) • 1.91 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
// 参数path,在生成配置文件时需要展示在文件里,所以这里去掉eslint校验
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function getCustomizeKey(key, path) {
return key;
}
function getCommonRule() {
return {
caller: '',
// functionName: 't',
functionName: '$hxt',
customizeKey: getCustomizeKey,
// importDeclaration: 'import { t } from "i18n"',
importDeclaration: '',
};
}
const config = {
input: 'src',
output: '',
exclude: ['**/node_modules/**/*'],
rules: {
js: getCommonRule(),
ts: getCommonRule(),
cjs: getCommonRule(),
mjs: getCommonRule(),
jsx: {
...getCommonRule(),
functionSnippets: '',
},
tsx: {
...getCommonRule(),
functionSnippets: '',
},
vue: {
caller: 'this',
functionNameInTemplate: '$hxt',
functionNameInScript: '$hxt',
customizeKey: getCustomizeKey,
importDeclaration: '',
tagOrder: ['template', 'script', 'style'],
},
},
prettier: {
semi: false,
singleQuote: true,
},
incremental: false,
skipExtract: false,
localePath: './locales/zh-CN.json',
localeFileType: 'json',
excelPath: './locales.xlsx',
exportExcel: false,
skipTranslate: false,
locales: ['en-US'],
globalRule: {
ignoreMethods: [],
},
// 参数currentFileKeyMap和currentFilePath,在生成配置文件时需要展示在文件里,所以这里去掉eslint校验
// eslint-disable-next-line @typescript-eslint/no-unused-vars
adjustKeyMap(allKeyValue, currentFileKeyMap, currentFilePath) {
return allKeyValue;
},
};
exports.default = config;