diff --git a/src/bin/extra-text.ts b/src/bin/extra-text.ts index 2dc3bf0..887b0c9 100644 --- a/src/bin/extra-text.ts +++ b/src/bin/extra-text.ts @@ -38,7 +38,7 @@ export function extraTextFromT( error: string[], ) { const regexp = new RegExp( - /\WfuncName\(\n*[ ]*((['"`])(.+?)\2)(,|\))/.source.replace( + /[^.A-z]funcName\(\n*[ ]*((['"`])(.+?)\2)(,|\))/.source.replace( 'funcName', funcName, ), diff --git a/test/bin/extra-text.test.ts b/test/bin/extra-text.test.ts index ab017d6..ee19bc2 100644 --- a/test/bin/extra-text.test.ts +++ b/test/bin/extra-text.test.ts @@ -16,6 +16,7 @@ describe('验证 t 翻译文本提取功能', () => { '我叫{0},今年{1}岁,来自{2},是一名{3}', 'a', 'b', + '文案', ] const errrorTexts = [ diff --git a/test/i18n/text.ts b/test/i18n/text.ts index 0940716..3b5edf9 100644 --- a/test/i18n/text.ts +++ b/test/i18n/text.ts @@ -23,3 +23,4 @@ t('普通文本') t('普通文本{0}', foo) t('我叫{0},今年{1}岁,来自{2},是一名{3}', '王尼玛', '22', '火星', '码农') t('a', t('b')) +t.t('自定义key', t.t('自定义key2', t('文案')))