@zohodesk/react-cli 1.1.26 → 1.1.27

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- let i18nObject = this.getI18nObjectByLocale(i18nKeys, locale);
62
- return `${this.jsonpFunc}(${(0, _utils.jsonToString)(i18nObject)});`; // return `${this.jsonpFunc}(JSON.parse(${JSON.stringify(jsonToString(i18nObject))}));`;
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/react-cli",
3
- "version": "1.1.26",
3
+ "version": "1.1.27",
4
4
  "description": "A CLI tool for build modern web application and libraries",
5
5
  "scripts": {
6
6
  "init": "node ./lib/utils/init.js",