@pie-lib/translator 2.38.0-mui-update.0 → 3.0.0-next.0
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/CHANGELOG.md +8 -101
- package/lib/en.js +1 -1
- package/lib/en.js.map +1 -1
- package/package.json +10 -2
- package/src/__tests__/index.test.js +278 -0
- package/src/en.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
# [
|
|
6
|
+
# [3.0.0-next.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.23.2-next.0...@pie-lib/translator@3.0.0-next.0) (2026-01-19)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @pie-lib/translator
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
## [2.23.2-next.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.38.0-mui-update.0...@pie-lib/translator@2.23.2-next.0) (2026-01-19)
|
|
15
15
|
|
|
16
16
|
**Note:** Version bump only for package @pie-lib/translator
|
|
17
17
|
|
|
@@ -19,168 +19,75 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
# [2.36.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.35.0-mui-update.0...@pie-lib/translator@2.36.0-mui-update.0) (2025-12-17)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @pie-lib/translator
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# [2.35.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.34.0-mui-update.0...@pie-lib/translator@2.35.0-mui-update.0) (2025-12-17)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @pie-lib/translator
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# [2.34.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.33.0-mui-update.0...@pie-lib/translator@2.34.0-mui-update.0) (2025-12-11)
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @pie-lib/translator
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
# [2.33.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.32.0-mui-update.0...@pie-lib/translator@2.33.0-mui-update.0) (2025-12-02)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
### Features
|
|
50
|
-
|
|
51
|
-
* sync latest changes from dev ([c936e9c](https://github.com/pie-framework/pie-lib/commit/c936e9c7f9e095e7d9b9805ac2bf72bd271e05f1))
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
22
|
## [2.23.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.19.0...@pie-lib/translator@2.23.1) (2025-10-22)
|
|
58
23
|
|
|
59
24
|
**Note:** Version bump only for package @pie-lib/translator
|
|
60
25
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
26
|
# [2.23.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.19.0...@pie-lib/translator@2.23.0) (2025-10-16)
|
|
66
27
|
|
|
67
28
|
**Note:** Version bump only for package @pie-lib/translator
|
|
68
29
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
30
|
# [2.22.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.19.0...@pie-lib/translator@2.22.0) (2025-10-16)
|
|
74
31
|
|
|
75
32
|
**Note:** Version bump only for package @pie-lib/translator
|
|
76
33
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
34
|
# [2.21.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.19.0...@pie-lib/translator@2.21.0) (2025-10-16)
|
|
82
35
|
|
|
83
36
|
**Note:** Version bump only for package @pie-lib/translator
|
|
84
37
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
38
|
# [2.20.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.19.0...@pie-lib/translator@2.20.0) (2025-10-16)
|
|
90
39
|
|
|
91
40
|
**Note:** Version bump only for package @pie-lib/translator
|
|
92
41
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
42
|
# [2.19.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.3.0...@pie-lib/translator@2.19.0) (2025-09-25)
|
|
98
43
|
|
|
99
|
-
|
|
100
44
|
### Bug Fixes
|
|
101
45
|
|
|
102
|
-
|
|
103
|
-
|
|
46
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
104
47
|
|
|
105
48
|
### Features
|
|
106
49
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
50
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
112
51
|
|
|
113
52
|
# [2.18.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.17.0...@pie-lib/translator@2.18.0) (2025-09-18)
|
|
114
53
|
|
|
115
54
|
**Note:** Version bump only for package @pie-lib/translator
|
|
116
55
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
56
|
# [2.17.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.16.0...@pie-lib/translator@2.17.0) (2025-09-18)
|
|
122
57
|
|
|
123
58
|
**Note:** Version bump only for package @pie-lib/translator
|
|
124
59
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
60
|
# [2.16.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.3.0...@pie-lib/translator@2.16.0) (2025-09-18)
|
|
130
61
|
|
|
131
|
-
|
|
132
62
|
### Bug Fixes
|
|
133
63
|
|
|
134
|
-
|
|
135
|
-
|
|
64
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
136
65
|
|
|
137
66
|
### Features
|
|
138
67
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
68
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
144
69
|
|
|
145
70
|
# [2.15.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.14.0...@pie-lib/translator@2.15.0) (2025-09-17)
|
|
146
71
|
|
|
147
72
|
**Note:** Version bump only for package @pie-lib/translator
|
|
148
73
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
74
|
# [2.14.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.13.0...@pie-lib/translator@2.14.0) (2025-09-17)
|
|
154
75
|
|
|
155
76
|
**Note:** Version bump only for package @pie-lib/translator
|
|
156
77
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
78
|
# [2.13.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.12.1...@pie-lib/translator@2.13.0) (2025-09-17)
|
|
162
79
|
|
|
163
80
|
**Note:** Version bump only for package @pie-lib/translator
|
|
164
81
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
82
|
## [2.12.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.3.0...@pie-lib/translator@2.12.1) (2025-08-11)
|
|
170
83
|
|
|
171
|
-
|
|
172
84
|
### Bug Fixes
|
|
173
85
|
|
|
174
|
-
|
|
175
|
-
|
|
86
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
176
87
|
|
|
177
88
|
### Features
|
|
178
89
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
90
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
184
91
|
|
|
185
92
|
# [2.12.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/translator@2.3.0...@pie-lib/translator@2.12.0) (2025-08-07)
|
|
186
93
|
|
package/lib/en.js
CHANGED
|
@@ -7,7 +7,7 @@ exports["default"] = void 0;
|
|
|
7
7
|
var _default = exports["default"] = {
|
|
8
8
|
translation: {
|
|
9
9
|
categorize: {
|
|
10
|
-
limitMaxChoicesPerCategory:
|
|
10
|
+
limitMaxChoicesPerCategory: 'You\'ve reached the limit of {{maxChoicesPerCategory}} responses per area. To add another response, one must first be removed.',
|
|
11
11
|
maxChoicesPerCategoryRestriction: 'To change this value to {{maxChoicesPerCategory}}, each category must have {{maxChoicesPerCategory}} or fewer answer choice[s].'
|
|
12
12
|
},
|
|
13
13
|
ebsr: {
|
package/lib/en.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.js","names":["translation","categorize","limitMaxChoicesPerCategory","maxChoicesPerCategoryRestriction","ebsr","part","numberLine","addElementLimit_one","addElementLimit_other","clearAll","imageClozeAssociation","reachedLimit_one","reachedLimit_other","drawingResponse","fillColor","outlineColor","noFill","lightblue","lightyellow","red","orange","yellow","violet","blue","green","white","black","onDoubleClick","charting","addCategory","actions","add","newLabel","keyLegend","incorrectAnswer","correctAnswer","correctKeyAnswer","graphing","point","circle","line","parabola","absolute","exponential","polygon","ray","segment","sine","vector","label","redo","reset","mathInline","primaryCorrectWithAlternates","multipleChoice","minSelections","maxSelections_one","maxSelections_other","minmaxSelections_equal","minmaxSelections_range","selectText","correctAnswerSelected","correctAnswerNotSelected","incorrectSelection","key","common","undo","correct","incorrect","showCorrectAnswer","hideCorrectAnswer","commonCorrectAnswerWithAlternates","warning","showNote","hideNote","cancel"],"sources":["../src/en.js"],"sourcesContent":["export default {\n translation: {\n categorize: {\n limitMaxChoicesPerCategory:\n
|
|
1
|
+
{"version":3,"file":"en.js","names":["translation","categorize","limitMaxChoicesPerCategory","maxChoicesPerCategoryRestriction","ebsr","part","numberLine","addElementLimit_one","addElementLimit_other","clearAll","imageClozeAssociation","reachedLimit_one","reachedLimit_other","drawingResponse","fillColor","outlineColor","noFill","lightblue","lightyellow","red","orange","yellow","violet","blue","green","white","black","onDoubleClick","charting","addCategory","actions","add","newLabel","keyLegend","incorrectAnswer","correctAnswer","correctKeyAnswer","graphing","point","circle","line","parabola","absolute","exponential","polygon","ray","segment","sine","vector","label","redo","reset","mathInline","primaryCorrectWithAlternates","multipleChoice","minSelections","maxSelections_one","maxSelections_other","minmaxSelections_equal","minmaxSelections_range","selectText","correctAnswerSelected","correctAnswerNotSelected","incorrectSelection","key","common","undo","correct","incorrect","showCorrectAnswer","hideCorrectAnswer","commonCorrectAnswerWithAlternates","warning","showNote","hideNote","cancel"],"sources":["../src/en.js"],"sourcesContent":["export default {\n translation: {\n categorize: {\n limitMaxChoicesPerCategory:\n 'You\\'ve reached the limit of {{maxChoicesPerCategory}} responses per area. To add another response, one must first be removed.',\n maxChoicesPerCategoryRestriction:\n 'To change this value to {{maxChoicesPerCategory}}, each category must have {{maxChoicesPerCategory}} or fewer answer choice[s].',\n },\n ebsr: {\n part: 'Part {{index}}',\n },\n numberLine: {\n addElementLimit_one: 'You can only add {{count}} element',\n addElementLimit_other: 'You can only add {{count}} elements',\n clearAll: 'Clear all',\n },\n imageClozeAssociation: {\n reachedLimit_one:\n 'You’ve reached the limit of {{count}} response per area. To add another response, one must first be removed.',\n reachedLimit_other: 'Full',\n },\n drawingResponse: {\n fillColor: 'Fill color',\n outlineColor: 'Outline color',\n noFill: 'No fill',\n lightblue: 'Light blue',\n lightyellow: 'Light yellow',\n red: 'Red',\n orange: 'Orange',\n yellow: 'Yellow',\n violet: 'Violet',\n blue: 'Blue',\n green: 'Green',\n white: 'White',\n black: 'Black',\n onDoubleClick: 'Double click to edit this text. Press Enter to submit.',\n },\n charting: {\n addCategory: 'Add category',\n actions: 'Actions',\n add: 'Add',\n delete: 'Delete',\n newLabel: 'New label',\n reachedLimit_other: \"There can't be more than {{count}} categories.\",\n keyLegend: {\n incorrectAnswer: 'Student incorrect answer',\n correctAnswer: 'Student correct answer',\n correctKeyAnswer: 'Answer key correct',\n },\n },\n graphing: {\n point: 'Point',\n circle: 'Circle',\n line: 'Line',\n parabola: 'Parabola',\n absolute: 'Absolute Value',\n exponential: 'Exponential',\n polygon: 'Polygon',\n ray: 'Ray',\n segment: 'Segment',\n sine: 'Sine',\n vector: 'Vector',\n label: 'Label',\n redo: 'Redo',\n reset: 'Reset',\n },\n mathInline: {\n primaryCorrectWithAlternates:\n 'Note: The answer shown above is the primary correct answer specified by the author for this item, but other answers may also be recognized as correct.',\n },\n multipleChoice: {\n minSelections: 'Select at least {{minSelections}}.',\n maxSelections_one: 'Only {{maxSelections}} answer is allowed.',\n maxSelections_other: 'Only {{maxSelections}} answers are allowed.',\n minmaxSelections_equal: 'Select {{minSelections}}.',\n minmaxSelections_range: 'Select between {{minSelections}} and {{maxSelections}}.',\n },\n selectText: {\n correctAnswerSelected: 'Correct',\n correctAnswerNotSelected: 'Correct Answer Not Selected',\n incorrectSelection: 'Incorrect Selection',\n key: 'Key',\n },\n },\n common: {\n undo: 'Undo',\n clearAll: 'Clear all',\n correct: 'Correct',\n incorrect: 'Incorrect',\n showCorrectAnswer: 'Show correct answer',\n hideCorrectAnswer: 'Hide correct answer',\n commonCorrectAnswerWithAlternates:\n 'Note: The answer shown above is the most common correct answer for this item. One or more additional correct answers are also defined, and will also be recognized as correct.',\n warning: 'Warning',\n showNote: 'Show Note',\n hideNote: 'Hide Note',\n cancel: 'Cancel',\n },\n};\n"],"mappings":";;;;;;oCAAe;EACbA,WAAW,EAAE;IACXC,UAAU,EAAE;MACVC,0BAA0B,EACxB,gIAAgI;MAClIC,gCAAgC,EAC9B;IACJ,CAAC;IACDC,IAAI,EAAE;MACJC,IAAI,EAAE;IACR,CAAC;IACDC,UAAU,EAAE;MACVC,mBAAmB,EAAE,oCAAoC;MACzDC,qBAAqB,EAAE,qCAAqC;MAC5DC,QAAQ,EAAE;IACZ,CAAC;IACDC,qBAAqB,EAAE;MACrBC,gBAAgB,EACd,8GAA8G;MAChHC,kBAAkB,EAAE;IACtB,CAAC;IACDC,eAAe,EAAE;MACfC,SAAS,EAAE,YAAY;MACvBC,YAAY,EAAE,eAAe;MAC7BC,MAAM,EAAE,SAAS;MACjBC,SAAS,EAAE,YAAY;MACvBC,WAAW,EAAE,cAAc;MAC3BC,GAAG,EAAE,KAAK;MACVC,MAAM,EAAE,QAAQ;MAChBC,MAAM,EAAE,QAAQ;MAChBC,MAAM,EAAE,QAAQ;MAChBC,IAAI,EAAE,MAAM;MACZC,KAAK,EAAE,OAAO;MACdC,KAAK,EAAE,OAAO;MACdC,KAAK,EAAE,OAAO;MACdC,aAAa,EAAE;IACjB,CAAC;IACDC,QAAQ,EAAE;MACRC,WAAW,EAAE,cAAc;MAC3BC,OAAO,EAAE,SAAS;MAClBC,GAAG,EAAE,KAAK;MACV,UAAQ,QAAQ;MAChBC,QAAQ,EAAE,WAAW;MACrBpB,kBAAkB,EAAE,gDAAgD;MACpEqB,SAAS,EAAE;QACTC,eAAe,EAAE,0BAA0B;QAC3CC,aAAa,EAAE,wBAAwB;QACvCC,gBAAgB,EAAE;MACpB;IACF,CAAC;IACDC,QAAQ,EAAE;MACRC,KAAK,EAAE,OAAO;MACdC,MAAM,EAAE,QAAQ;MAChBC,IAAI,EAAE,MAAM;MACZC,QAAQ,EAAE,UAAU;MACpBC,QAAQ,EAAE,gBAAgB;MAC1BC,WAAW,EAAE,aAAa;MAC1BC,OAAO,EAAE,SAAS;MAClBC,GAAG,EAAE,KAAK;MACVC,OAAO,EAAE,SAAS;MAClBC,IAAI,EAAE,MAAM;MACZC,MAAM,EAAE,QAAQ;MAChBC,KAAK,EAAE,OAAO;MACdC,IAAI,EAAE,MAAM;MACZC,KAAK,EAAE;IACT,CAAC;IACDC,UAAU,EAAE;MACVC,4BAA4B,EAC1B;IACJ,CAAC;IACDC,cAAc,EAAE;MACdC,aAAa,EAAE,oCAAoC;MACnDC,iBAAiB,EAAE,2CAA2C;MAC9DC,mBAAmB,EAAE,6CAA6C;MAClEC,sBAAsB,EAAE,2BAA2B;MACnDC,sBAAsB,EAAE;IAC1B,CAAC;IACDC,UAAU,EAAE;MACVC,qBAAqB,EAAE,SAAS;MAChCC,wBAAwB,EAAE,6BAA6B;MACvDC,kBAAkB,EAAE,qBAAqB;MACzCC,GAAG,EAAE;IACP;EACF,CAAC;EACDC,MAAM,EAAE;IACNC,IAAI,EAAE,MAAM;IACZzD,QAAQ,EAAE,WAAW;IACrB0D,OAAO,EAAE,SAAS;IAClBC,SAAS,EAAE,WAAW;IACtBC,iBAAiB,EAAE,qBAAqB;IACxCC,iBAAiB,EAAE,qBAAqB;IACxCC,iCAAiC,EAC/B,gLAAgL;IAClLC,OAAO,EAAE,SAAS;IAClBC,QAAQ,EAAE,WAAW;IACrBC,QAAQ,EAAE,WAAW;IACrBC,MAAM,EAAE;EACV;AACF,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/translator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-next.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -18,5 +18,13 @@
|
|
|
18
18
|
"react": "18.2.0",
|
|
19
19
|
"react-dom": "18.2.0"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "e0f8f2250addd014938f4a631ab86cafe16b2730",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"require": "./lib/index.js",
|
|
25
|
+
"import": "./src/index.js",
|
|
26
|
+
"default": "./lib/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./esm": "./esm/index.js"
|
|
29
|
+
}
|
|
22
30
|
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import translatorExport from '../index';
|
|
5
|
+
|
|
6
|
+
describe('Translator', () => {
|
|
7
|
+
const { translator, languageOptions } = translatorExport;
|
|
8
|
+
|
|
9
|
+
describe('Initialization', () => {
|
|
10
|
+
it('should export translator object with i18next methods', () => {
|
|
11
|
+
expect(translator).toBeDefined();
|
|
12
|
+
expect(typeof translator.t).toBe('function');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should have default language set to English', () => {
|
|
16
|
+
expect(translator.language).toBe('en');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should export language options', () => {
|
|
20
|
+
expect(languageOptions).toBeDefined();
|
|
21
|
+
expect(Array.isArray(languageOptions)).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should have correct language options', () => {
|
|
25
|
+
expect(languageOptions).toEqual([
|
|
26
|
+
{ value: 'en_US', label: 'English (US)' },
|
|
27
|
+
{ value: 'es_ES', label: 'Spanish' },
|
|
28
|
+
]);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('Translation Function', () => {
|
|
33
|
+
it('should translate a key in English', () => {
|
|
34
|
+
const result = translator.t('categorize.limitMaxChoicesPerCategory', {
|
|
35
|
+
lng: 'en_US',
|
|
36
|
+
maxChoicesPerCategory: 5,
|
|
37
|
+
});
|
|
38
|
+
expect(result).toContain('5');
|
|
39
|
+
expect(result).toContain('responses per area');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should translate a key in Spanish', () => {
|
|
43
|
+
const result = translator.t('categorize.limitMaxChoicesPerCategory', {
|
|
44
|
+
lng: 'es_ES',
|
|
45
|
+
maxChoicesPerCategory: 5,
|
|
46
|
+
});
|
|
47
|
+
expect(result).toBeDefined();
|
|
48
|
+
expect(typeof result).toBe('string');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should handle en_US locale and convert it to en', () => {
|
|
52
|
+
const result = translator.t('categorize.limitMaxChoicesPerCategory', {
|
|
53
|
+
lng: 'en_US',
|
|
54
|
+
maxChoicesPerCategory: 5,
|
|
55
|
+
});
|
|
56
|
+
expect(result).toContain('5');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should handle en-US locale and convert it to en', () => {
|
|
60
|
+
const result = translator.t('categorize.limitMaxChoicesPerCategory', {
|
|
61
|
+
lng: 'en-US',
|
|
62
|
+
maxChoicesPerCategory: 5,
|
|
63
|
+
});
|
|
64
|
+
expect(result).toContain('5');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should handle es_ES locale and convert it to es', () => {
|
|
68
|
+
const result = translator.t('categorize.limitMaxChoicesPerCategory', {
|
|
69
|
+
lng: 'es_ES',
|
|
70
|
+
maxChoicesPerCategory: 5,
|
|
71
|
+
});
|
|
72
|
+
expect(result).toBeDefined();
|
|
73
|
+
expect(typeof result).toBe('string');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should handle es-ES locale and convert it to es', () => {
|
|
77
|
+
const result = translator.t('categorize.limitMaxChoicesPerCategory', {
|
|
78
|
+
lng: 'es-ES',
|
|
79
|
+
maxChoicesPerCategory: 5,
|
|
80
|
+
});
|
|
81
|
+
expect(result).toBeDefined();
|
|
82
|
+
expect(typeof result).toBe('string');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should handle es_MX locale and convert it to es', () => {
|
|
86
|
+
const result = translator.t('categorize.limitMaxChoicesPerCategory', {
|
|
87
|
+
lng: 'es_MX',
|
|
88
|
+
maxChoicesPerCategory: 5,
|
|
89
|
+
});
|
|
90
|
+
expect(result).toBeDefined();
|
|
91
|
+
expect(typeof result).toBe('string');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should handle es-MX locale and convert it to es', () => {
|
|
95
|
+
const result = translator.t('categorize.limitMaxChoicesPerCategory', {
|
|
96
|
+
lng: 'es-MX',
|
|
97
|
+
maxChoicesPerCategory: 5,
|
|
98
|
+
});
|
|
99
|
+
expect(result).toBeDefined();
|
|
100
|
+
expect(typeof result).toBe('string');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should translate pluralized keys correctly', () => {
|
|
104
|
+
const resultOne = translator.t('numberLine.addElementLimit', {
|
|
105
|
+
lng: 'en',
|
|
106
|
+
count: 1,
|
|
107
|
+
});
|
|
108
|
+
expect(resultOne).toContain('1');
|
|
109
|
+
expect(resultOne).toContain('element');
|
|
110
|
+
|
|
111
|
+
const resultMultiple = translator.t('numberLine.addElementLimit', {
|
|
112
|
+
lng: 'en',
|
|
113
|
+
count: 5,
|
|
114
|
+
});
|
|
115
|
+
expect(resultMultiple).toContain('5');
|
|
116
|
+
expect(resultMultiple).toContain('elements');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should handle nested translation keys', () => {
|
|
120
|
+
const result = translator.t('charting.keyLegend.correctAnswer', {
|
|
121
|
+
lng: 'en',
|
|
122
|
+
});
|
|
123
|
+
expect(result).toContain('correct answer');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should return the key when translation is not found', () => {
|
|
127
|
+
const result = translator.t('nonexistent.key', {
|
|
128
|
+
lng: 'en',
|
|
129
|
+
});
|
|
130
|
+
expect(result).toBeDefined();
|
|
131
|
+
// i18next returns the key itself when translation is not found
|
|
132
|
+
expect(typeof result).toBe('string');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('should support interpolation with multiple variables', () => {
|
|
136
|
+
const result = translator.t('categorize.maxChoicesPerCategoryRestriction', {
|
|
137
|
+
lng: 'en',
|
|
138
|
+
maxChoicesPerCategory: 10,
|
|
139
|
+
});
|
|
140
|
+
expect(result).toContain('10');
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe('i18next Methods', () => {
|
|
145
|
+
it('should have i18next methods available', () => {
|
|
146
|
+
expect(typeof translator.changeLanguage).toBe('function');
|
|
147
|
+
expect(typeof translator.getFixedT).toBe('function');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('should have resources defined', () => {
|
|
151
|
+
expect(translator.getResourceBundle).toBeDefined();
|
|
152
|
+
const enBundle = translator.getResourceBundle('en', 'translation');
|
|
153
|
+
expect(enBundle).toBeDefined();
|
|
154
|
+
expect(enBundle.categorize).toBeDefined();
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe('Translation Keys Coverage', () => {
|
|
159
|
+
it('should have categorize translations', () => {
|
|
160
|
+
const result = translator.t('categorize.limitMaxChoicesPerCategory', {
|
|
161
|
+
lng: 'en',
|
|
162
|
+
maxChoicesPerCategory: 5,
|
|
163
|
+
});
|
|
164
|
+
expect(result).not.toBe('categorize.limitMaxChoicesPerCategory');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('should have ebsr translations', () => {
|
|
168
|
+
const result = translator.t('ebsr.part', {
|
|
169
|
+
lng: 'en',
|
|
170
|
+
index: 1,
|
|
171
|
+
});
|
|
172
|
+
expect(result).toContain('Part');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should have numberLine translations', () => {
|
|
176
|
+
const result = translator.t('numberLine.clearAll', {
|
|
177
|
+
lng: 'en',
|
|
178
|
+
});
|
|
179
|
+
expect(result).toBe('Clear all');
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('should have charting translations', () => {
|
|
183
|
+
const result = translator.t('charting.add', {
|
|
184
|
+
lng: 'en',
|
|
185
|
+
});
|
|
186
|
+
expect(result).toBe('Add');
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('should have drawingResponse translations', () => {
|
|
190
|
+
const result = translator.t('drawingResponse.fillColor', {
|
|
191
|
+
lng: 'en',
|
|
192
|
+
});
|
|
193
|
+
expect(result).toBe('Fill color');
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('should have imageClozeAssociation translations', () => {
|
|
197
|
+
const result = translator.t('imageClozeAssociation.reachedLimit_one', {
|
|
198
|
+
lng: 'en',
|
|
199
|
+
count: 1,
|
|
200
|
+
});
|
|
201
|
+
expect(result).toBeDefined();
|
|
202
|
+
expect(typeof result).toBe('string');
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe('Language Fallback', () => {
|
|
207
|
+
it('should fallback to English when translation is missing in other language', () => {
|
|
208
|
+
const result = translator.t('ebsr.part', {
|
|
209
|
+
lng: 'es',
|
|
210
|
+
index: 1,
|
|
211
|
+
});
|
|
212
|
+
expect(result).toBeDefined();
|
|
213
|
+
expect(typeof result).toBe('string');
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it('should handle undefined language and fallback gracefully', () => {
|
|
217
|
+
const result = translator.t('charting.add', {
|
|
218
|
+
lng: undefined,
|
|
219
|
+
});
|
|
220
|
+
expect(result).toBeDefined();
|
|
221
|
+
expect(typeof result).toBe('string');
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
describe('Component Integration', () => {
|
|
226
|
+
// Test with a simple component that uses the translator
|
|
227
|
+
const TranslatorTestComponent = ({ lng = 'en' }) => {
|
|
228
|
+
const { t } = translator;
|
|
229
|
+
const translated = t('charting.add', { lng });
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<div>
|
|
233
|
+
<button data-testid="translate-btn">
|
|
234
|
+
{translated}
|
|
235
|
+
</button>
|
|
236
|
+
</div>
|
|
237
|
+
);
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
it('should render translated content in a component', () => {
|
|
241
|
+
render(<TranslatorTestComponent lng="en" />);
|
|
242
|
+
const button = screen.getByTestId('translate-btn');
|
|
243
|
+
expect(button).toBeInTheDocument();
|
|
244
|
+
expect(button).toHaveTextContent('Add');
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('should update translated content when language changes', async () => {
|
|
248
|
+
const { rerender } = render(<TranslatorTestComponent lng="en" />);
|
|
249
|
+
const button = screen.getByTestId('translate-btn');
|
|
250
|
+
expect(button).toHaveTextContent('Add');
|
|
251
|
+
|
|
252
|
+
rerender(<TranslatorTestComponent lng="es" />);
|
|
253
|
+
await waitFor(() => {
|
|
254
|
+
expect(button).toBeInTheDocument();
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('should handle user interactions with translated content', async () => {
|
|
259
|
+
const user = userEvent.setup();
|
|
260
|
+
const handleClick = jest.fn();
|
|
261
|
+
|
|
262
|
+
const InteractiveComponent = () => {
|
|
263
|
+
const { t } = translator;
|
|
264
|
+
return (
|
|
265
|
+
<button onClick={handleClick} data-testid="interactive-btn">
|
|
266
|
+
{t('charting.delete', { lng: 'en' })}
|
|
267
|
+
</button>
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
render(<InteractiveComponent />);
|
|
272
|
+
const button = screen.getByTestId('interactive-btn');
|
|
273
|
+
|
|
274
|
+
await user.click(button);
|
|
275
|
+
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
});
|
package/src/en.js
CHANGED
|
@@ -2,7 +2,7 @@ export default {
|
|
|
2
2
|
translation: {
|
|
3
3
|
categorize: {
|
|
4
4
|
limitMaxChoicesPerCategory:
|
|
5
|
-
|
|
5
|
+
'You\'ve reached the limit of {{maxChoicesPerCategory}} responses per area. To add another response, one must first be removed.',
|
|
6
6
|
maxChoicesPerCategoryRestriction:
|
|
7
7
|
'To change this value to {{maxChoicesPerCategory}}, each category must have {{maxChoicesPerCategory}} or fewer answer choice[s].',
|
|
8
8
|
},
|