@zohodesk/i18n 1.0.0-beta.41-murphy → 1.0.0-beta.42-murphy
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/es/utils/errorReporter.js +8 -10
- package/es/utils/index.js +0 -4
- package/es/utils/jsxTranslations.js +0 -4
- package/lib/utils/errorReporter.js +8 -10
- package/lib/utils/index.js +0 -6
- package/lib/utils/jsxTranslations.js +0 -6
- package/package.json +1 -1
- package/src/utils/errorReporter.js +7 -8
- package/src/utils/index.js +0 -7
- package/src/utils/jsxTranslations.js +0 -4
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export const I18N_ERROR_TYPES = {
|
|
2
|
-
UNDEFINED_OBJECT: 'I18N_UNDEFINED_OBJECT',
|
|
3
2
|
MISSING_KEY: 'I18N_MISSING_KEY',
|
|
4
3
|
NUMERIC_FALLBACK: 'I18N_NUMERIC_FALLBACK'
|
|
5
4
|
};
|
|
@@ -7,32 +6,31 @@ const reportedKeys = new Set();
|
|
|
7
6
|
export function reportI18NError(type, key) {
|
|
8
7
|
const dedupeKey = `${type}:${key}`;
|
|
9
8
|
if (reportedKeys.has(dedupeKey)) {
|
|
10
|
-
console.log(`[i18n-reporter] SKIPPED (already reported): ${dedupeKey}`);
|
|
11
9
|
return;
|
|
12
10
|
}
|
|
13
|
-
|
|
11
|
+
|
|
12
|
+
// Prefix numeric keys to prevent Murphy masking
|
|
13
|
+
const isNumeric = /^\d+$/.test(key);
|
|
14
|
+
const displayKey = isNumeric ? `key:${key}` : key;
|
|
15
|
+
const errorMessage = `i18n ${type}: ${displayKey}`;
|
|
14
16
|
const errorData = {
|
|
15
17
|
errorType: type,
|
|
16
|
-
i18nKey:
|
|
18
|
+
i18nKey: displayKey,
|
|
19
|
+
rawKey: key,
|
|
17
20
|
category: 'i18n'
|
|
18
21
|
};
|
|
19
22
|
try {
|
|
20
23
|
if (typeof window._windowDeskCustomError === 'function') {
|
|
21
|
-
console.log(`[i18n-reporter] Using DESK path (deskCustomError): ${dedupeKey}`);
|
|
22
24
|
window._windowDeskCustomError(errorData, errorMessage, errorData);
|
|
23
25
|
} else if (window.murphy) {
|
|
24
|
-
console.log(`[i18n-reporter] Using IM path (murphy direct): ${dedupeKey}`);
|
|
25
26
|
window.murphy.addCustomTracking(errorData);
|
|
26
27
|
const error = new Error(errorMessage);
|
|
27
28
|
error.name = type;
|
|
28
29
|
window.murphy.error(error);
|
|
29
30
|
} else {
|
|
30
|
-
console.log(`[i18n-reporter] SKIPPED (Murphy not loaded): ${dedupeKey}`);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
} catch (err) {
|
|
34
|
-
console.error(`[i18n-reporter] ERROR reporting: ${dedupeKey}`, err);
|
|
35
|
-
}
|
|
33
|
+
} catch (err) {}
|
|
36
34
|
reportedKeys.add(dedupeKey);
|
|
37
35
|
}
|
|
38
36
|
export function getFallbackText(key) {
|
package/es/utils/index.js
CHANGED
|
@@ -234,10 +234,6 @@ export function getLocalizedValue({
|
|
|
234
234
|
return localizedValue || null;
|
|
235
235
|
}
|
|
236
236
|
export function getI18NValue(i18n) {
|
|
237
|
-
if (typeof i18n === 'undefined') {
|
|
238
|
-
reportI18NError(I18N_ERROR_TYPES.UNDEFINED_OBJECT, 'i18n_object');
|
|
239
|
-
return key => key;
|
|
240
|
-
}
|
|
241
237
|
return (key, values, localizedProps) => {
|
|
242
238
|
const localizedValue = localizedProps ? getLocalizedValue(localizedProps) : localizedStringData[key];
|
|
243
239
|
const finalKey = getMappedKey(key);
|
|
@@ -169,10 +169,6 @@ export function placeComponentForTags(i18nValue) {
|
|
|
169
169
|
return i18nMechanismForComponents(value, value);
|
|
170
170
|
}
|
|
171
171
|
export function getI18NComponent(i18n) {
|
|
172
|
-
if (typeof i18n === 'undefined') {
|
|
173
|
-
reportI18NError(I18N_ERROR_TYPES.UNDEFINED_OBJECT, 'i18n_object_jsx');
|
|
174
|
-
return key => key;
|
|
175
|
-
}
|
|
176
172
|
return key => {
|
|
177
173
|
let i18nStr = i18n[key];
|
|
178
174
|
if (i18nStr === undefined) {
|
|
@@ -7,7 +7,6 @@ exports.I18N_ERROR_TYPES = void 0;
|
|
|
7
7
|
exports.getFallbackText = getFallbackText;
|
|
8
8
|
exports.reportI18NError = reportI18NError;
|
|
9
9
|
var I18N_ERROR_TYPES = exports.I18N_ERROR_TYPES = {
|
|
10
|
-
UNDEFINED_OBJECT: 'I18N_UNDEFINED_OBJECT',
|
|
11
10
|
MISSING_KEY: 'I18N_MISSING_KEY',
|
|
12
11
|
NUMERIC_FALLBACK: 'I18N_NUMERIC_FALLBACK'
|
|
13
12
|
};
|
|
@@ -15,32 +14,31 @@ var reportedKeys = new Set();
|
|
|
15
14
|
function reportI18NError(type, key) {
|
|
16
15
|
var dedupeKey = "".concat(type, ":").concat(key);
|
|
17
16
|
if (reportedKeys.has(dedupeKey)) {
|
|
18
|
-
console.log("[i18n-reporter] SKIPPED (already reported): ".concat(dedupeKey));
|
|
19
17
|
return;
|
|
20
18
|
}
|
|
21
|
-
|
|
19
|
+
|
|
20
|
+
// Prefix numeric keys to prevent Murphy masking
|
|
21
|
+
var isNumeric = /^\d+$/.test(key);
|
|
22
|
+
var displayKey = isNumeric ? "key:".concat(key) : key;
|
|
23
|
+
var errorMessage = "i18n ".concat(type, ": ").concat(displayKey);
|
|
22
24
|
var errorData = {
|
|
23
25
|
errorType: type,
|
|
24
|
-
i18nKey:
|
|
26
|
+
i18nKey: displayKey,
|
|
27
|
+
rawKey: key,
|
|
25
28
|
category: 'i18n'
|
|
26
29
|
};
|
|
27
30
|
try {
|
|
28
31
|
if (typeof window._windowDeskCustomError === 'function') {
|
|
29
|
-
console.log("[i18n-reporter] Using DESK path (deskCustomError): ".concat(dedupeKey));
|
|
30
32
|
window._windowDeskCustomError(errorData, errorMessage, errorData);
|
|
31
33
|
} else if (window.murphy) {
|
|
32
|
-
console.log("[i18n-reporter] Using IM path (murphy direct): ".concat(dedupeKey));
|
|
33
34
|
window.murphy.addCustomTracking(errorData);
|
|
34
35
|
var error = new Error(errorMessage);
|
|
35
36
|
error.name = type;
|
|
36
37
|
window.murphy.error(error);
|
|
37
38
|
} else {
|
|
38
|
-
console.log("[i18n-reporter] SKIPPED (Murphy not loaded): ".concat(dedupeKey));
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
} catch (err) {
|
|
42
|
-
console.error("[i18n-reporter] ERROR reporting: ".concat(dedupeKey), err);
|
|
43
|
-
}
|
|
41
|
+
} catch (err) {}
|
|
44
42
|
reportedKeys.add(dedupeKey);
|
|
45
43
|
}
|
|
46
44
|
function getFallbackText(key) {
|
package/lib/utils/index.js
CHANGED
|
@@ -269,12 +269,6 @@ function getLocalizedValue() {
|
|
|
269
269
|
return localizedValue || null;
|
|
270
270
|
}
|
|
271
271
|
function getI18NValue(i18n) {
|
|
272
|
-
if (typeof i18n === 'undefined') {
|
|
273
|
-
(0, _errorReporter.reportI18NError)(_errorReporter.I18N_ERROR_TYPES.UNDEFINED_OBJECT, 'i18n_object');
|
|
274
|
-
return function (key) {
|
|
275
|
-
return key;
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
272
|
return function (key, values, localizedProps) {
|
|
279
273
|
var localizedValue = localizedProps ? getLocalizedValue(localizedProps) : localizedStringData[key];
|
|
280
274
|
var finalKey = getMappedKey(key);
|
|
@@ -198,12 +198,6 @@ function placeComponentForTags(i18nValue) {
|
|
|
198
198
|
return i18nMechanismForComponents(value, value);
|
|
199
199
|
}
|
|
200
200
|
function getI18NComponent(i18n) {
|
|
201
|
-
if (typeof i18n === 'undefined') {
|
|
202
|
-
(0, _errorReporter.reportI18NError)(_errorReporter.I18N_ERROR_TYPES.UNDEFINED_OBJECT, 'i18n_object_jsx');
|
|
203
|
-
return function (key) {
|
|
204
|
-
return key;
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
201
|
return function (key) {
|
|
208
202
|
var i18nStr = i18n[key];
|
|
209
203
|
if (i18nStr === undefined) {
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export const I18N_ERROR_TYPES = {
|
|
2
|
-
UNDEFINED_OBJECT: 'I18N_UNDEFINED_OBJECT',
|
|
3
2
|
MISSING_KEY: 'I18N_MISSING_KEY',
|
|
4
3
|
NUMERIC_FALLBACK: 'I18N_NUMERIC_FALLBACK'
|
|
5
4
|
};
|
|
@@ -10,33 +9,33 @@ export function reportI18NError(type, key) {
|
|
|
10
9
|
const dedupeKey = `${type}:${key}`;
|
|
11
10
|
|
|
12
11
|
if (reportedKeys.has(dedupeKey)) {
|
|
13
|
-
console.log(`[i18n-reporter] SKIPPED (already reported): ${dedupeKey}`);
|
|
14
12
|
return;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
// Prefix numeric keys to prevent Murphy masking
|
|
16
|
+
const isNumeric = /^\d+$/.test(key);
|
|
17
|
+
const displayKey = isNumeric ? `key:${key}` : key;
|
|
18
|
+
|
|
19
|
+
const errorMessage = `i18n ${type}: ${displayKey}`;
|
|
18
20
|
const errorData = {
|
|
19
21
|
errorType: type,
|
|
20
|
-
i18nKey:
|
|
22
|
+
i18nKey: displayKey,
|
|
23
|
+
rawKey: key,
|
|
21
24
|
category: 'i18n'
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
try {
|
|
25
28
|
if (typeof window._windowDeskCustomError === 'function') {
|
|
26
|
-
console.log(`[i18n-reporter] Using DESK path (deskCustomError): ${dedupeKey}`);
|
|
27
29
|
window._windowDeskCustomError(errorData, errorMessage, errorData);
|
|
28
30
|
} else if (window.murphy) {
|
|
29
|
-
console.log(`[i18n-reporter] Using IM path (murphy direct): ${dedupeKey}`);
|
|
30
31
|
window.murphy.addCustomTracking(errorData);
|
|
31
32
|
const error = new Error(errorMessage);
|
|
32
33
|
error.name = type;
|
|
33
34
|
window.murphy.error(error);
|
|
34
35
|
} else {
|
|
35
|
-
console.log(`[i18n-reporter] SKIPPED (Murphy not loaded): ${dedupeKey}`);
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
} catch (err) {
|
|
39
|
-
console.error(`[i18n-reporter] ERROR reporting: ${dedupeKey}`, err);
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
reportedKeys.add(dedupeKey);
|
package/src/utils/index.js
CHANGED
|
@@ -290,24 +290,17 @@ export function getLocalizedValue({
|
|
|
290
290
|
return localizedValue || null
|
|
291
291
|
}
|
|
292
292
|
export function getI18NValue(i18n) {
|
|
293
|
-
if (typeof i18n === 'undefined') {
|
|
294
|
-
reportI18NError(I18N_ERROR_TYPES.UNDEFINED_OBJECT, 'i18n_object');
|
|
295
|
-
return (key) => key;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
293
|
return (key, values, localizedProps) => {
|
|
299
294
|
const localizedValue = localizedProps
|
|
300
295
|
? getLocalizedValue(localizedProps)
|
|
301
296
|
: localizedStringData[key];
|
|
302
297
|
const finalKey = getMappedKey(key);
|
|
303
298
|
let i18nStr = i18n[finalKey];
|
|
304
|
-
|
|
305
299
|
if (i18nStr === undefined) {
|
|
306
300
|
const isNumeric = /^\d+$/.test(finalKey);
|
|
307
301
|
const errorType = isNumeric
|
|
308
302
|
? I18N_ERROR_TYPES.NUMERIC_FALLBACK
|
|
309
303
|
: I18N_ERROR_TYPES.MISSING_KEY;
|
|
310
|
-
|
|
311
304
|
reportI18NError(errorType, finalKey);
|
|
312
305
|
return localizedValue || getFallbackText(finalKey);
|
|
313
306
|
}
|
|
@@ -180,10 +180,6 @@ export function placeComponentForTags(i18nValue) {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
export function getI18NComponent(i18n) {
|
|
183
|
-
if(typeof i18n === 'undefined') {
|
|
184
|
-
reportI18NError(I18N_ERROR_TYPES.UNDEFINED_OBJECT, 'i18n_object_jsx');
|
|
185
|
-
return (key) => key;
|
|
186
|
-
}
|
|
187
183
|
return (key) => {
|
|
188
184
|
let i18nStr = i18n[key];
|
|
189
185
|
if (i18nStr === undefined) {
|