/
i18n.js
75 lines (68 loc) · 2.92 KB
/
i18n.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import i18n from 'i18next';
// set instance on hooks stuff
import { setI18n } from '../src/context';
setI18n(i18n);
i18n.init({
lng: 'en',
fallbackLng: 'en',
resources: {
en: {
translation: {
key1: 'test',
interpolateKey: 'add {{insert}} {{up, uppercase}}',
interpolateKey2: '<strong>add</strong> {{insert}} {{up, uppercase}}',
transTest1: 'Go <1>there</1>.',
transTest1_noParent: '<0>Go <1>there</1>.</0>',
transTest1_customHtml: '<strong>Go</strong> <br/><1>there</1>.',
transTest1_customHtml2: '<strong>Go</strong> <br/> there.',
transTest1_customHtml3:
'<strong>Go</strong><video /><script>console.warn("test")</script> there.',
transTest2:
'Hello <1><0>{{name}}</0></1>, you have <3>{{count}}</3> message. Open <5>hear</5>.',
transTest2_other:
'Hello <1><0>{{name}}</0></1>, you have <3>{{count}}</3> messages. Open <5>here</5>.',
transTest2InV2: 'Hello <1>{{name}}</1>, you have {{count}} message. Open <5>hear</5>.',
transTest2InV2_other:
'Hello <1>{{name}}</1>, you have {{count}} messages. Open <5>here</5>.',
testTransKey1: '<0>{{numOfItems}}</0> item matched.',
testTransKey1_other: '<0>{{numOfItems}}</0> items matched.',
testTransKey2: '<0><0>{{numOfItems}}</0></0> item matched.',
testTransKey2_other: '<0><0>{{numOfItems}}</0></0> items matched.',
testTransKey3: 'Result: <1><0>{{numOfItems}}</0></1> item matched.',
testTransKey3_other: 'Result: <1><0>{{numOfItems}}</0></1> items matched.',
testInvalidHtml: '<hello',
testInvalidHtml2: '<hello>',
testTrans4KeyWithNestedComponent: 'Result should be a list: <0></0>',
testTrans5KeyWithNestedComponent: 'Result should be a list: <1></1>',
testTrans5KeyWithValue: 'Result should be rendered within tag <0>{{testValue}}</0>',
transTest3: 'Result should be a clickable link <0 href="https://www.google.com">Google</0>',
transTest3_overwrite:
'Result should be a clickable link <0 href="https://www.google.com">Google</0>',
transTestEscapedHtml: 'Escaped html should unescape correctly <0>< &></0>.',
transTestCustomUnescape: 'Text should be passed through custom unescape <0>­</0>',
testTransWithCtx: 'Go <1>there</1>.',
testTransWithCtx_home: 'Go <1>home</1>.',
deepPath: {
deepKey1: 'value1',
},
},
other: {
transTest1: 'Another go <1>there</1>.',
},
},
},
interpolation: {
escapeValue: false, // not needed for react!!
formatSeparator: ',',
format(value, format) {
if (format === 'uppercase') return value.toUpperCase();
return value;
},
},
react: {
defaultTransParent: 'div',
transSupportBasicHtmlNodes: true,
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i'],
},
});
export default i18n;