@lingual/i18n-check 0.8.2 → 0.8.3
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 +10 -18
- package/dist/bin/index.js +58 -57
- package/dist/bin/index.test.js +289 -289
- package/dist/errorReporters.d.ts +1 -1
- package/dist/errorReporters.js +21 -21
- package/dist/errorReporters.test.js +39 -39
- package/dist/index.d.ts +3 -3
- package/dist/index.js +59 -42
- package/dist/utils/findInvalidTranslations.d.ts +2 -2
- package/dist/utils/findInvalidTranslations.js +20 -19
- package/dist/utils/findInvalidTranslations.test.js +30 -30
- package/dist/utils/findInvalidi18nTranslations.d.ts +2 -2
- package/dist/utils/findInvalidi18nTranslations.js +35 -35
- package/dist/utils/findInvalidi18nTranslations.test.js +72 -72
- package/dist/utils/findMissingKeys.d.ts +1 -1
- package/dist/utils/findMissingKeys.js +2 -2
- package/dist/utils/findMissingKeys.test.js +20 -20
- package/dist/utils/flattenTranslations.d.ts +1 -1
- package/dist/utils/flattenTranslations.js +3 -3
- package/dist/utils/flattenTranslations.test.js +13 -13
- package/dist/utils/i18NextParser.d.ts +6 -6
- package/dist/utils/i18NextParser.js +29 -29
- package/dist/utils/i18NextParser.test.js +104 -104
- package/dist/utils/nextIntlSrcParser.js +11 -11
- package/dist/utils/nextIntlSrcParser.test.js +156 -156
- package/package.json +14 -4
|
@@ -2,40 +2,40 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const findMissingKeys_1 = require("./findMissingKeys");
|
|
4
4
|
const sourceFile = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
'one.two.three': 'one two three',
|
|
6
|
+
'four.five.six': 'four five six',
|
|
7
|
+
'seven.eight.nine': 'seven eight nine',
|
|
8
8
|
};
|
|
9
9
|
const secondaryFile = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
'one.two.three': 'one two three',
|
|
11
|
+
'four.five.six': 'four five six',
|
|
12
|
+
'seven.eight.nine': 'seven eight nine',
|
|
13
13
|
};
|
|
14
|
-
describe(
|
|
15
|
-
it(
|
|
14
|
+
describe('findMissingKeys:compareTranslationFiles', () => {
|
|
15
|
+
it('should return empty array if files are identical', () => {
|
|
16
16
|
expect((0, findMissingKeys_1.compareTranslationFiles)(sourceFile, secondaryFile)).toEqual([]);
|
|
17
17
|
});
|
|
18
|
-
it(
|
|
19
|
-
expect((0, findMissingKeys_1.compareTranslationFiles)({ ...sourceFile,
|
|
18
|
+
it('should return the missing keys in the secondary file', () => {
|
|
19
|
+
expect((0, findMissingKeys_1.compareTranslationFiles)({ ...sourceFile, 'ten.eleven.twelve': 'ten eleven twelve' }, secondaryFile)).toEqual(['ten.eleven.twelve']);
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
|
-
describe(
|
|
23
|
-
it(
|
|
22
|
+
describe('findMissingKeys', () => {
|
|
23
|
+
it('should return an empty object if all files have no missing keys', () => {
|
|
24
24
|
expect((0, findMissingKeys_1.findMissingKeys)(sourceFile, { de: secondaryFile })).toEqual({});
|
|
25
25
|
});
|
|
26
|
-
it(
|
|
27
|
-
expect((0, findMissingKeys_1.findMissingKeys)({ ...sourceFile,
|
|
26
|
+
it('should return an object containing the keys for the missing language', () => {
|
|
27
|
+
expect((0, findMissingKeys_1.findMissingKeys)({ ...sourceFile, 'ten.eleven.twelve': 'ten eleven twelve' }, { de: secondaryFile })).toEqual({ de: ['ten.eleven.twelve'] });
|
|
28
28
|
});
|
|
29
|
-
it(
|
|
30
|
-
expect((0, findMissingKeys_1.findMissingKeys)({ ...sourceFile,
|
|
29
|
+
it('should return an object containing the keys for every language with missing key', () => {
|
|
30
|
+
expect((0, findMissingKeys_1.findMissingKeys)({ ...sourceFile, 'ten.eleven.twelve': 'ten eleven twelve' }, {
|
|
31
31
|
de: secondaryFile,
|
|
32
32
|
fr: {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
'four.five.six': 'four five six',
|
|
34
|
+
'seven.eight.nine': 'seven eight nine',
|
|
35
35
|
},
|
|
36
36
|
})).toEqual({
|
|
37
|
-
de: [
|
|
38
|
-
fr: [
|
|
37
|
+
de: ['ten.eleven.twelve'],
|
|
38
|
+
fr: ['one.two.three', 'ten.eleven.twelve'],
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
});
|
|
@@ -12,10 +12,10 @@ exports.flattenTranslations = flattenTranslations;
|
|
|
12
12
|
* Top level search for any objects
|
|
13
13
|
*/
|
|
14
14
|
const hasNestedDefinitions = (translations) => {
|
|
15
|
-
return Object.values(translations).find((translation) => typeof translation ===
|
|
15
|
+
return Object.values(translations).find((translation) => typeof translation === 'object');
|
|
16
16
|
};
|
|
17
17
|
const isTranslationObject = (entry) => {
|
|
18
|
-
return typeof entry ===
|
|
18
|
+
return typeof entry === 'object';
|
|
19
19
|
};
|
|
20
20
|
const flattenEntry = (entry, keys = []) => {
|
|
21
21
|
const result = {};
|
|
@@ -26,7 +26,7 @@ const flattenEntry = (entry, keys = []) => {
|
|
|
26
26
|
for (const [k, v] of entries) {
|
|
27
27
|
Object.assign(result, isTranslationObject(v)
|
|
28
28
|
? (0, exports.flattenEntry)(v, [...keys, String(k)])
|
|
29
|
-
: { [[...keys, String(k)].join(
|
|
29
|
+
: { [[...keys, String(k)].join('.')]: v });
|
|
30
30
|
}
|
|
31
31
|
return result;
|
|
32
32
|
};
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const flattenTranslations_1 = require("./flattenTranslations");
|
|
4
|
-
const flatStructure = require(
|
|
5
|
-
const nestedStructure = require(
|
|
4
|
+
const flatStructure = require('../../translations/en-us.json');
|
|
5
|
+
const nestedStructure = require('../../translations/flattenExamples/en-us.json');
|
|
6
6
|
const expectedFlatStructure = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
'test.drive.one': 'testing one',
|
|
8
|
+
'test.drive.two': 'testing two',
|
|
9
|
+
'other.nested.three': 'testing three',
|
|
10
|
+
'other.nested.deep.more.final': 'nested translation',
|
|
11
11
|
};
|
|
12
|
-
describe(
|
|
13
|
-
it(
|
|
12
|
+
describe('flattenTranslations', () => {
|
|
13
|
+
it('should do nothing if the file structure is flat', () => {
|
|
14
14
|
expect((0, flattenTranslations_1.flattenTranslations)(flatStructure)).toEqual(flatStructure);
|
|
15
15
|
});
|
|
16
|
-
describe(
|
|
17
|
-
it(
|
|
16
|
+
describe('flattenEntry', () => {
|
|
17
|
+
it('should flatten a nested object', () => {
|
|
18
18
|
expect((0, flattenTranslations_1.flattenEntry)({
|
|
19
19
|
a: {
|
|
20
|
-
b: { c:
|
|
20
|
+
b: { c: 'one' },
|
|
21
21
|
},
|
|
22
|
-
})).toEqual({
|
|
22
|
+
})).toEqual({ 'a.b.c': 'one' });
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
|
-
it(
|
|
25
|
+
it('should do nothing if the file structure is flat', () => {
|
|
26
26
|
expect((0, flattenTranslations_1.flattenTranslations)(nestedStructure)).toEqual(expectedFlatStructure);
|
|
27
27
|
});
|
|
28
28
|
});
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
export type MessageFormatElement = {
|
|
2
|
-
type:
|
|
2
|
+
type: 'text';
|
|
3
3
|
content: string;
|
|
4
4
|
} | {
|
|
5
|
-
type:
|
|
5
|
+
type: 'interpolation';
|
|
6
6
|
raw: string;
|
|
7
7
|
prefix: string;
|
|
8
8
|
suffix: string;
|
|
9
9
|
content: string;
|
|
10
10
|
variable: string;
|
|
11
11
|
} | {
|
|
12
|
-
type:
|
|
12
|
+
type: 'interpolation_unescaped';
|
|
13
13
|
raw: string;
|
|
14
14
|
prefix: string;
|
|
15
15
|
suffix: string;
|
|
16
16
|
content: string;
|
|
17
17
|
variable: string;
|
|
18
18
|
} | {
|
|
19
|
-
type:
|
|
19
|
+
type: 'nesting';
|
|
20
20
|
raw: string;
|
|
21
21
|
prefix: string;
|
|
22
22
|
suffix: string;
|
|
23
23
|
content: string;
|
|
24
24
|
variable: string;
|
|
25
25
|
} | {
|
|
26
|
-
type:
|
|
26
|
+
type: 'plural';
|
|
27
27
|
raw: string;
|
|
28
28
|
prefix: string;
|
|
29
29
|
suffix: string;
|
|
30
30
|
content: string;
|
|
31
31
|
variable: string;
|
|
32
32
|
} | {
|
|
33
|
-
type:
|
|
33
|
+
type: 'tag';
|
|
34
34
|
raw: string;
|
|
35
35
|
voidElement: boolean;
|
|
36
36
|
};
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// Based on https://github.com/i18next/i18next-translation-parser/blob/v1.0.0/src/parse.js
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.parse = void 0;
|
|
5
|
-
const REGEXP = new RegExp(
|
|
6
|
-
const DOUBLE_BRACE =
|
|
7
|
-
const $_T_BRACE =
|
|
8
|
-
const $_T_PARENTHESIS =
|
|
9
|
-
const OPEN_PARENTHESIS =
|
|
10
|
-
const OPEN_TAG =
|
|
11
|
-
const CLOSE_TAG =
|
|
5
|
+
const REGEXP = new RegExp('({{[^}]+}}|\\$t{[^}]+}|\\$t\\([^\\)]+\\)|\\([0-9\\-inf]+\\)(?=\\[)|<[^>]+>)', 'g');
|
|
6
|
+
const DOUBLE_BRACE = '{{';
|
|
7
|
+
const $_T_BRACE = '$t{';
|
|
8
|
+
const $_T_PARENTHESIS = '$t(';
|
|
9
|
+
const OPEN_PARENTHESIS = '(';
|
|
10
|
+
const OPEN_TAG = '<';
|
|
11
|
+
const CLOSE_TAG = '</';
|
|
12
12
|
const parse = (input) => {
|
|
13
13
|
let ast = [];
|
|
14
14
|
ast = parseInput([input]);
|
|
@@ -21,15 +21,15 @@ const parseInput = (input) => {
|
|
|
21
21
|
}
|
|
22
22
|
let ast = [];
|
|
23
23
|
input.forEach((element) => {
|
|
24
|
-
const elements = element.split(REGEXP).filter((element) => element !==
|
|
24
|
+
const elements = element.split(REGEXP).filter((element) => element !== '');
|
|
25
25
|
const result = elements.reduce((acc, match) => {
|
|
26
|
-
if (match.indexOf(
|
|
26
|
+
if (match.indexOf('{{-') === 0) {
|
|
27
27
|
const content = match.substring(3, match.length - 2);
|
|
28
28
|
acc.push({
|
|
29
|
-
type:
|
|
29
|
+
type: 'interpolation_unescaped',
|
|
30
30
|
raw: match,
|
|
31
|
-
prefix:
|
|
32
|
-
suffix:
|
|
31
|
+
prefix: '{{-',
|
|
32
|
+
suffix: '}}',
|
|
33
33
|
content,
|
|
34
34
|
variable: content.trim(),
|
|
35
35
|
});
|
|
@@ -37,10 +37,10 @@ const parseInput = (input) => {
|
|
|
37
37
|
else if (match.indexOf(DOUBLE_BRACE) === 0) {
|
|
38
38
|
const content = match.substring(2, match.length - 2);
|
|
39
39
|
acc.push({
|
|
40
|
-
type:
|
|
40
|
+
type: 'interpolation',
|
|
41
41
|
raw: match,
|
|
42
|
-
prefix:
|
|
43
|
-
suffix:
|
|
42
|
+
prefix: '{{',
|
|
43
|
+
suffix: '}}',
|
|
44
44
|
content,
|
|
45
45
|
variable: content.trim(),
|
|
46
46
|
});
|
|
@@ -48,10 +48,10 @@ const parseInput = (input) => {
|
|
|
48
48
|
else if (match.indexOf($_T_BRACE) === 0) {
|
|
49
49
|
const content = match.substring(3, match.length - 1);
|
|
50
50
|
acc.push({
|
|
51
|
-
type:
|
|
51
|
+
type: 'nesting',
|
|
52
52
|
raw: match,
|
|
53
|
-
prefix:
|
|
54
|
-
suffix:
|
|
53
|
+
prefix: '$t{',
|
|
54
|
+
suffix: '}',
|
|
55
55
|
content,
|
|
56
56
|
variable: content.trim(),
|
|
57
57
|
});
|
|
@@ -59,10 +59,10 @@ const parseInput = (input) => {
|
|
|
59
59
|
else if (match.indexOf($_T_PARENTHESIS) === 0) {
|
|
60
60
|
const content = match.substring(3, match.length - 1);
|
|
61
61
|
acc.push({
|
|
62
|
-
type:
|
|
62
|
+
type: 'nesting',
|
|
63
63
|
raw: match,
|
|
64
|
-
prefix:
|
|
65
|
-
suffix:
|
|
64
|
+
prefix: '$t(',
|
|
65
|
+
suffix: ')',
|
|
66
66
|
content,
|
|
67
67
|
variable: content.trim(),
|
|
68
68
|
});
|
|
@@ -71,30 +71,30 @@ const parseInput = (input) => {
|
|
|
71
71
|
/\([0-9\-inf]+\)/.test(match)) {
|
|
72
72
|
const content = match.substring(1, match.length - 1);
|
|
73
73
|
acc.push({
|
|
74
|
-
type:
|
|
74
|
+
type: 'plural',
|
|
75
75
|
raw: match,
|
|
76
|
-
prefix:
|
|
77
|
-
suffix:
|
|
76
|
+
prefix: '(',
|
|
77
|
+
suffix: ')',
|
|
78
78
|
content,
|
|
79
79
|
variable: content.trim(),
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
else if (match.indexOf(CLOSE_TAG) === 0) {
|
|
83
83
|
acc.push({
|
|
84
|
-
type:
|
|
84
|
+
type: 'tag',
|
|
85
85
|
raw: match,
|
|
86
|
-
voidElement: match.substring(match.length - 2) ===
|
|
86
|
+
voidElement: match.substring(match.length - 2) === '/>',
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
else if (match.indexOf(OPEN_TAG) === 0 && /<[^\s]+/.test(match)) {
|
|
90
90
|
acc.push({
|
|
91
|
-
type:
|
|
91
|
+
type: 'tag',
|
|
92
92
|
raw: match,
|
|
93
|
-
voidElement: match.substring(match.length - 2) ===
|
|
93
|
+
voidElement: match.substring(match.length - 2) === '/>',
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
97
|
-
acc.push({ type:
|
|
97
|
+
acc.push({ type: 'text', content: match });
|
|
98
98
|
}
|
|
99
99
|
return acc;
|
|
100
100
|
}, []);
|
|
@@ -1,150 +1,150 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const i18NextParser_1 = require("./i18NextParser");
|
|
4
|
-
describe(
|
|
5
|
-
it(
|
|
6
|
-
expect((0, i18NextParser_1.parse)(
|
|
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
7
|
{
|
|
8
|
-
type:
|
|
9
|
-
content:
|
|
8
|
+
type: 'text',
|
|
9
|
+
content: 'test ',
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
|
-
type:
|
|
13
|
-
raw:
|
|
14
|
-
prefix:
|
|
15
|
-
suffix:
|
|
16
|
-
content:
|
|
17
|
-
variable:
|
|
12
|
+
type: 'interpolation',
|
|
13
|
+
raw: '{{val}}',
|
|
14
|
+
prefix: '{{',
|
|
15
|
+
suffix: '}}',
|
|
16
|
+
content: 'val',
|
|
17
|
+
variable: 'val',
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
|
-
type:
|
|
21
|
-
content:
|
|
20
|
+
type: 'text',
|
|
21
|
+
content: ' text ',
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
type:
|
|
25
|
-
raw:
|
|
26
|
-
prefix:
|
|
27
|
-
suffix:
|
|
28
|
-
content:
|
|
29
|
-
variable:
|
|
24
|
+
type: 'interpolation_unescaped',
|
|
25
|
+
raw: '{{- encoded}}',
|
|
26
|
+
prefix: '{{-',
|
|
27
|
+
suffix: '}}',
|
|
28
|
+
content: ' encoded',
|
|
29
|
+
variable: 'encoded',
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
|
-
type:
|
|
33
|
-
content:
|
|
32
|
+
type: 'text',
|
|
33
|
+
content: ' with ',
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
|
-
type:
|
|
37
|
-
raw:
|
|
38
|
-
prefix:
|
|
39
|
-
suffix:
|
|
40
|
-
content:
|
|
41
|
-
variable:
|
|
36
|
+
type: 'interpolation',
|
|
37
|
+
raw: '{{val, format}}',
|
|
38
|
+
prefix: '{{',
|
|
39
|
+
suffix: '}}',
|
|
40
|
+
content: 'val, format',
|
|
41
|
+
variable: 'val, format',
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
|
-
type:
|
|
45
|
-
content:
|
|
44
|
+
type: 'text',
|
|
45
|
+
content: ' some ',
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
|
-
type:
|
|
49
|
-
raw:
|
|
50
|
-
prefix:
|
|
51
|
-
suffix:
|
|
52
|
-
content:
|
|
53
|
-
variable:
|
|
48
|
+
type: 'nesting',
|
|
49
|
+
raw: '$t{nesting}',
|
|
50
|
+
prefix: '$t{',
|
|
51
|
+
suffix: '}',
|
|
52
|
+
content: 'nesting',
|
|
53
|
+
variable: 'nesting',
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
|
-
type:
|
|
57
|
-
content:
|
|
56
|
+
type: 'text',
|
|
57
|
+
content: ' help',
|
|
58
58
|
},
|
|
59
59
|
]);
|
|
60
60
|
});
|
|
61
|
-
it(
|
|
62
|
-
expect((0, i18NextParser_1.parse)(
|
|
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
63
|
{
|
|
64
|
-
type:
|
|
65
|
-
raw:
|
|
66
|
-
prefix:
|
|
67
|
-
suffix:
|
|
68
|
-
content:
|
|
69
|
-
variable:
|
|
64
|
+
type: 'plural',
|
|
65
|
+
raw: '(1)',
|
|
66
|
+
prefix: '(',
|
|
67
|
+
suffix: ')',
|
|
68
|
+
content: '1',
|
|
69
|
+
variable: '1',
|
|
70
70
|
},
|
|
71
|
-
{ type:
|
|
71
|
+
{ type: 'text', content: '[one item];' },
|
|
72
72
|
{
|
|
73
|
-
type:
|
|
74
|
-
raw:
|
|
75
|
-
prefix:
|
|
76
|
-
suffix:
|
|
77
|
-
content:
|
|
78
|
-
variable:
|
|
73
|
+
type: 'plural',
|
|
74
|
+
raw: '(2-7)',
|
|
75
|
+
prefix: '(',
|
|
76
|
+
suffix: ')',
|
|
77
|
+
content: '2-7',
|
|
78
|
+
variable: '2-7',
|
|
79
79
|
},
|
|
80
|
-
{ type:
|
|
80
|
+
{ type: 'text', content: '[a few items];' },
|
|
81
81
|
{
|
|
82
|
-
type:
|
|
83
|
-
raw:
|
|
84
|
-
prefix:
|
|
85
|
-
suffix:
|
|
86
|
-
content:
|
|
87
|
-
variable:
|
|
82
|
+
type: 'plural',
|
|
83
|
+
raw: '(7-inf)',
|
|
84
|
+
prefix: '(',
|
|
85
|
+
suffix: ')',
|
|
86
|
+
content: '7-inf',
|
|
87
|
+
variable: '7-inf',
|
|
88
88
|
},
|
|
89
|
-
{ type:
|
|
89
|
+
{ type: 'text', content: '[a lot of items];' },
|
|
90
90
|
]);
|
|
91
91
|
});
|
|
92
|
-
it(
|
|
93
|
-
expect((0, i18NextParser_1.parse)(
|
|
94
|
-
{ type:
|
|
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
95
|
]);
|
|
96
96
|
});
|
|
97
|
-
it(
|
|
98
|
-
expect((0, i18NextParser_1.parse)(
|
|
97
|
+
it('should parse translations with nesting', () => {
|
|
98
|
+
expect((0, i18NextParser_1.parse)('1 $t(nesting2)')).toEqual([
|
|
99
99
|
{
|
|
100
|
-
type:
|
|
101
|
-
content:
|
|
100
|
+
type: 'text',
|
|
101
|
+
content: '1 ',
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
|
-
type:
|
|
105
|
-
raw:
|
|
106
|
-
prefix:
|
|
107
|
-
suffix:
|
|
108
|
-
content:
|
|
109
|
-
variable:
|
|
104
|
+
type: 'nesting',
|
|
105
|
+
raw: '$t(nesting2)',
|
|
106
|
+
prefix: '$t(',
|
|
107
|
+
suffix: ')',
|
|
108
|
+
content: 'nesting2',
|
|
109
|
+
variable: 'nesting2',
|
|
110
110
|
},
|
|
111
111
|
]);
|
|
112
112
|
});
|
|
113
|
-
it(
|
|
114
|
-
expect((0, i18NextParser_1.parse)(
|
|
115
|
-
{ type:
|
|
116
|
-
{ type:
|
|
117
|
-
{ type:
|
|
118
|
-
{ type:
|
|
119
|
-
{ type:
|
|
120
|
-
{ type:
|
|
121
|
-
{ type:
|
|
122
|
-
{ type:
|
|
123
|
-
{ type:
|
|
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
124
|
]);
|
|
125
125
|
});
|
|
126
|
-
it(
|
|
127
|
-
expect((0, i18NextParser_1.parse)(
|
|
128
|
-
{ type:
|
|
129
|
-
{ type:
|
|
130
|
-
{ type:
|
|
131
|
-
{ type:
|
|
132
|
-
{ type:
|
|
133
|
-
{ type:
|
|
134
|
-
{ type:
|
|
135
|
-
{ type:
|
|
136
|
-
{ type:
|
|
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
137
|
]);
|
|
138
138
|
});
|
|
139
|
-
it(
|
|
140
|
-
expect((0, i18NextParser_1.parse)(
|
|
141
|
-
{ type:
|
|
142
|
-
{ type:
|
|
143
|
-
{ type:
|
|
144
|
-
{ type:
|
|
145
|
-
{ type:
|
|
146
|
-
{ type:
|
|
147
|
-
{ type:
|
|
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
148
|
]);
|
|
149
149
|
});
|
|
150
150
|
});
|