UNPKG

i18n-extract-en-cli

Version:

这是一款能够自动将代码里的英文转成i18n国际化标记的命令行工具。当然,你也可以用它实现将英文语言包自动翻译成其他语言。适用于vue2、vue3和react

62 lines (61 loc) 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // 第二个参数path,在生成配置文件时需要展示在文件里,所以不需要去掉 // eslint-disable-next-line @typescript-eslint/no-unused-vars function getCustomizeKey(key, path) { return key; } function getCommonRule() { return { caller: '', functionName: 't', customizeKey: getCustomizeKey, importDeclaration: 'import { t } from "i18n"', }; } 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: '$t', functionNameInScript: '$t', customizeKey: getCustomizeKey, importDeclaration: '', }, }, 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: [], }, // eslint-disable-next-line @typescript-eslint/no-unused-vars adjustKeyMap(allKeyValue, currentFileKeyMap, currentFilePath) { return allKeyValue; }, }; exports.default = config;