orc-shared 1.2.0-dev.7 → 1.3.0-dev.2

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.
Files changed (60) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/dist/components/AppFrame/About.js +5 -1
  4. package/dist/components/AppFrame/AppFrame.js +14 -4
  5. package/dist/components/AppFrame/MenuItem.js +1 -4
  6. package/dist/components/Culture.js +106 -0
  7. package/dist/components/I18n.js +5 -2
  8. package/dist/components/MaterialUI/Inputs/DatePicker.js +10 -37
  9. package/dist/components/MaterialUI/Inputs/InputBase.js +42 -4
  10. package/dist/components/MaterialUI/Inputs/InputBaseProps.js +4 -1
  11. package/dist/components/MaterialUI/Inputs/TimePicker.js +5 -2
  12. package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +8 -2
  13. package/dist/components/Provision.js +3 -1
  14. package/dist/components/Routing/FullPage.js +6 -3
  15. package/dist/content/icons/archives.svg +3 -0
  16. package/dist/content/icons/lock.svg +3 -0
  17. package/dist/content/icons/unlock.svg +3 -0
  18. package/dist/content/iconsSheet.svg +9 -3
  19. package/dist/selectors/metadata.js +13 -3
  20. package/dist/selectors/scope.js +2 -1
  21. package/dist/utils/localizationHelper.js +11 -1
  22. package/dist/utils/setTranslation.js +27 -1
  23. package/dist/utils/setTranslationWithFallback.js +30 -1
  24. package/package.json +1 -1
  25. package/src/components/AppFrame/About.js +8 -1
  26. package/src/components/AppFrame/AppFrame.js +13 -2
  27. package/src/components/AppFrame/AppFrame.test.js +53 -0
  28. package/src/components/AppFrame/MenuItem.js +1 -12
  29. package/src/components/Culture.js +25 -0
  30. package/src/components/Culture.test.js +86 -0
  31. package/src/components/I18n.js +4 -2
  32. package/src/components/I18n.test.js +32 -3
  33. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Translations.test.js +7 -1
  34. package/src/components/MaterialUI/Inputs/DatePicker.js +5 -27
  35. package/src/components/MaterialUI/Inputs/DatePicker.test.js +6 -34
  36. package/src/components/MaterialUI/Inputs/InputBase.js +20 -2
  37. package/src/components/MaterialUI/Inputs/InputBase.test.js +68 -0
  38. package/src/components/MaterialUI/Inputs/InputBaseProps.js +2 -0
  39. package/src/components/MaterialUI/Inputs/InputBaseProps.test.js +2 -0
  40. package/src/components/MaterialUI/Inputs/TimePicker.js +6 -2
  41. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +5 -1
  42. package/src/components/Provision.js +2 -0
  43. package/src/components/Routing/FullPage.js +12 -4
  44. package/src/components/Routing/FullPage.test.js +24 -0
  45. package/src/components/Scope/Scope.test.js +4 -0
  46. package/src/content/icons/archives.svg +3 -0
  47. package/src/content/icons/lock.svg +3 -0
  48. package/src/content/icons/unlock.svg +3 -0
  49. package/src/content/iconsSheet.svg +9 -3
  50. package/src/selectors/metadata.js +18 -7
  51. package/src/selectors/metadata.test.js +221 -283
  52. package/src/selectors/scope.js +1 -1
  53. package/src/translations/en-US.json +1 -1
  54. package/src/translations/fr-CA.json +1 -1
  55. package/src/utils/localizationHelper.js +12 -0
  56. package/src/utils/localizationHelper.test.js +64 -0
  57. package/src/utils/setTranslation.js +16 -1
  58. package/src/utils/setTranslation.test.js +24 -0
  59. package/src/utils/setTranslationWithFallback.js +18 -1
  60. package/src/utils/setTranslationWithFallback.test.js +108 -0
