Skip to content

Commit

Permalink
fix(bin): fix extra text error from t.t('xxx')
Browse files Browse the repository at this point in the history
'xxx' is key but not the text
  • Loading branch information
eyelly-wu committed May 16, 2024
1 parent e6162e9 commit 1ae7b7f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bin/extra-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down
1 change: 1 addition & 0 deletions test/bin/extra-text.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('验证 t 翻译文本提取功能', () => {
'我叫{0},今年{1}岁,来自{2},是一名{3}',
'a',
'b',
'文案',
]

const errrorTexts = [
Expand Down
1 change: 1 addition & 0 deletions test/i18n/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('文案')))

0 comments on commit 1ae7b7f

Please sign in to comment.