Skip to content

Commit c39ee5c

Browse files
committed
Ignore dynamic keypath as dynamic path in i18n-t
1 parent f9fdae4 commit c39ee5c

7 files changed

+20
-12
lines changed

dist/vue-i18n-extract.modern.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function extractMethodMatches(file) {
140140
}
141141

142142
function extractComponentMatches(file) {
143-
const componentRegExp = /(?:(?:<|h\()(?:i18n|Translation))(?:.|\n)*?(?:[^:]path(?:=|: )("|'))((?:[^\\]|\\.)*?)\1/gi;
143+
const componentRegExp = /(?:(?:<|h\()(?:i18n|Translation))(?:.|\n)*?(?:\s(?:(?:key)?)path(?:=|: )("|'))((?:[^\\]|\\.)*?)\1/gi;
144144
return [...getMatches(file, componentRegExp, 2)];
145145
}
146146

dist/vue-i18n-extract.modern.mjs.map

+1-1
Large diffs are not rendered by default.

dist/vue-i18n-extract.umd.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-i18n-extract.umd.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/create-report/vue-files.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function* getMatches (file: SimpleFile, regExp: RegExp, captureGroup = 1): Itera
7676
}
7777

7878
function extractComponentMatches (file: SimpleFile): I18NItemWithBounding[] {
79-
const componentRegExp = /(?:(?:<|h\()(?:i18n|Translation))(?:.|\n)*?(?:[^:]path(?:=|: )("|'))((?:[^\\]|\\.)*?)\1/gi;
79+
const componentRegExp = /(?:(?:<|h\()(?:i18n|Translation))(?:.|\n)*?(?:\s(?:(?:key)?)path(?:=|: )("|'))((?:[^\\]|\\.)*?)\1/gi;
8080
return [ ...getMatches(file, componentRegExp, 2) ];
8181
}
8282

tests/fixtures/expected-values.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ export const expectedFromParsedVueFiles = [
4646
previousCharacter: "'",
4747
nextCharacter: "'",
4848
file: './tests/fixtures/vue-files/Basic.vue',
49-
line: 12
49+
line: 16
5050
},
5151
{
5252
path: 'content.link.b',
5353
previousCharacter: "'",
5454
nextCharacter: "'",
5555
file: './tests/fixtures/vue-files/Basic.vue',
56-
line: 15
56+
line: 23
5757
},
5858
{
5959
path: 'header.title',
6060
previousCharacter: "'",
6161
nextCharacter: "'",
6262
file: './tests/fixtures/vue-files/Basic.vue',
63-
line: 19
63+
line: 27
6464
},
6565
{
6666
path: 'content.link.a',
@@ -74,28 +74,28 @@ export const expectedFromParsedVueFiles = [
7474
previousCharacter: '"',
7575
nextCharacter: '"',
7676
file: './tests/fixtures/vue-files/Basic.vue',
77-
line: 11
77+
line: 12
7878
},
7979
{
8080
path: 'content.link.a',
8181
previousCharacter: '"',
8282
nextCharacter: '"',
8383
file: './tests/fixtures/vue-files/Basic.vue',
84-
line: 14
84+
line: 19
8585
},
8686
{
8787
path: 'header.title',
8888
previousCharacter: "'",
8989
nextCharacter: "'",
9090
file: './tests/fixtures/vue-files/Basic.vue',
91-
line: 17
91+
line: 25
9292
},
9393
{
9494
path: 'header.title',
9595
previousCharacter: "'",
9696
nextCharacter: "'",
9797
file: './tests/fixtures/vue-files/Basic.vue',
98-
line: 18
98+
line: 26
9999
},
100100
{
101101
path: "single \\' quote",

tests/fixtures/vue-files/Basic.vue

+8
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@
88
<i18n path="content.link.a">
99
<a place="link" href="#">{{ $t('content.link.b') }}</a>
1010
</i18n>
11+
<!-- Should not match -- dynamic path is ignored -->
12+
<i18n :path="dynamicPath">
13+
<span place="icon" class="icon" />
14+
</i18n>
1115
<i18n-t keypath="content.link.a">
1216
<a place="link" href="#">{{ $t('content.link.b') }}</a>
1317
</i18n-t>
18+
<!-- Should not match -- dynamic keypath is ignored -->
19+
<i18n-t :keypath="dynamicPath">
20+
<span place="icon" class="icon" />
21+
</i18n-t>
1422
<Translation keypath="content.link.a">
1523
<a place="link" href="#">{{ $t('content.link.b') }}</a>
1624
</Translation>

0 commit comments

Comments
 (0)