File tree Expand file tree Collapse file tree 1 file changed +47
-20
lines changed Expand file tree Collapse file tree 1 file changed +47
-20
lines changed Original file line number Diff line number Diff line change @@ -8,28 +8,42 @@ This rule warns locale message key missing if the key does not exist in locale m
8
8
9
9
## :book : Rule Details
10
10
11
- The methods that can be detected with this rule are as follows :
11
+ You can be detected with this rule the following :
12
12
13
13
- ` $t `
14
14
- ` t `
15
15
- ` $tc `
16
16
- ` tc `
17
+ - ` v-t `
17
18
18
19
:-1 : Examples of ** incorrect** code for this rule:
19
20
20
- ``` js
21
- const localeMessages = {
22
- en: {
23
- hello: ' Hello! DIO!'
24
- }
25
- ja: {
26
- hello: ' こんにちは、DIO!'
27
- }
21
+ locale messages:
22
+ ``` json
23
+ {
24
+ "hello" : " Hello! DIO!"
28
25
}
26
+ ```
27
+
28
+ localization codes:
29
29
30
+ ``` vue
31
+ <template>
32
+ <div class="app">
33
+ <!-- ✗ BAD -->
34
+ <p>{{ $t('hi) }}</p>
35
+ <!-- ✗ BAD -->
36
+ <p v-t="'hi'"></p>
37
+ </div>
38
+ </template>
39
+ ```
40
+
41
+ ``` js
30
42
const i18n = new VueI18n ({
31
43
locale: ' en' ,
32
- localeMessages
44
+ messages: {
45
+ en: require (' ./locales/en.json' )
46
+ }
33
47
})
34
48
35
49
/* ✗ BAD */
@@ -38,21 +52,34 @@ i18n.t('hi')
38
52
39
53
:+1 : Examples of ** correct** code for this rule:
40
54
41
- ``` js
42
- const localeMessages = {
43
- en: {
44
- hello: ' Hello! DIO!'
45
- }
46
- ja: {
47
- hello: ' こんにちは、DIO!'
48
- }
55
+ locale messages:
56
+ ``` json
57
+ {
58
+ "hello" : " Hello! DIO!"
49
59
}
60
+ ```
50
61
62
+ localization codes:
63
+
64
+ ``` vue
65
+ <template>
66
+ <div class="app">
67
+ <!-- ✗ GOOD -->
68
+ <p>{{ $t('hello') }}</p>
69
+ <!-- ✗ GOOD -->
70
+ <p v-t="'hello'"></p>
71
+ </div>
72
+ </template>
73
+ ```
74
+
75
+ ``` js
51
76
const i18n = new VueI18n ({
52
77
locale: ' en' ,
53
- localeMessages
78
+ messages: {
79
+ en: require (' ./locales/en.json' )
80
+ }
54
81
})
55
82
56
83
/* ✓ GOOD */
57
84
i18n .t (' hello' )
58
- ```
85
+ ```
You can’t perform that action at this time.
0 commit comments