@lingual/i18n-check 0.8.4 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/bin/index.js +4 -1
- package/dist/index.js +2 -2
- package/dist/utils/nextIntlSrcParser.js +43 -0
- package/package.json +12 -11
- package/dist/bin/index.test.d.ts +0 -1
- package/dist/bin/index.test.js +0 -786
- package/dist/errorReporters.test.d.ts +0 -1
- package/dist/errorReporters.test.js +0 -165
- package/dist/utils/findInvalidTranslations.test.d.ts +0 -1
- package/dist/utils/findInvalidTranslations.test.js +0 -83
- package/dist/utils/findInvalidi18nTranslations.test.d.ts +0 -1
- package/dist/utils/findInvalidi18nTranslations.test.js +0 -206
- package/dist/utils/findMissingKeys.test.d.ts +0 -1
- package/dist/utils/findMissingKeys.test.js +0 -41
- package/dist/utils/flattenTranslations.test.d.ts +0 -1
- package/dist/utils/flattenTranslations.test.js +0 -28
- package/dist/utils/i18NextParser.test.d.ts +0 -1
- package/dist/utils/i18NextParser.test.js +0 -150
- package/dist/utils/nextIntlSrcParser.test.d.ts +0 -1
- package/dist/utils/nextIntlSrcParser.test.js +0 -568
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const i18NextParser_1 = require("./i18NextParser");
|
|
4
|
-
describe('i18NextParser', () => {
|
|
5
|
-
it('should parse interpolation', () => {
|
|
6
|
-
expect((0, i18NextParser_1.parse)('test {{val}} text {{- encoded}} with {{val, format}} some $t{nesting} help')).toEqual([
|
|
7
|
-
{
|
|
8
|
-
type: 'text',
|
|
9
|
-
content: 'test ',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
type: 'interpolation',
|
|
13
|
-
raw: '{{val}}',
|
|
14
|
-
prefix: '{{',
|
|
15
|
-
suffix: '}}',
|
|
16
|
-
content: 'val',
|
|
17
|
-
variable: 'val',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
type: 'text',
|
|
21
|
-
content: ' text ',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
type: 'interpolation_unescaped',
|
|
25
|
-
raw: '{{- encoded}}',
|
|
26
|
-
prefix: '{{-',
|
|
27
|
-
suffix: '}}',
|
|
28
|
-
content: ' encoded',
|
|
29
|
-
variable: 'encoded',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
type: 'text',
|
|
33
|
-
content: ' with ',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
type: 'interpolation',
|
|
37
|
-
raw: '{{val, format}}',
|
|
38
|
-
prefix: '{{',
|
|
39
|
-
suffix: '}}',
|
|
40
|
-
content: 'val, format',
|
|
41
|
-
variable: 'val, format',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
type: 'text',
|
|
45
|
-
content: ' some ',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
type: 'nesting',
|
|
49
|
-
raw: '$t{nesting}',
|
|
50
|
-
prefix: '$t{',
|
|
51
|
-
suffix: '}',
|
|
52
|
-
content: 'nesting',
|
|
53
|
-
variable: 'nesting',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
type: 'text',
|
|
57
|
-
content: ' help',
|
|
58
|
-
},
|
|
59
|
-
]);
|
|
60
|
-
});
|
|
61
|
-
it('should parse plural translations', () => {
|
|
62
|
-
expect((0, i18NextParser_1.parse)('(1)[one item];(2-7)[a few items];(7-inf)[a lot of items];')).toEqual([
|
|
63
|
-
{
|
|
64
|
-
type: 'plural',
|
|
65
|
-
raw: '(1)',
|
|
66
|
-
prefix: '(',
|
|
67
|
-
suffix: ')',
|
|
68
|
-
content: '1',
|
|
69
|
-
variable: '1',
|
|
70
|
-
},
|
|
71
|
-
{ type: 'text', content: '[one item];' },
|
|
72
|
-
{
|
|
73
|
-
type: 'plural',
|
|
74
|
-
raw: '(2-7)',
|
|
75
|
-
prefix: '(',
|
|
76
|
-
suffix: ')',
|
|
77
|
-
content: '2-7',
|
|
78
|
-
variable: '2-7',
|
|
79
|
-
},
|
|
80
|
-
{ type: 'text', content: '[a few items];' },
|
|
81
|
-
{
|
|
82
|
-
type: 'plural',
|
|
83
|
-
raw: '(7-inf)',
|
|
84
|
-
prefix: '(',
|
|
85
|
-
suffix: ')',
|
|
86
|
-
content: '7-inf',
|
|
87
|
-
variable: '7-inf',
|
|
88
|
-
},
|
|
89
|
-
{ type: 'text', content: '[a lot of items];' },
|
|
90
|
-
]);
|
|
91
|
-
});
|
|
92
|
-
it('should not parse plural translations if regular text inside parenthesis', () => {
|
|
93
|
-
expect((0, i18NextParser_1.parse)('(This is a regular text inside parenthesis)')).toEqual([
|
|
94
|
-
{ type: 'text', content: '(This is a regular text inside parenthesis)' },
|
|
95
|
-
]);
|
|
96
|
-
});
|
|
97
|
-
it('should parse translations with nesting', () => {
|
|
98
|
-
expect((0, i18NextParser_1.parse)('1 $t(nesting2)')).toEqual([
|
|
99
|
-
{
|
|
100
|
-
type: 'text',
|
|
101
|
-
content: '1 ',
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
type: 'nesting',
|
|
105
|
-
raw: '$t(nesting2)',
|
|
106
|
-
prefix: '$t(',
|
|
107
|
-
suffix: ')',
|
|
108
|
-
content: 'nesting2',
|
|
109
|
-
variable: 'nesting2',
|
|
110
|
-
},
|
|
111
|
-
]);
|
|
112
|
-
});
|
|
113
|
-
it('should parse translations with tags', () => {
|
|
114
|
-
expect((0, i18NextParser_1.parse)('This is some <b>bold text</b> and some <i>italic</i> text.')).toEqual([
|
|
115
|
-
{ type: 'text', content: 'This is some ' },
|
|
116
|
-
{ type: 'tag', raw: '<b>', voidElement: false },
|
|
117
|
-
{ type: 'text', content: 'bold text' },
|
|
118
|
-
{ type: 'tag', raw: '</b>', voidElement: false },
|
|
119
|
-
{ type: 'text', content: ' and some ' },
|
|
120
|
-
{ type: 'tag', raw: '<i>', voidElement: false },
|
|
121
|
-
{ type: 'text', content: 'italic' },
|
|
122
|
-
{ type: 'tag', raw: '</i>', voidElement: false },
|
|
123
|
-
{ type: 'text', content: ' text.' },
|
|
124
|
-
]);
|
|
125
|
-
});
|
|
126
|
-
it('should parse translations with nested tags', () => {
|
|
127
|
-
expect((0, i18NextParser_1.parse)('This is some <b>bold text and some <i>nested italic</i> text</b>!')).toEqual([
|
|
128
|
-
{ type: 'text', content: 'This is some ' },
|
|
129
|
-
{ type: 'tag', raw: '<b>', voidElement: false },
|
|
130
|
-
{ type: 'text', content: 'bold text and some ' },
|
|
131
|
-
{ type: 'tag', raw: '<i>', voidElement: false },
|
|
132
|
-
{ type: 'text', content: 'nested italic' },
|
|
133
|
-
{ type: 'tag', raw: '</i>', voidElement: false },
|
|
134
|
-
{ type: 'text', content: ' text' },
|
|
135
|
-
{ type: 'tag', raw: '</b>', voidElement: false },
|
|
136
|
-
{ type: 'text', content: '!' },
|
|
137
|
-
]);
|
|
138
|
-
});
|
|
139
|
-
it('should parse translations with self closing tags', () => {
|
|
140
|
-
expect((0, i18NextParser_1.parse)('This is some <b>bold text and some </b> and some random self closing tag <img /> as well.')).toEqual([
|
|
141
|
-
{ type: 'text', content: 'This is some ' },
|
|
142
|
-
{ type: 'tag', raw: '<b>', voidElement: false },
|
|
143
|
-
{ type: 'text', content: 'bold text and some ' },
|
|
144
|
-
{ type: 'tag', raw: '</b>', voidElement: false },
|
|
145
|
-
{ type: 'text', content: ' and some random self closing tag ' },
|
|
146
|
-
{ type: 'tag', raw: '<img />', voidElement: true },
|
|
147
|
-
{ type: 'text', content: ' as well.' },
|
|
148
|
-
]);
|
|
149
|
-
});
|
|
150
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|