@@ -848,6 +848,143 @@ describe("definitions", () => {
848
848
  description: "InnaCustom2",
849
849
  };
850
850
 
851
+ let baseBuitInAttribute1 = {
852
+ maximum: 256,
853
+ dataType: "Text",
854
+ isRequired: false,
855
+ name: "Username",
856
+ displayOrder: 1,
857
+ isSearchable: true,
858
+ displayName: {
859
+ "en-CA": "User name",
860
+ "en-US": "User name",
861
+ "fr-CA": "User name",
862
+ },
863
+ minimum: 1,
864
+ multilingual: false,
865
+ isBuiltIn: true,
866
+ groupId: "Default",
867
+ allowMultipleValues: false,
868
+ };
869
+
870
+ let baseBuitInAttribute2 = {
871
+ maximum: 256,
872
+ dataType: "Text",
873
+ isRequired: false,
874
+ name: "Email",
875
+ displayOrder: 2,
876
+ isSearchable: true,
877
+ displayName: {
878
+ "en-CA": "Email",
879
+ "en-US": "Email",
880
+ "fr-CA": "Email",
881
+ },
882
+ minimum: 0,
883
+ multilingual: false,
884
+ isBuiltIn: true,
885
+ groupId: "Default",
886
+ allowMultipleValues: false,
887
+ };
888
+
889
+ let baseBuitInAttribute3 = {
890
+ maximum: 64,
891
+ dataType: "Text",
892
+ isRequired: false,
893
+ name: "LastName",
894
+ displayOrder: 3,
895
+ isSearchable: true,
896
+ displayName: {
897
+ "en-CA": "Last name",
898
+ "en-US": "Last name",
899
+ "fr-CA": "Last name",
900
+ "it-IT": "Cognome",
901
+ },
902
+ minimum: 0,
903
+ multilingual: false,
904
+ isBuiltIn: true,
905
+ groupId: "Default",
906
+ allowMultipleValues: false,
907
+ };
908
+
909
+ let baseBuitInAttribute4 = {
910
+ maximum: 64,
911
+ dataType: "Text",
912
+ isRequired: false,
913
+ name: "FirstName",
914
+ displayOrder: 4,
915
+ isSearchable: true,
916
+ displayName: {
917
+ "ar-JO": "",
918
+ "en-CA": "First Name",
919
+ "en-US": "First Name",
920
+ "es-ES": "",
921
+ "fr-CA": "First Name",
922
+ "it-IT": "Nome",
923
+ },
924
+ minimum: 0,
925
+ multilingual: false,
926
+ isBuiltIn: true,
927
+ groupId: "Default",
928
+ allowMultipleValues: false,
929
+ };
930
+
931
+ let baseCustomAttribute1 = {
932
+ maximum: 64,
933
+ dataType: "Text",
934
+ isRequired: false,
935
+ name: "BaseAttribute1",
936
+ displayOrder: 1,
937
+ isSearchable: true,
938
+ displayName: {
939
+ "en-CA": "Base Attribute1",
940
+ "en-US": "Base Attribute1",
941
+ "fr-CA": "Base Attribute1",
942
+ },
943
+ minimum: 0,
944
+ multilingual: false,
945
+ isBuiltIn: false,
946
+ groupId: "Default",
947
+ allowMultipleValues: false,
948
+ };
949
+
950
+ let baseCustomAttribute2 = {
951
+ maximum: 64,
952
+ dataType: "Text",
953
+ isRequired: false,
954
+ name: "BaseAttribute2",
955
+ displayOrder: 2,
956
+ isSearchable: true,
957
+ displayName: {
958
+ "en-CA": "Base Attribute 2",
959
+ "en-US": "Base Attribute 2",
960
+ "fr-CA": "Base Attribute 2",
961
+ },
962
+ minimum: 0,
963
+ multilingual: false,
964
+ isBuiltIn: false,
965
+ groupId: "Default",
966
+ allowMultipleValues: false,
967
+ };
968
+
969
+ let baseCustomAttribute3 = {
970
+ maximum: 64,
971
+ dataType: "Text",
972
+ isRequired: false,
973
+ name: "BaseAttribute3",
974
+ displayOrder: 3,
975
+ isSearchable: true,
976
+ displayName: {
977
+ "en-CA": "Base Attribute 3",
978
+ "en-US": "Base Attribute 3",
979
+ "fr-CA": "Base Attribute 3",
980
+ },
981
+ minimum: 0,
982
+ multilingual: false,
983
+ isBuiltIn: false,
984
+ groupId: "Default",
985
+ allowMultipleValues: false,
986
+ };
987
+
851
988
  beforeEach(() => {
852
989
  state = Immutable.fromJS({
853
990
  locale: {
@@ -978,90 +1115,15 @@ describe("definitions", () => {
978
1115
  entityTypeName: "CUSTOMER",
979
1116
  isBuiltIn: true,
980
1117
  attributes: [
981
- {
982
- maximum: 256,
983
- dataType: "Text",
984
- isRequired: false,
985
- name: "Username",
986
- displayOrder: 0,
987
- isSearchable: true,
988
- displayName: {
989
- "ar-JO": "",
990
- "en-CA": "User name",
991
- "en-US": "User name",
992
- "es-ES": "",
993
- "fr-CA": "User name",
994
- "it-IT": "Nome utente",
995
- },
996
- minimum: 1,
997
- multilingual: false,
998
- isBuiltIn: true,
999
- groupId: "Default",
1000
- allowMultipleValues: false,
1001
- },
1002
- {
1003
- maximum: 256,
1004
- dataType: "Text",
1005
- isRequired: false,
1006
- name: "Email",
1007
- displayOrder: 0,
1008
- isSearchable: true,
1009
- displayName: {
1010
- "ar-JO": "",
1011
- "en-CA": "Email",
1012
- "en-US": "Email",
1013
- "es-ES": "",
1014
- "fr-CA": "Email",
1015
- "it-IT": "Email",
1016
- },
1017
- minimum: 0,
1018
- multilingual: false,
1019
- isBuiltIn: true,
1020
- groupId: "Default",
1021
- allowMultipleValues: false,
1022
- },
1118
+ baseBuitInAttribute1,
1119
+ baseBuitInAttribute2,
1023
1120
  customProfileAttribute1,
1024
1121
  customProfileAttribute2,
1025
- {
1026
- maximum: 64,
1027
- dataType: "Text",
1028
- isRequired: false,
1029
- name: "LastName",
1030
- displayOrder: 0,
1031
- isSearchable: true,
1032
- displayName: {
1033
- "en-CA": "Last name",
1034
- "en-US": "Last name",
1035
- "fr-CA": "Last name",
1036
- "it-IT": "Cognome",
1037
- },
1038
- minimum: 0,
1039
- multilingual: false,
1040
- isBuiltIn: true,
1041
- groupId: "Default",
1042
- allowMultipleValues: false,
1043
- },
1044
- {
1045
- maximum: 64,
1046
- dataType: "Text",
1047
- isRequired: false,
1048
- name: "FirstName",
1049
- displayOrder: 0,
1050
- isSearchable: true,
1051
- displayName: {
1052
- "ar-JO": "",
1053
- "en-CA": "First Name",
1054
- "en-US": "First Name",
1055
- "es-ES": "",
1056
- "fr-CA": "First Name",
1057
- "it-IT": "Nome",
1058
- },
1059
- minimum: 0,
1060
- multilingual: false,
1061
- isBuiltIn: true,
1062
- groupId: "Default",
1063
- allowMultipleValues: false,
1064
- },
1122
+ baseBuitInAttribute4,
1123
+ baseBuitInAttribute3,
1124
+ baseCustomAttribute1,
1125
+ baseCustomAttribute3,
1126
+ baseCustomAttribute2,
1065
1127
  ],
1066
1128
  isSharedEntity: true,
1067
1129
  },
@@ -1359,7 +1421,7 @@ describe("definitions", () => {
1359
1421
  {},
1360
1422
  ));
1361
1423
 
1362
- it("will return correct custom profile attributes definition", () => {
1424
+ it("will return correct custom profile attributes definition in correct order", () => {
1363
1425
  const expectedGroup1 = customProfileAttribute1.groupId;
1364
1426
  const expectedGroup2 = customProfileAttribute2.groupId;
1365
1427
  const expectedItem1 = {
@@ -1371,11 +1433,26 @@ describe("definitions", () => {
1371
1433
  ...{ displayName: customProfileAttribute2.displayName["en-US"] },
1372
1434
  };
1373
1435
 
1436
+ const expectedBaseCustomWithOrder1 = {
1437
+ ...baseCustomAttribute1,
1438
+ ...{ displayName: baseCustomAttribute1.displayName["en-US"] },
1439
+ };
1440
+
1441
+ const expectedBaseCustomWithOrder2 = {
1442
+ ...baseCustomAttribute2,
1443
+ ...{ displayName: baseCustomAttribute2.displayName["en-US"] },
1444
+ };
1445
+
1446
+ const expectedBaseCustomWithOrder3 = {
1447
+ ...baseCustomAttribute3,
1448
+ ...{ displayName: baseCustomAttribute3.displayName["en-US"] },
1449
+ };
1450
+
1374
1451
  const expected = Immutable.fromJS({
1375
1452
  [expectedGroup1]: {
1376
1453
  id: expectedGroup1,
1377
1454
  name: "Default en-US",
1378
- baseAttributes: [],
1455
+ baseAttributes: [expectedBaseCustomWithOrder1, expectedBaseCustomWithOrder2, expectedBaseCustomWithOrder3],
1379
1456
  profileAttributes: [expectedItem1],
1380
1457
  },
1381
1458
  [expectedGroup2]: {
@@ -1397,90 +1474,12 @@ describe("definitions", () => {
1397
1474
  );
1398
1475
  });
1399
1476
 
1400
- it("will return correct full base customer definition attributes", () => {
1477
+ it("will return correct full base (built in) customer definition attributes", () => {
1401
1478
  const expected = Immutable.fromJS([
1402
- {
1403
- maximum: 256,
1404
- dataType: "Text",
1405
- isRequired: false,
1406
- name: "Username",
1407
- displayOrder: 0,
1408
- isSearchable: true,
1409
- displayName: {
1410
- "ar-JO": "",
1411
- "en-CA": "User name",
1412
- "en-US": "User name",
1413
- "es-ES": "",
1414
- "fr-CA": "User name",
1415
- "it-IT": "Nome utente",
1416
- },
1417
- minimum: 1,
1418
- multilingual: false,
1419
- isBuiltIn: true,
1420
- groupId: "Default",
1421
- allowMultipleValues: false,
1422
- },
1423
- {
1424
- maximum: 256,
1425
- dataType: "Text",
1426
- isRequired: false,
1427
- name: "Email",
1428
- displayOrder: 0,
1429
- isSearchable: true,
1430
- displayName: {
1431
- "ar-JO": "",
1432
- "en-CA": "Email",
1433
- "en-US": "Email",
1434
- "es-ES": "",
1435
- "fr-CA": "Email",
1436
- "it-IT": "Email",
1437
- },
1438
- minimum: 0,
1439
- multilingual: false,
1440
- isBuiltIn: true,
1441
- groupId: "Default",
1442
- allowMultipleValues: false,
1443
- },
1444
- {
1445
- maximum: 64,
1446
- dataType: "Text",
1447
- isRequired: false,
1448
- name: "LastName",
1449
- displayOrder: 0,
1450
- isSearchable: true,
1451
- displayName: {
1452
- "en-CA": "Last name",
1453
- "en-US": "Last name",
1454
- "fr-CA": "Last name",
1455
- "it-IT": "Cognome",
1456
- },
1457
- minimum: 0,
1458
- multilingual: false,
1459
- isBuiltIn: true,
1460
- groupId: "Default",
1461
- allowMultipleValues: false,
1462
- },
1463
- {
1464
- maximum: 64,
1465
- dataType: "Text",
1466
- isRequired: false,
1467
- name: "FirstName",
1468
- displayOrder: 0,
1469
- isSearchable: true,
1470
- displayName: {
1471
- "ar-JO": "",
1472
- "en-CA": "First Name",
1473
- "en-US": "First Name",
1474
- "es-ES": "",
1475
- "fr-CA": "First Name",
1476
- "it-IT": "Nome",
1477
- },
1478
- minimum: 0,
1479
- multilingual: false,
1480
- isBuiltIn: true,
1481
- groupId: "Default",
1482
- allowMultipleValues: false,
1483
- },
1479
+ baseBuitInAttribute1,
1480
+ baseBuitInAttribute2,
1481
+ baseBuitInAttribute3,
1482
+ baseBuitInAttribute4,
1484
1483
  ]);
1485
1484
  expect(
1486
1485
  definitionEntityBaseAttributesSelector,
@@ -1495,34 +1494,11 @@ describe("definitions", () => {
1495
1494
 
1496
1495
  it("will return correct full custom customer definition attributes", () => {
1497
1496
  const expected = Immutable.fromJS([
1498
- {
1499
- dataType: "EntityReference",
1500
- isRequired: false,
1501
- name: "InnaCustom1",
1502
- displayOrder: 0,
1503
- isSearchable: false,
1504
- displayName: { "en-CA": "attribute en-CA", "en-US": "attribute en-US", "fr-CA": "" },
1505
- referenceTypeName: "CustomProfile1",
1506
- multilingual: false,
1507
- isBuiltIn: false,
1508
- groupId: "Default",
1509
- allowMultipleValues: true,
1510
- description: "InnaCustomer",
1511
- },
1512
- {
1513
- dataType: "EntityReference",
1514
- isRequired: false,
1515
- name: "InnaCustom2",
1516
- displayOrder: 0,
1517
- isSearchable: false,
1518
- displayName: { "en-CA": "attribute en-CA", "en-US": "attribute en-UA", "fr-CA": "" },
1519
- referenceTypeName: "CustomProfile2",
1520
- multilingual: false,
1521
- isBuiltIn: false,
1522
- groupId: "CustomGroup",
1523
- allowMultipleValues: true,
1524
- description: "InnaCustom2",
1525
- },
1497
+ customProfileAttribute1,
1498
+ customProfileAttribute2,
1499
+ baseCustomAttribute1,
1500
+ baseCustomAttribute2,
1501
+ baseCustomAttribute3,
1526
1502
  ]);
1527
1503
  expect(
1528
1504
  definitionEntityCustomAttributesSelector,
@@ -1535,64 +1511,30 @@ describe("definitions", () => {
1535
1511
  );
1536
1512
  });
1537
1513
 
1538
- it("will return correct customer attributes", () => {
1514
+ it("will return correct customer base (build in) attributes in correct order", () => {
1515
+ const locale = "en-US";
1516
+ const expectedBaseBuitInAttribute1 = {
1517
+ ...baseBuitInAttribute1,
1518
+ ...{ displayName: baseBuitInAttribute1.displayName[locale] },
1519
+ };
1520
+ const expectedBaseBuitInAttribute2 = {
1521
+ ...baseBuitInAttribute2,
1522
+ ...{ displayName: baseBuitInAttribute2.displayName[locale] },
1523
+ };
1524
+ const expectedBaseBuitInAttribute3 = {
1525
+ ...baseBuitInAttribute3,
1526
+ ...{ displayName: baseBuitInAttribute3.displayName[locale] },
1527
+ };
1528
+ const expectedBaseBuitInAttribute4 = {
1529
+ ...baseBuitInAttribute4,
1530
+ ...{ displayName: baseBuitInAttribute4.displayName[locale] },
1531
+ };
1532
+
1539
1533
  const expected = Immutable.fromJS([
1540
- {
1541
- maximum: 256,
1542
- dataType: "Text",
1543
- isRequired: false,
1544
- name: "Username",
1545
- displayOrder: 0,
1546
- isSearchable: true,
1547
- displayName: "User name",
1548
- minimum: 1,
1549
- multilingual: false,
1550
- isBuiltIn: true,
1551
- groupId: "Default",
1552
- allowMultipleValues: false,
1553
- },
1554
- {
1555
- maximum: 256,
1556
- dataType: "Text",
1557
- isRequired: false,
1558
- name: "Email",
1559
- displayOrder: 0,
1560
- isSearchable: true,
1561
- displayName: "Email",
1562
- minimum: 0,
1563
- multilingual: false,
1564
- isBuiltIn: true,
1565
- groupId: "Default",
1566
- allowMultipleValues: false,
1567
- },
1568
- {
1569
- maximum: 64,
1570
- dataType: "Text",
1571
- isRequired: false,
1572
- name: "LastName",
1573
- displayOrder: 0,
1574
- isSearchable: true,
1575
- displayName: "Last name",
1576
- minimum: 0,
1577
- multilingual: false,
1578
- isBuiltIn: true,
1579
- groupId: "Default",
1580
- allowMultipleValues: false,
1581
- },
1582
- {
1583
- maximum: 64,
1584
- dataType: "Text",
1585
- isRequired: false,
1586
- name: "FirstName",
1587
- displayOrder: 0,
1588
- isSearchable: true,
1589
- displayName: "First Name",
1590
- minimum: 0,
1591
- multilingual: false,
1592
- isBuiltIn: true,
1593
- groupId: "Default",
1594
- allowMultipleValues: false,
1595
- },
1534
+ expectedBaseBuitInAttribute1,
1535
+ expectedBaseBuitInAttribute2,
1536
+ expectedBaseBuitInAttribute3,
1537
+ expectedBaseBuitInAttribute4,
1596
1538
  ]);
1597
1539
  expect(
1598
1540
  baseAttributesSelector,
@@ -1606,41 +1548,37 @@ describe("definitions", () => {
1606
1548
  });
1607
1549
 
1608
1550
  it("will return correct customer attributes definition", () => {
1551
+ const locale = "en-US";
1552
+ const expectedProfileAttribute1 = {
1553
+ ...customProfileAttribute1,
1554
+ ...{ displayName: customProfileAttribute1.displayName[locale] },
1555
+ };
1556
+ const expectedProfileAttribute2 = {
1557
+ ...customProfileAttribute2,
1558
+ ...{ displayName: customProfileAttribute2.displayName[locale] },
1559
+ };
1560
+
1561
+ const expectedBase1 = {
1562
+ ...baseCustomAttribute1,
1563
+ ...{ displayName: baseCustomAttribute1.displayName[locale] },
1564
+ };
1565
+
1566
+ const expectedBase2 = {
1567
+ ...baseCustomAttribute2,
1568
+ ...{ displayName: baseCustomAttribute2.displayName[locale] },
1569
+ };
1570
+
1571
+ const expectedBase3 = {
1572
+ ...baseCustomAttribute3,
1573
+ ...{ displayName: baseCustomAttribute3.displayName[locale] },
1574
+ };
1575
+
1609
1576
  const expected = Immutable.fromJS({
1610
1577
  displayName: "Customer",
1611
1578
  entityTypeName: "CUSTOMER",
1612
1579
  isBuiltIn: true,
1613
- baseAttributes: [],
1614
- profileAttributes: [
1615
- {
1616
- dataType: "EntityReference",
1617
- isRequired: false,
1618
- name: "InnaCustom1",
1619
- displayOrder: 0,
1620
- isSearchable: false,
1621
- displayName: "attribute en-US",
1622
- referenceTypeName: "CustomProfile1",
1623
- multilingual: false,
1624
- isBuiltIn: false,
1625
- groupId: "Default",
1626
- allowMultipleValues: true,
1627
- description: "InnaCustomer",
1628
- },
1629
- {
1630
- dataType: "EntityReference",
1631
- isRequired: false,
1632
- name: "InnaCustom2",
1633
- displayOrder: 0,
1634
- isSearchable: false,
1635
- displayName: "attribute en-UA",
1636
- referenceTypeName: "CustomProfile2",
1637
- multilingual: false,
1638
- isBuiltIn: false,
1639
- groupId: "CustomGroup",
1640
- allowMultipleValues: true,
1641
- description: "InnaCustom2",
1642
- },
1643
- ],
1580
+ baseAttributes: [expectedBase1, expectedBase2, expectedBase3],
1581
+ profileAttributes: [expectedProfileAttribute1, expectedProfileAttribute2],
1644
1582
  isSharedEntity: true,
1645
1583
  });
1646
1584
  expect(
@@ -15,7 +15,7 @@ const scopeData = state => state.get("scopes");
15
15
 
16
16
  export const getScopesSelector = createSelector(scopeData, scopes => scopes);
17
17
 
18
- const localizedScopesSelector = createSelector(scopeData, currentLocaleOrDefault, (scopes, locale) =>
18
+ export const localizedScopesSelector = createSelector(scopeData, currentLocaleOrDefault, (scopes, locale) =>
19
19
  scopes.map(scope =>
20
20
  scope.withMutations(s => {
21
21
  setTranslationWithFallbackField(locale, s, "id", "name");
@@ -12,7 +12,7 @@
12
12
  "orc-shared.ccVersion": "Commerce Cloud {version}",
13
13
  "orc-shared.close": "Close",
14
14
  "orc-shared.confirmation": "Confirmation",
15
- "orc-shared.copyright": "© 2021 Orckestra Technologies Inc.",
15
+ "orc-shared.copyright": "© {year} Orckestra Technologies Inc.",
16
16
  "orc-shared.copyrightTermsNotice": "This computer program is protected by copyright laws and international treaties. Unauthorized reproduction or redistribution of this program, or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under the law. Orckestra is a trademark of Orckestra Technologies Inc. All other trademarks are property of the respective owners.",
17
17
  "orc-shared.defaultApp": "Default application",
18
18
  "orc-shared.delete": "Delete",
@@ -12,7 +12,7 @@
12
12
  "orc-shared.ccVersion": "Commerce Cloud {version}",
13
13
  "orc-shared.close": "Fermer",
14
14
  "orc-shared.confirmation": "Confirmation",
15
- "orc-shared.copyright": "© 2021 Technologies Orckestra Inc.",
15
+ "orc-shared.copyright": "© {year} Technologies Orckestra Inc.",
16
16
  "orc-shared.copyrightTermsNotice": "Avertissement: Ce programme est protégé par la loi relative au droit d'auteur et par les conventions internationales. Toute reproduction ou distribution partielle ou totale du logiciel, par quelque moyen que ce soit, est strictement interdite. Toute personne ne respectant pas ces dispositions se rendra coupable du délit de contrefaçon et sera passible des sanctions pénales prévues par la loi. Orckestra est une marque de commerce déposée et détenue par Technologies Orckestra Inc. Toutes les autres marques de commerce sont la propriété de leurs détenteurs respectifs.",
17
17
  "orc-shared.defaultApp": "Application par défaut",
18
18
  "orc-shared.delete": "Supprimer",
@@ -22,7 +22,19 @@ export function getNotLocalizedString(value) {
22
22
  return value && `[${value}]`;
23
23
  }
24
24
 
25
+ export function findCorrespondingLocale(locales, language) {
26
+ return (
27
+ locales[language] ??
28
+ locales[language.replace(/-/g, "")] ??
29
+ locales[language.toLowerCase()] ??
30
+ locales[language.toLowerCase().replace(/-/g, "")] ??
31
+ locales[language.substring(0, 2).toLowerCase()] ??
32
+ null
33
+ );
34
+ }
35
+
25
36
  export default {
26
37
  getLocalization,
27
38
  getNotLocalizedString,
39
+ findCorrespondingLocale,
28
40
  };
@@ -76,3 +76,67 @@ describe("<localizationHelper.getLocalization>", () => {
76
76
  expect(localizationHelper.getLocalization(defaultLocalizations, "it", "fallback"), "to equal", fallbackValue);
77
77
  });
78
78
  });
79
+
80
+ describe("findCorrespondingLocale", () => {
81
+ const locales = {
82
+ fr: "FR",
83
+ enGB: "GB",
84
+ enNZ: "NZ",
85
+ "en-in": "IN",
86
+ enau: "AU",
87
+ "en-IE": "IE",
88
+ frCa: "CA",
89
+ };
90
+
91
+ it("findCorrespondingLocale should return null for en-US", () => {
92
+ expect(localizationHelper.findCorrespondingLocale(locales, "en-US"), "to equal", null);
93
+ });
94
+
95
+ it("findCorrespondingLocale should return FR for fr-FR", () => {
96
+ expect(localizationHelper.findCorrespondingLocale(locales, "fr-FR"), "to equal", "FR");
97
+ });
98
+
99
+ it("findCorrespondingLocale should return FR for fr-fr", () => {
100
+ expect(localizationHelper.findCorrespondingLocale(locales, "fr-fr"), "to equal", "FR");
101
+ });
102
+
103
+ it("findCorrespondingLocale should return FR for frFR", () => {
104
+ expect(localizationHelper.findCorrespondingLocale(locales, "frFR"), "to equal", "FR");
105
+ });
106
+
107
+ it("findCorrespondingLocale should return FR for frfr", () => {
108
+ expect(localizationHelper.findCorrespondingLocale(locales, "frfr"), "to equal", "FR");
109
+ });
110
+
111
+ it("findCorrespondingLocale should return IE for en-IE", () => {
112
+ expect(localizationHelper.findCorrespondingLocale(locales, "en-IE"), "to equal", "IE");
113
+ });
114
+
115
+ it("findCorrespondingLocale should return GB for en-GB", () => {
116
+ expect(localizationHelper.findCorrespondingLocale(locales, "en-GB"), "to equal", "GB");
117
+ });
118
+
119
+ it("findCorrespondingLocale should return GB for en-NZ", () => {
120
+ expect(localizationHelper.findCorrespondingLocale(locales, "en-NZ"), "to equal", "NZ");
121
+ });
122
+
123
+ it("findCorrespondingLocale should return AU for en-AU", () => {
124
+ expect(localizationHelper.findCorrespondingLocale(locales, "en-AU"), "to equal", "AU");
125
+ });
126
+
127
+ it("findCorrespondingLocale should return AU for en-au", () => {
128
+ expect(localizationHelper.findCorrespondingLocale(locales, "en-au"), "to equal", "AU");
129
+ });
130
+
131
+ it("findCorrespondingLocale should return AU for enAU", () => {
132
+ expect(localizationHelper.findCorrespondingLocale(locales, "enAU"), "to equal", "AU");
133
+ });
134
+
135
+ it("findCorrespondingLocale should return IN for en-IN", () => {
136
+ expect(localizationHelper.findCorrespondingLocale(locales, "en-IN"), "to equal", "IN");
137
+ });
138
+
139
+ it("findCorrespondingLocale should return CA for frCa", () => {
140
+ expect(localizationHelper.findCorrespondingLocale(locales, "frCa"), "to equal", "CA");
141
+ });
142
+ });