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: [], extensions: [], }, trans: { component: 'Trans', i18nKey: 'i18nKey', defaultsKey: 'defaults', extensions: ['.ts', '.tsx'], acorn: { ecmaVersion: 2020, sourceType: 'module', plugins: ['typescript', 'jsx'], }, fallbackKey: function (ns, value) { return value }, }, lngs: ['en'], defaultLng: 'en', defaultNs: 'translation', defaultValue: function (lng, ns, key) { return key }, resource: { loadPath: 'public/locales/{{lng}}/{{ns}}.json', savePath: 'public/locales/{{lng}}/{{ns}}.json', jsonIndent: 2, lineEnding: '\n', }, nsSeparator: ':', keySeparator: '.', interpolation: { prefix: '{{', suffix: '}}', }, // 自定义提取规则,用于扫描未使用 i18next 的文本 customTransComponents: [ { name: 'Trans', props: ['i18nKey', 'defaults'], }, ], // 扫描 JSX 文本和属性 detect: { // 扫描 JSX 子元素文本 jsxText: true, // 扫描属性值 attr: ['placeholder', 'title', 'alt', 'aria-label', 'aria-placeholder'], // 扫描函数调用中的字符串 func: ['toast', 'alert', 'confirm', 'message', 'console.log', 'console.error'], // 扫描对象字面量中的 message 属性 object: ['message', 'error', 'warning', 'success'], }, }, }