@underverse-ui/underverse 1.0.51 → 1.0.52

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@underverse-ui/underverse",
3
- "version": "1.0.51",
3
+ "version": "1.0.52",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 239,
6
6
  "exports": [
package/dist/index.cjs CHANGED
@@ -1633,9 +1633,9 @@ var defaultTranslations = {
1633
1633
  ko: ko_default,
1634
1634
  ja: ja_default
1635
1635
  };
1636
- function resolveTranslationValue(translations, namespace, key) {
1637
- const parts = namespace.split(".");
1638
- let current = translations;
1636
+ function resolveObjectPath(input, path) {
1637
+ const parts = path.split(".");
1638
+ let current = input;
1639
1639
  for (const part of parts) {
1640
1640
  if (current && typeof current === "object" && part in current) {
1641
1641
  current = current[part];
@@ -1643,11 +1643,12 @@ function resolveTranslationValue(translations, namespace, key) {
1643
1643
  return null;
1644
1644
  }
1645
1645
  }
1646
- if (current && typeof current === "object" && key in current) {
1647
- const value = current[key];
1648
- return typeof value === "string" ? value : null;
1649
- }
1650
- return null;
1646
+ return current;
1647
+ }
1648
+ function resolveTranslationValue(translations, namespace, key) {
1649
+ const namespaceValue = resolveObjectPath(translations, namespace);
1650
+ const value = resolveObjectPath(namespaceValue, key);
1651
+ return typeof value === "string" ? value : null;
1651
1652
  }
1652
1653
  function getUnderverseDefaultTranslation(locale, namespace, key) {
1653
1654
  return resolveTranslationValue(defaultTranslations[locale] ?? defaultTranslations.en, namespace, key) ?? resolveTranslationValue(defaultTranslations.en, namespace, key) ?? key;
@@ -22449,6 +22450,23 @@ var defaultTranslations2 = {
22449
22450
  }
22450
22451
  }
22451
22452
  };
22453
+ function resolveObjectPath2(input, path) {
22454
+ const parts = path.split(".");
22455
+ let current = input;
22456
+ for (const part of parts) {
22457
+ if (current && typeof current === "object" && part in current) {
22458
+ current = current[part];
22459
+ } else {
22460
+ return null;
22461
+ }
22462
+ }
22463
+ return current;
22464
+ }
22465
+ function resolveTranslationValue2(translations, namespace, key) {
22466
+ const namespaceValue = resolveObjectPath2(translations, namespace);
22467
+ const value = resolveObjectPath2(namespaceValue, key);
22468
+ return typeof value === "string" ? value : null;
22469
+ }
22452
22470
  var TranslationContext2 = React70.createContext(null);
22453
22471
  var UnderverseProvider = ({ children, locale = "en", translations }) => {
22454
22472
  const t = React70.useCallback(
@@ -22458,20 +22476,7 @@ var UnderverseProvider = ({ children, locale = "en", translations }) => {
22458
22476
  ...defaultTranslations2[locale],
22459
22477
  ...translations
22460
22478
  };
22461
- const parts = namespace.split(".");
22462
- let current = mergedTranslations;
22463
- for (const part of parts) {
22464
- if (current && typeof current === "object" && part in current) {
22465
- current = current[part];
22466
- } else {
22467
- return key;
22468
- }
22469
- }
22470
- if (current && typeof current === "object" && key in current) {
22471
- const value = current[key];
22472
- return typeof value === "string" ? value : key;
22473
- }
22474
- return key;
22479
+ return resolveTranslationValue2(mergedTranslations, namespace, key) ?? key;
22475
22480
  };
22476
22481
  },
22477
22482
  [locale, translations]
@@ -22500,20 +22505,8 @@ function interpolate(template, params) {
22500
22505
  function getInternalTranslation(namespace, locale) {
22501
22506
  return (key, params) => {
22502
22507
  const localeTranslations = defaultTranslations2[locale] || defaultTranslations2.en;
22503
- const parts = namespace.split(".");
22504
- let current = localeTranslations;
22505
- for (const part of parts) {
22506
- if (current && typeof current === "object" && part in current) {
22507
- current = current[part];
22508
- } else {
22509
- return interpolate(key, params);
22510
- }
22511
- }
22512
- if (current && typeof current === "object" && key in current) {
22513
- const value = current[key];
22514
- return typeof value === "string" ? interpolate(value, params) : interpolate(key, params);
22515
- }
22516
- return interpolate(key, params);
22508
+ const value = resolveTranslationValue2(localeTranslations, namespace, key);
22509
+ return typeof value === "string" ? interpolate(value, params) : interpolate(key, params);
22517
22510
  };
22518
22511
  }
22519
22512
  function useTranslations(namespace) {