@zohodesk/react-cli 1.1.14-exp.2 → 1.1.14-exp.4

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.
@@ -215,6 +215,7 @@ function downloadScriptTagForI18nDynamicChunks(chunkName = '', language = '') {
215
215
  chunkId = chunkName;
216
216
  }
217
217
  if (language) {
218
+ window.userLangCode = language;
218
219
  locale = language;
219
220
  }
220
221
  if(installedI18nChunks[chunkId]) {
@@ -251,19 +252,31 @@ function downloadScriptTagForI18nDynamicChunks(chunkName = '', language = '') {
251
252
  }` : ''}
252
253
  document.body.appendChild(scriptTag);
253
254
  }).then(function() {
254
- installedI18nChunks[chunkId] = 0;
255
+ installedI18nChunks[chunkId] = 0;
255
256
  }));
256
257
  }
258
+ return installedI18nChunks[chunkId];
257
259
  };
258
260
  downloadScriptTagForI18nDynamicChunks();
259
- ${mainTemplate.requireFn}.changeLanguage = function changeLanguage(language) {
260
- window.userLangCode=language;
261
- Object.keys(installedI18nChunks).map(chunks => {
262
- if (chunks !== './runtime~main' && installedI18nChunks[chunks] == 0) {
263
- installedI18nChunks[chunks] = null;
264
- downloadScriptTagForI18nDynamicChunks(chunks, language);
265
- }
266
- });}`]);
261
+ ${mainTemplate.requireFn}.changeLanguage = function changeLanguage(language) {
262
+ window.change(language);
263
+ return new Promise((resolve, reject) => {
264
+ const chunkPromises = Object.keys(installedI18nChunks).map(chunks => {
265
+ if (chunks !== './runtime~main' && installedI18nChunks[chunks] == 0) {
266
+ installedI18nChunks[chunks] = null;
267
+ return downloadScriptTagForI18nDynamicChunks(chunks, language);
268
+ }
269
+ });
270
+
271
+ Promise.all(chunkPromises)
272
+ .then(() => {
273
+ resolve();
274
+ })
275
+ .catch(error => {
276
+ reject(error);
277
+ });
278
+ });
279
+ };`]);
267
280
  });
268
281
  }
269
282
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/react-cli",
3
- "version": "1.1.14-exp.2",
3
+ "version": "1.1.14-exp.4",
4
4
  "description": "A CLI tool for build modern web application and libraries",
5
5
  "scripts": {
6
6
  "init": "node ./lib/utils/init.js",