@configuratorware/configurator-frontendgui 1.49.4 → 1.49.6
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/App/configuration.js +53 -37
- package/package.json +4 -4
- package/src/App/configuration.js +61 -35
package/App/configuration.js
CHANGED
|
@@ -358,47 +358,63 @@ function setConfiguration(customApplicationConfiguration) {
|
|
|
358
358
|
}
|
|
359
359
|
function setLanguage() {
|
|
360
360
|
var language;
|
|
361
|
-
//
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
361
|
+
//fetch default language and set
|
|
362
|
+
_Api["default"].request({
|
|
363
|
+
url: 'languages'
|
|
364
|
+
}).then(function (response) {
|
|
365
|
+
var _response$data$find;
|
|
366
|
+
language = (_response$data$find = response.data.find(function (lang) {
|
|
367
|
+
return lang.isDefault;
|
|
368
|
+
})) === null || _response$data$find === void 0 ? void 0 : _response$data$find.iso;
|
|
369
|
+
// if the default language is defined in the configuration
|
|
370
|
+
if (applicationConfiguration.language) {
|
|
371
|
+
language = applicationConfiguration.language;
|
|
372
|
+
} else if (!language) {
|
|
373
|
+
// if there is a locales array in the configuration...
|
|
374
|
+
if (applicationConfiguration.locales) {
|
|
375
|
+
var browserLanguage = (0, _get["default"])(navigator, 'languages[0]', navigator.language).replace('-', '_');
|
|
376
|
+
var matchToBrowserLanguage = (0, _find["default"])(applicationConfiguration.locales, {
|
|
377
|
+
code: browserLanguage
|
|
378
|
+
});
|
|
379
|
+
var preferred = (0, _find["default"])(applicationConfiguration.locales, {
|
|
380
|
+
preferred: true
|
|
381
|
+
});
|
|
374
382
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
383
|
+
// if there is a match with the browser language use that
|
|
384
|
+
if (matchToBrowserLanguage) {
|
|
385
|
+
language = matchToBrowserLanguage.code;
|
|
386
|
+
}
|
|
387
|
+
// if the preferred language is set use it
|
|
388
|
+
else if (preferred) {
|
|
389
|
+
language = preferred.code;
|
|
390
|
+
}
|
|
391
|
+
// otherwise use the first from the locales list
|
|
392
|
+
else {
|
|
393
|
+
language = (0, _first["default"])(applicationConfiguration.locales).code;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
// we have no info about the language, so try to use the browser language
|
|
397
|
+
else {
|
|
398
|
+
language = (0, _get["default"])(navigator, 'languages[0]', navigator.language).replace('-', '_') || 'de_DE';
|
|
399
|
+
}
|
|
382
400
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
401
|
+
if (!(0, _find["default"])(applicationConfiguration.locales, {
|
|
402
|
+
code: language.replace('-', '_')
|
|
403
|
+
})) {
|
|
404
|
+
// eslint-disable-next-line no-console
|
|
405
|
+
console.warn("The selected language (".concat(language, ") is not listed in the available languages!"));
|
|
406
|
+
language = (0, _find["default"])(applicationConfiguration.locales, {
|
|
407
|
+
preferred: true
|
|
408
|
+
}).code;
|
|
386
409
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
if (!(0, _find["default"])(applicationConfiguration.locales, {
|
|
393
|
-
code: language
|
|
394
|
-
})) {
|
|
410
|
+
applicationConfiguration.language = language.replace('_', '-');
|
|
411
|
+
_Api["default"].setLanguage(applicationConfiguration.language);
|
|
412
|
+
document.documentElement.lang = language.substring(0, 2);
|
|
413
|
+
(0, _Translations.initLanguage)(applicationConfiguration.language, applicationConfiguration.network.baseURL);
|
|
414
|
+
})["catch"](function (error) {
|
|
395
415
|
// eslint-disable-next-line no-console
|
|
396
|
-
console.
|
|
397
|
-
}
|
|
398
|
-
applicationConfiguration.language = language.replace('_', '-');
|
|
399
|
-
_Api["default"].setLanguage(applicationConfiguration.language);
|
|
400
|
-
document.documentElement.lang = language.substring(0, 2);
|
|
401
|
-
(0, _Translations.initLanguage)(applicationConfiguration.language, applicationConfiguration.network.baseURL);
|
|
416
|
+
console.error('Error by loading api default language!', error);
|
|
417
|
+
});
|
|
402
418
|
}
|
|
403
419
|
|
|
404
420
|
// backward compatibility alias
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configuratorware/configurator-frontendgui",
|
|
3
|
-
"version": "1.49.
|
|
3
|
+
"version": "1.49.6",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@babel/polyfill": "^7.12.1",
|
|
9
|
-
"@configuratorware/scripts": "1.49.
|
|
9
|
+
"@configuratorware/scripts": "1.49.6",
|
|
10
10
|
"@material-ui/core": "^4.12.4",
|
|
11
11
|
"@material-ui/icons": "^4.11.3",
|
|
12
12
|
"@material-ui/lab": "^4.0.0-alpha.61",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"react-router-dom": "^5.3.4",
|
|
37
37
|
"react-swipeable": "^5.5.1",
|
|
38
38
|
"react-zoom-pan-pinch": "^2.1.3",
|
|
39
|
-
"redhotmagma-graphics-editor": "1.49.
|
|
40
|
-
"redhotmagma-visualization": "1.49.
|
|
39
|
+
"redhotmagma-graphics-editor": "1.49.6",
|
|
40
|
+
"redhotmagma-visualization": "1.49.6",
|
|
41
41
|
"redux": "^4.1.0",
|
|
42
42
|
"redux-logger": "^3.0.6",
|
|
43
43
|
"redux-persist": "^5.10.0",
|
package/src/App/configuration.js
CHANGED
|
@@ -404,41 +404,67 @@ export function setConfiguration(customApplicationConfiguration) {
|
|
|
404
404
|
|
|
405
405
|
function setLanguage() {
|
|
406
406
|
let language;
|
|
407
|
-
//
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
407
|
+
//fetch default language and set
|
|
408
|
+
Api.request({
|
|
409
|
+
url: 'languages',
|
|
410
|
+
})
|
|
411
|
+
.then(response => {
|
|
412
|
+
language = response.data.find(lang => lang.isDefault)?.iso;
|
|
413
|
+
// if the default language is defined in the configuration
|
|
414
|
+
if (applicationConfiguration.language) {
|
|
415
|
+
language = applicationConfiguration.language;
|
|
416
|
+
} else if (!language) {
|
|
417
|
+
// if there is a locales array in the configuration...
|
|
418
|
+
if (applicationConfiguration.locales) {
|
|
419
|
+
const browserLanguage = get(navigator, 'languages[0]', navigator.language).replace(
|
|
420
|
+
'-',
|
|
421
|
+
'_'
|
|
422
|
+
);
|
|
423
|
+
const matchToBrowserLanguage = find(applicationConfiguration.locales, {
|
|
424
|
+
code: browserLanguage,
|
|
425
|
+
});
|
|
426
|
+
const preferred = find(applicationConfiguration.locales, {
|
|
427
|
+
preferred: true,
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
// if there is a match with the browser language use that
|
|
431
|
+
if (matchToBrowserLanguage) {
|
|
432
|
+
language = matchToBrowserLanguage.code;
|
|
433
|
+
}
|
|
434
|
+
// if the preferred language is set use it
|
|
435
|
+
else if (preferred) {
|
|
436
|
+
language = preferred.code;
|
|
437
|
+
}
|
|
438
|
+
// otherwise use the first from the locales list
|
|
439
|
+
else {
|
|
440
|
+
language = first(applicationConfiguration.locales).code;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
// we have no info about the language, so try to use the browser language
|
|
444
|
+
else {
|
|
445
|
+
language =
|
|
446
|
+
get(navigator, 'languages[0]', navigator.language).replace('-', '_') || 'de_DE';
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
if (
|
|
451
|
+
!find(applicationConfiguration.locales, {
|
|
452
|
+
code: language.replace('-', '_'),
|
|
453
|
+
})
|
|
454
|
+
) {
|
|
455
|
+
// eslint-disable-next-line no-console
|
|
456
|
+
console.warn(`The selected language (${language}) is not listed in the available languages!`);
|
|
457
|
+
language = find(applicationConfiguration.locales, { preferred: true }).code;
|
|
458
|
+
}
|
|
459
|
+
applicationConfiguration.language = language.replace('_', '-');
|
|
460
|
+
Api.setLanguage(applicationConfiguration.language);
|
|
461
|
+
document.documentElement.lang = language.substring(0, 2);
|
|
462
|
+
initLanguage(applicationConfiguration.language, applicationConfiguration.network.baseURL);
|
|
463
|
+
})
|
|
464
|
+
.catch(error => {
|
|
465
|
+
// eslint-disable-next-line no-console
|
|
466
|
+
console.error('Error by loading api default language!', error);
|
|
467
|
+
});
|
|
442
468
|
}
|
|
443
469
|
|
|
444
470
|
// backward compatibility alias
|