2025-11-13 08:38:25 +00:00
|
|
|
module.exports = {
|
|
|
|
|
input: [
|
|
|
|
|
'src/**/*.{ts,tsx}',
|
|
|
|
|
'!src/**/*.d.ts',
|
|
|
|
|
'!src/**/node_modules/**',
|
|
|
|
|
'!src/**/.next/**',
|
|
|
|
|
'!src/**/__tests__/**',
|
|
|
|
|
'!src/**/mocks/**',
|
|
|
|
|
'!src/**/mock/**',
|
|
|
|
|
],
|
|
|
|
|
output: './',
|
|
|
|
|
options: {
|
|
|
|
|
debug: true,
|
|
|
|
|
// 禁用默认的 i18next 函数扫描,因为项目还没有使用 i18next
|
|
|
|
|
func: {
|
|
|
|
|
list: [],
|
2025-11-28 06:31:36 +00:00
|
|
|
extensions: [],
|
2025-11-13 08:38:25 +00:00
|
|
|
},
|
|
|
|
|
trans: {
|
|
|
|
|
component: 'Trans',
|
|
|
|
|
i18nKey: 'i18nKey',
|
|
|
|
|
defaultsKey: 'defaults',
|
|
|
|
|
extensions: ['.ts', '.tsx'],
|
|
|
|
|
acorn: {
|
|
|
|
|
ecmaVersion: 2020,
|
|
|
|
|
sourceType: 'module',
|
2025-11-28 06:31:36 +00:00
|
|
|
plugins: ['typescript', 'jsx'],
|
|
|
|
|
},
|
|
|
|
|
fallbackKey: function (ns, value) {
|
|
|
|
|
return value
|
2025-11-13 08:38:25 +00:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
lngs: ['en'],
|
|
|
|
|
defaultLng: 'en',
|
|
|
|
|
defaultNs: 'translation',
|
2025-11-28 06:31:36 +00:00
|
|
|
defaultValue: function (lng, ns, key) {
|
|
|
|
|
return key
|
2025-11-13 08:38:25 +00:00
|
|
|
},
|
|
|
|
|
resource: {
|
|
|
|
|
loadPath: 'public/locales/{{lng}}/{{ns}}.json',
|
|
|
|
|
savePath: 'public/locales/{{lng}}/{{ns}}.json',
|
|
|
|
|
jsonIndent: 2,
|
2025-11-28 06:31:36 +00:00
|
|
|
lineEnding: '\n',
|
2025-11-13 08:38:25 +00:00
|
|
|
},
|
|
|
|
|
nsSeparator: ':',
|
|
|
|
|
keySeparator: '.',
|
|
|
|
|
interpolation: {
|
|
|
|
|
prefix: '{{',
|
2025-11-28 06:31:36 +00:00
|
|
|
suffix: '}}',
|
2025-11-13 08:38:25 +00:00
|
|
|
},
|
|
|
|
|
// 自定义提取规则,用于扫描未使用 i18next 的文本
|
|
|
|
|
customTransComponents: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Trans',
|
2025-11-28 06:31:36 +00:00
|
|
|
props: ['i18nKey', 'defaults'],
|
|
|
|
|
},
|
2025-11-13 08:38:25 +00:00
|
|
|
],
|
|
|
|
|
// 扫描 JSX 文本和属性
|
|
|
|
|
detect: {
|
|
|
|
|
// 扫描 JSX 子元素文本
|
|
|
|
|
jsxText: true,
|
|
|
|
|
// 扫描属性值
|
|
|
|
|
attr: ['placeholder', 'title', 'alt', 'aria-label', 'aria-placeholder'],
|
|
|
|
|
// 扫描函数调用中的字符串
|
|
|
|
|
func: ['toast', 'alert', 'confirm', 'message', 'console.log', 'console.error'],
|
|
|
|
|
// 扫描对象字面量中的 message 属性
|
2025-11-28 06:31:36 +00:00
|
|
|
object: ['message', 'error', 'warning', 'success'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|