@zohodesk/react-cli 1.1.26 → 1.1.27
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.
@@ -11,6 +11,8 @@ var _utils = require("./utils");
|
|
11
11
|
|
12
12
|
var _getI18nKeysFormModules = _interopRequireDefault(require("./utils/getI18nKeysFormModules"));
|
13
13
|
|
14
|
+
var _unicodeConversion = require("./utils/unicodeConversion");
|
15
|
+
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
17
|
|
16
18
|
/**
|
@@ -58,8 +60,9 @@ class I18nFilesEmitter {
|
|
58
60
|
}
|
59
61
|
|
60
62
|
getTemplateString(i18nKeys, locale) {
|
61
|
-
|
62
|
-
|
63
|
+
const i18nObject = this.getI18nObjectByLocale(i18nKeys, locale);
|
64
|
+
const convertedI18nObject = (0, _unicodeConversion.convertUnicode)(JSON.stringify(i18nObject, null, 0));
|
65
|
+
return `${this.jsonpFunc}(${convertedI18nObject});`; // return `${this.jsonpFunc}(JSON.parse(${JSON.stringify(jsonToString(i18nObject))}));`;
|
63
66
|
}
|
64
67
|
|
65
68
|
renderI18nLocaleChunk(chunk, locale, i18nKeys) {
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.convertUnicode = convertUnicode;
|
7
|
+
const UNICODE_PATTERN = /\\+u([0-9a-fA-F]{4})/g;
|
8
|
+
|
9
|
+
function convertUnicode(jsonStr) {
|
10
|
+
if (!jsonStr.includes('\\u')) {
|
11
|
+
return jsonStr;
|
12
|
+
}
|
13
|
+
|
14
|
+
UNICODE_PATTERN.lastIndex = 0;
|
15
|
+
return jsonStr.replace(UNICODE_PATTERN, (_, hex) => String.fromCharCode(Number.parseInt(hex, 16)));
|
16
|
+
}
|