@intlayer/core 7.5.0-canary.0 → 7.5.0

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 (127) hide show
  1. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs +10 -10
  2. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
  3. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs +11 -11
  4. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
  5. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs +4 -4
  6. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
  7. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs +7 -7
  8. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
  9. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +3 -3
  10. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
  11. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs +6 -6
  12. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
  13. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +6 -6
  14. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
  15. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +5 -5
  16. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  17. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +27 -27
  18. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  19. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +5 -5
  20. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  21. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +3 -3
  22. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  23. package/dist/cjs/dictionaryManipulator/getNodeType.cjs +11 -11
  24. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
  25. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +5 -5
  26. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
  27. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +3 -3
  28. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
  29. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +4 -4
  30. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  31. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +4 -4
  32. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  33. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +3 -3
  34. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  35. package/dist/cjs/formatters/compact.cjs +3 -3
  36. package/dist/cjs/formatters/compact.cjs.map +1 -1
  37. package/dist/cjs/formatters/currency.cjs +3 -3
  38. package/dist/cjs/formatters/currency.cjs.map +1 -1
  39. package/dist/cjs/formatters/date.cjs +3 -3
  40. package/dist/cjs/formatters/date.cjs.map +1 -1
  41. package/dist/cjs/formatters/list.cjs +3 -3
  42. package/dist/cjs/formatters/list.cjs.map +1 -1
  43. package/dist/cjs/formatters/number.cjs +3 -3
  44. package/dist/cjs/formatters/number.cjs.map +1 -1
  45. package/dist/cjs/formatters/percentage.cjs +3 -3
  46. package/dist/cjs/formatters/percentage.cjs.map +1 -1
  47. package/dist/cjs/formatters/relativeTime.cjs +3 -3
  48. package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
  49. package/dist/cjs/formatters/units.cjs +3 -3
  50. package/dist/cjs/formatters/units.cjs.map +1 -1
  51. package/dist/cjs/getStorageAttributes.cjs +4 -4
  52. package/dist/cjs/getStorageAttributes.cjs.map +1 -1
  53. package/dist/cjs/interpreter/getContent/deepTransform.cjs +3 -3
  54. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  55. package/dist/cjs/interpreter/getContent/getContent.cjs +3 -3
  56. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  57. package/dist/cjs/interpreter/getContent/plugins.cjs +18 -18
  58. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  59. package/dist/cjs/interpreter/getIntlayer.cjs +7 -7
  60. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  61. package/dist/cjs/localization/getBrowserLocale.cjs +7 -7
  62. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  63. package/dist/cjs/localization/getHTMLTextDir.cjs +39 -26
  64. package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
  65. package/dist/cjs/localization/getLocale.cjs +8 -8
  66. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  67. package/dist/cjs/localization/getLocaleFromPath.cjs +5 -5
  68. package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
  69. package/dist/cjs/localization/getLocalizedUrl.cjs +6 -6
  70. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  71. package/dist/cjs/localization/getMultilingualUrls.cjs +6 -6
  72. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  73. package/dist/cjs/localization/getPathWithoutLocale.cjs +3 -3
  74. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  75. package/dist/cjs/localization/getPrefix.cjs +6 -6
  76. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  77. package/dist/cjs/localization/localeMapper.cjs +6 -6
  78. package/dist/cjs/localization/localeMapper.cjs.map +1 -1
  79. package/dist/cjs/localization/localeResolver.cjs +3 -3
  80. package/dist/cjs/localization/localeResolver.cjs.map +1 -1
  81. package/dist/cjs/localization/validatePrefix.cjs +6 -6
  82. package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
  83. package/dist/cjs/messageFormat/ICU.cjs +5 -5
  84. package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
  85. package/dist/cjs/messageFormat/i18next.cjs +5 -5
  86. package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
  87. package/dist/cjs/messageFormat/verify-icu-format.cjs +65 -0
  88. package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -0
  89. package/dist/cjs/messageFormat/vue-i18n.cjs +5 -5
  90. package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
  91. package/dist/cjs/transpiler/condition/condition.cjs +2 -2
  92. package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
  93. package/dist/cjs/transpiler/enumeration/enumeration.cjs +2 -2
  94. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  95. package/dist/cjs/transpiler/file/file.cjs +7 -7
  96. package/dist/cjs/transpiler/file/file.cjs.map +1 -1
  97. package/dist/cjs/transpiler/file/fileBrowser.cjs +1 -1
  98. package/dist/cjs/transpiler/gender/gender.cjs +2 -2
  99. package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
  100. package/dist/cjs/transpiler/insertion/insertion.cjs +2 -2
  101. package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
  102. package/dist/cjs/transpiler/markdown/markdown.cjs +2 -2
  103. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  104. package/dist/cjs/transpiler/nesting/nesting.cjs +2 -2
  105. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  106. package/dist/cjs/transpiler/translation/translation.cjs +2 -2
  107. package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
  108. package/dist/cjs/utils/intl.cjs +3 -3
  109. package/dist/cjs/utils/intl.cjs.map +1 -1
  110. package/dist/cjs/utils/localeStorage.cjs +5 -5
  111. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  112. package/dist/esm/localization/getHTMLTextDir.mjs +18 -5
  113. package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
  114. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  115. package/dist/esm/messageFormat/verify-icu-format.mjs +65 -0
  116. package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -0
  117. package/dist/esm/utils/intl.mjs +19 -22
  118. package/dist/esm/utils/intl.mjs.map +1 -1
  119. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +8 -8
  120. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -1
  121. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +8 -8
  122. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
  123. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +2 -2
  124. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  125. package/dist/types/messageFormat/ICU.d.ts.map +1 -1
  126. package/dist/types/messageFormat/verify-icu-format.d.ts +1 -0
  127. package/package.json +9 -9
@@ -1,17 +1,17 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_interpreter_getDictionary = require('./getDictionary.cjs');
3
- let __intlayer_config_client = require("@intlayer/config/client");
4
- let __intlayer_config_built = require("@intlayer/config/built");
5
- __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
6
- let __intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
3
+ let _intlayer_config_client = require("@intlayer/config/client");
4
+ let _intlayer_config_built = require("@intlayer/config/built");
5
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
6
+ let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
7
7
 
8
8
  //#region src/interpreter/getIntlayer.ts
9
9
  const getIntlayer = (key, locale, plugins) => {
10
- const dictionaries = (0, __intlayer_dictionaries_entry.getDictionaries)();
10
+ const dictionaries = (0, _intlayer_dictionaries_entry.getDictionaries)();
11
11
  const dictionary = dictionaries[key];
12
12
  if (!dictionary) {
13
- if (__intlayer_config_built.default.build.optimize === true || __intlayer_config_built.default.build.optimize === void 0 && process.env.NODE_ENV === "production") {
14
- (0, __intlayer_config_client.getAppLogger)(__intlayer_config_built.default)("Build optimization is enabled, the dictionary may have been purged. You can disable build optimization, or configure the traversePattern to include the current component.", {
13
+ if (_intlayer_config_built.default.build.optimize === true || _intlayer_config_built.default.build.optimize === void 0 && process.env.NODE_ENV === "production") {
14
+ (0, _intlayer_config_client.getAppLogger)(_intlayer_config_built.default)("Build optimization is enabled, the dictionary may have been purged. You can disable build optimization, or configure the traversePattern to include the current component.", {
15
15
  level: "error",
16
16
  isVerbose: true
17
17
  });
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.cjs","names":["configuration","getDictionary"],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { getAppLogger } from '@intlayer/config/client';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n DictionaryRegistryElement,\n LocalesValues,\n} from '@intlayer/types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryContent<T>,\n IInterpreterPluginState,\n L\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T] as DictionaryRegistryElement<T>;\n\n if (!dictionary) {\n if (\n configuration.build.optimize === true ||\n (configuration.build.optimize === undefined &&\n process.env.NODE_ENV === 'production')\n ) {\n const logger = getAppLogger(configuration);\n\n logger(\n 'Build optimization is enabled, the dictionary may have been purged. You can disable build optimization, or configure the traversePattern to include the current component.',\n {\n level: 'error',\n isVerbose: true,\n }\n );\n throw new Error(\n `Dictionary ${key as string} not found - Build optimization is enabled, the dictionary may have been purged. You can disable build optimization, or configure the 'traversePattern' to include the current component.`,\n dictionaries\n );\n }\n throw new Error(`Dictionary ${key as string} not found`, dictionaries);\n }\n\n return getDictionary<DictionaryRegistryElement<T>, L>(\n dictionary,\n locale,\n plugins\n );\n};\n"],"mappings":";;;;;;;;AAiBA,MAAa,eAIX,KACA,QACA,YAKG;CACH,MAAM,mEAAgC;CACtC,MAAM,aAAa,aAAa;AAEhC,KAAI,CAAC,YAAY;AACf,MACEA,gCAAc,MAAM,aAAa,QAChCA,gCAAc,MAAM,aAAa,UAChC,QAAQ,IAAI,aAAa,cAC3B;AAGA,8CAF4BA,gCAAc,CAGxC,8KACA;IACE,OAAO;IACP,WAAW;IACZ,CACF;AACD,SAAM,IAAI,MACR,cAAc,IAAc,4LAC5B,aACD;;AAEH,QAAM,IAAI,MAAM,cAAc,IAAc,aAAa,aAAa;;AAGxE,QAAOC,gDACL,YACA,QACA,QACD"}
1
+ {"version":3,"file":"getIntlayer.cjs","names":["configuration","getDictionary"],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { getAppLogger } from '@intlayer/config/client';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n DictionaryRegistryElement,\n LocalesValues,\n} from '@intlayer/types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryContent<T>,\n IInterpreterPluginState,\n L\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T] as DictionaryRegistryElement<T>;\n\n if (!dictionary) {\n if (\n configuration.build.optimize === true ||\n (configuration.build.optimize === undefined &&\n process.env.NODE_ENV === 'production')\n ) {\n const logger = getAppLogger(configuration);\n\n logger(\n 'Build optimization is enabled, the dictionary may have been purged. You can disable build optimization, or configure the traversePattern to include the current component.',\n {\n level: 'error',\n isVerbose: true,\n }\n );\n throw new Error(\n `Dictionary ${key as string} not found - Build optimization is enabled, the dictionary may have been purged. You can disable build optimization, or configure the 'traversePattern' to include the current component.`,\n dictionaries\n );\n }\n throw new Error(`Dictionary ${key as string} not found`, dictionaries);\n }\n\n return getDictionary<DictionaryRegistryElement<T>, L>(\n dictionary,\n locale,\n plugins\n );\n};\n"],"mappings":";;;;;;;;AAiBA,MAAa,eAIX,KACA,QACA,YAKG;CACH,MAAM,kEAAgC;CACtC,MAAM,aAAa,aAAa;AAEhC,KAAI,CAAC,YAAY;AACf,MACEA,+BAAc,MAAM,aAAa,QAChCA,+BAAc,MAAM,aAAa,UAChC,QAAQ,IAAI,aAAa,cAC3B;AAGA,6CAF4BA,+BAAc,CAGxC,8KACA;IACE,OAAO;IACP,WAAW;IACZ,CACF;AACD,SAAM,IAAI,MACR,cAAc,IAAc,4LAC5B,aACD;;AAEH,QAAM,IAAI,MAAM,cAAc,IAAc,aAAa,aAAa;;AAGxE,QAAOC,gDACL,YACA,QACA,QACD"}
@@ -1,9 +1,9 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_localization_localeDetector = require('./localeDetector.cjs');
3
3
  const require_utils_localeStorage = require('../utils/localeStorage.cjs');
4
- let __intlayer_types = require("@intlayer/types");
5
- let __intlayer_config_built = require("@intlayer/config/built");
6
- __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
4
+ let _intlayer_types = require("@intlayer/types");
5
+ let _intlayer_config_built = require("@intlayer/config/built");
6
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
7
7
 
8
8
  //#region src/localization/getBrowserLocale.tsx
9
9
  let LanguageDetector = /* @__PURE__ */ function(LanguageDetector$1) {
@@ -78,7 +78,7 @@ const detectLanguage = (order, options) => {
78
78
  };
79
79
  const navigatorDetector = () => {
80
80
  if (typeof navigator === "undefined") return;
81
- const { internationalization } = __intlayer_config_built.default;
81
+ const { internationalization } = _intlayer_config_built.default;
82
82
  const languages = navigator.languages ?? [navigator.language];
83
83
  const locale = require_localization_localeDetector.localeDetector({ "accept-language": languages.join(",") }, internationalization.locales, internationalization.defaultLocale);
84
84
  if (locale) detected[LanguageDetector.Navigator] = locale;
@@ -88,7 +88,7 @@ const detectLanguage = (order, options) => {
88
88
  if (htmlTag && typeof htmlTag.getAttribute === "function") {
89
89
  const lang = htmlTag.getAttribute("lang");
90
90
  if (lang) {
91
- const { internationalization } = __intlayer_config_built.default;
91
+ const { internationalization } = _intlayer_config_built.default;
92
92
  const locale = require_localization_localeDetector.localeDetector({ "accept-language": lang }, internationalization.locales, internationalization.defaultLocale);
93
93
  detected[LanguageDetector.HtmlTag] = locale;
94
94
  }
@@ -106,12 +106,12 @@ const detectLanguage = (order, options) => {
106
106
  return detected;
107
107
  };
108
108
  const getFirstAvailableLocale = (locales, order) => {
109
- const { internationalization } = __intlayer_config_built.default;
109
+ const { internationalization } = _intlayer_config_built.default;
110
110
  for (const detector of order) {
111
111
  const locale = locales[detector];
112
112
  if (locale && internationalization.locales.includes(locale)) return locale;
113
113
  }
114
- return internationalization?.defaultLocale ?? __intlayer_types.Locales.ENGLISH;
114
+ return internationalization?.defaultLocale ?? _intlayer_types.Locales.ENGLISH;
115
115
  };
116
116
  /**
117
117
  * Core language detector function for browser environments.
@@ -1 +1 @@
1
- {"version":3,"file":"getBrowserLocale.cjs","names":["localeStorageOptions: LocaleStorageOptions","detected: Record<LanguageDetector, Locale | undefined>","getLocaleFromStorage","configuration","localeDetector","detectors: Record<string, () => void>","Locales"],"sources":["../../../src/localization/getBrowserLocale.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { type Locale, Locales } from '@intlayer/types';\nimport {\n getLocaleFromStorage,\n type LocaleStorageOptions,\n} from '../utils/localeStorage';\nimport { localeDetector } from './localeDetector';\n\nexport enum LanguageDetector {\n Querystring = 'querystring',\n Storage = 'storage',\n Navigator = 'navigator',\n HtmlTag = 'htmlTag',\n}\n\nexport const localeStorageOptions: LocaleStorageOptions = {\n getCookie: (name: string) =>\n document.cookie\n .split(';')\n .find((c) => c.trim().startsWith(`${name}=`))\n ?.split('=')[1],\n getLocaleStorage: (name: string) => localStorage.getItem(name),\n getSessionStorage: (name: string) => sessionStorage.getItem(name),\n isCookieEnabled: true,\n setCookieStore: (name, value, attributes) =>\n cookieStore.set({\n name,\n value,\n path: attributes.path,\n domain: attributes.domain,\n expires: attributes.expires,\n sameSite: attributes.sameSite,\n }),\n setCookieString: (cookie) => {\n // biome-ignore lint/suspicious/noDocumentCookie: set cookie fallback\n document.cookie = cookie;\n },\n setSessionStorage: (name, value) => sessionStorage.setItem(name, value),\n setLocaleStorage: (name, value) => localStorage.setItem(name, value),\n};\n\n// Default settings for the language detector\ntype LanguageDetectorOptions = {\n order?: LanguageDetector[];\n lookupQuerystring?: string;\n htmlTag?: HTMLElement | null;\n};\n\nconst getDefaultsOptions = (): LanguageDetectorOptions => {\n return {\n order: [\n LanguageDetector.Querystring,\n LanguageDetector.Storage,\n LanguageDetector.Navigator,\n LanguageDetector.HtmlTag,\n ],\n lookupQuerystring: 'locale',\n htmlTag: typeof document !== 'undefined' ? document.documentElement : null,\n };\n};\n\nconst detectLanguage = (\n order: string[],\n options: LanguageDetectorOptions\n): Record<LanguageDetector, Locale | undefined> => {\n const detected: Record<LanguageDetector, Locale | undefined> = {} as Record<\n LanguageDetector,\n Locale | undefined\n >;\n\n const queryStringDetector = () => {\n if (typeof window === 'undefined') return;\n const search = window.location.search || '';\n const params = new URLSearchParams(search);\n const value = params.get(options.lookupQuerystring ?? '');\n if (value) {\n detected[LanguageDetector.Querystring] = value as Locale;\n }\n };\n\n const storageDetector = () => {\n if (typeof window === 'undefined') return;\n\n const locale = getLocaleFromStorage({\n getCookie: (name: string) => {\n try {\n const cookies = document.cookie.split(';');\n const cookieName = `${name}=`;\n const cookie = cookies.find((c) => c.trim().startsWith(cookieName));\n if (cookie) {\n return cookie.split('=')[1].trim();\n }\n } catch {}\n return undefined;\n },\n getSessionStorage: (name: string) => {\n try {\n return window.sessionStorage.getItem(name) ?? undefined;\n } catch {}\n return undefined;\n },\n getLocaleStorage: (name: string) => {\n try {\n return window.localStorage.getItem(name) ?? undefined;\n } catch {}\n return undefined;\n },\n });\n\n if (locale) {\n detected[LanguageDetector.Storage] = locale;\n }\n };\n\n const navigatorDetector = () => {\n if (typeof navigator === 'undefined') return;\n\n const { internationalization } = configuration;\n const languages = navigator.languages ?? [navigator.language];\n\n // Use localeDetector to find the best matching locale\n const locale = localeDetector(\n { 'accept-language': languages.join(',') },\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n if (locale) {\n detected[LanguageDetector.Navigator] = locale;\n }\n };\n\n const htmlTagDetector = () => {\n const htmlTag = options.htmlTag;\n if (htmlTag && typeof htmlTag.getAttribute === 'function') {\n const lang = htmlTag.getAttribute('lang');\n if (lang) {\n const { internationalization } = configuration;\n\n // Validate and resolve the locale\n const locale = localeDetector(\n { 'accept-language': lang },\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n detected[LanguageDetector.HtmlTag] = locale;\n }\n }\n };\n\n // Map detector names to their corresponding functions\n const detectors: Record<string, () => void> = {\n [LanguageDetector.Querystring]: queryStringDetector,\n [LanguageDetector.Storage]: storageDetector,\n [LanguageDetector.Navigator]: navigatorDetector,\n [LanguageDetector.HtmlTag]: htmlTagDetector,\n };\n\n // Use the provided order to run each detector\n order.forEach((detectorName) => {\n detectors[detectorName]?.();\n });\n\n return detected;\n};\n\nconst getFirstAvailableLocale = (\n locales: Record<LanguageDetector, Locale | undefined>,\n order: LanguageDetector[]\n): Locale => {\n const { internationalization } = configuration;\n\n for (const detector of order) {\n const locale = locales[detector];\n\n if (locale && internationalization.locales.includes(locale)) {\n return locale;\n }\n }\n\n return internationalization?.defaultLocale ?? Locales.ENGLISH;\n};\n\n/**\n * Core language detector function for browser environments.\n *\n * Detects the user's preferred locale by checking multiple sources in order:\n * 1. Query string parameter\n * 2. Storage (cookies, localStorage, sessionStorage) - uses getLocaleFromStorage\n * 3. Navigator languages - uses localeDetector\n * 4. HTML lang attribute - uses localeDetector\n *\n * @param userOptions - Optional configuration for detection order and lookup keys\n * @returns The detected locale or the default locale\n *\n * @example\n * const locale = getBrowserLocale({ order: [LanguageDetector.Storage, LanguageDetector.Navigator] });\n */\nexport const getBrowserLocale = (\n userOptions: LanguageDetectorOptions | undefined = {}\n): Locale => {\n const options = { ...getDefaultsOptions(), ...userOptions };\n\n const locales = detectLanguage(options.order ?? [], options);\n\n return getFirstAvailableLocale(locales, options.order ?? []);\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"getBrowserLocale.cjs","names":["localeStorageOptions: LocaleStorageOptions","detected: Record<LanguageDetector, Locale | undefined>","getLocaleFromStorage","configuration","localeDetector","detectors: Record<string, () => void>","Locales"],"sources":["../../../src/localization/getBrowserLocale.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { type Locale, Locales } from '@intlayer/types';\nimport {\n getLocaleFromStorage,\n type LocaleStorageOptions,\n} from '../utils/localeStorage';\nimport { localeDetector } from './localeDetector';\n\nexport enum LanguageDetector {\n Querystring = 'querystring',\n Storage = 'storage',\n Navigator = 'navigator',\n HtmlTag = 'htmlTag',\n}\n\nexport const localeStorageOptions: LocaleStorageOptions = {\n getCookie: (name: string) =>\n document.cookie\n .split(';')\n .find((c) => c.trim().startsWith(`${name}=`))\n ?.split('=')[1],\n getLocaleStorage: (name: string) => localStorage.getItem(name),\n getSessionStorage: (name: string) => sessionStorage.getItem(name),\n isCookieEnabled: true,\n setCookieStore: (name, value, attributes) =>\n cookieStore.set({\n name,\n value,\n path: attributes.path,\n domain: attributes.domain,\n expires: attributes.expires,\n sameSite: attributes.sameSite,\n }),\n setCookieString: (cookie) => {\n // biome-ignore lint/suspicious/noDocumentCookie: set cookie fallback\n document.cookie = cookie;\n },\n setSessionStorage: (name, value) => sessionStorage.setItem(name, value),\n setLocaleStorage: (name, value) => localStorage.setItem(name, value),\n};\n\n// Default settings for the language detector\ntype LanguageDetectorOptions = {\n order?: LanguageDetector[];\n lookupQuerystring?: string;\n htmlTag?: HTMLElement | null;\n};\n\nconst getDefaultsOptions = (): LanguageDetectorOptions => {\n return {\n order: [\n LanguageDetector.Querystring,\n LanguageDetector.Storage,\n LanguageDetector.Navigator,\n LanguageDetector.HtmlTag,\n ],\n lookupQuerystring: 'locale',\n htmlTag: typeof document !== 'undefined' ? document.documentElement : null,\n };\n};\n\nconst detectLanguage = (\n order: string[],\n options: LanguageDetectorOptions\n): Record<LanguageDetector, Locale | undefined> => {\n const detected: Record<LanguageDetector, Locale | undefined> = {} as Record<\n LanguageDetector,\n Locale | undefined\n >;\n\n const queryStringDetector = () => {\n if (typeof window === 'undefined') return;\n const search = window.location.search || '';\n const params = new URLSearchParams(search);\n const value = params.get(options.lookupQuerystring ?? '');\n if (value) {\n detected[LanguageDetector.Querystring] = value as Locale;\n }\n };\n\n const storageDetector = () => {\n if (typeof window === 'undefined') return;\n\n const locale = getLocaleFromStorage({\n getCookie: (name: string) => {\n try {\n const cookies = document.cookie.split(';');\n const cookieName = `${name}=`;\n const cookie = cookies.find((c) => c.trim().startsWith(cookieName));\n if (cookie) {\n return cookie.split('=')[1].trim();\n }\n } catch {}\n return undefined;\n },\n getSessionStorage: (name: string) => {\n try {\n return window.sessionStorage.getItem(name) ?? undefined;\n } catch {}\n return undefined;\n },\n getLocaleStorage: (name: string) => {\n try {\n return window.localStorage.getItem(name) ?? undefined;\n } catch {}\n return undefined;\n },\n });\n\n if (locale) {\n detected[LanguageDetector.Storage] = locale;\n }\n };\n\n const navigatorDetector = () => {\n if (typeof navigator === 'undefined') return;\n\n const { internationalization } = configuration;\n const languages = navigator.languages ?? [navigator.language];\n\n // Use localeDetector to find the best matching locale\n const locale = localeDetector(\n { 'accept-language': languages.join(',') },\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n if (locale) {\n detected[LanguageDetector.Navigator] = locale;\n }\n };\n\n const htmlTagDetector = () => {\n const htmlTag = options.htmlTag;\n if (htmlTag && typeof htmlTag.getAttribute === 'function') {\n const lang = htmlTag.getAttribute('lang');\n if (lang) {\n const { internationalization } = configuration;\n\n // Validate and resolve the locale\n const locale = localeDetector(\n { 'accept-language': lang },\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n detected[LanguageDetector.HtmlTag] = locale;\n }\n }\n };\n\n // Map detector names to their corresponding functions\n const detectors: Record<string, () => void> = {\n [LanguageDetector.Querystring]: queryStringDetector,\n [LanguageDetector.Storage]: storageDetector,\n [LanguageDetector.Navigator]: navigatorDetector,\n [LanguageDetector.HtmlTag]: htmlTagDetector,\n };\n\n // Use the provided order to run each detector\n order.forEach((detectorName) => {\n detectors[detectorName]?.();\n });\n\n return detected;\n};\n\nconst getFirstAvailableLocale = (\n locales: Record<LanguageDetector, Locale | undefined>,\n order: LanguageDetector[]\n): Locale => {\n const { internationalization } = configuration;\n\n for (const detector of order) {\n const locale = locales[detector];\n\n if (locale && internationalization.locales.includes(locale)) {\n return locale;\n }\n }\n\n return internationalization?.defaultLocale ?? Locales.ENGLISH;\n};\n\n/**\n * Core language detector function for browser environments.\n *\n * Detects the user's preferred locale by checking multiple sources in order:\n * 1. Query string parameter\n * 2. Storage (cookies, localStorage, sessionStorage) - uses getLocaleFromStorage\n * 3. Navigator languages - uses localeDetector\n * 4. HTML lang attribute - uses localeDetector\n *\n * @param userOptions - Optional configuration for detection order and lookup keys\n * @returns The detected locale or the default locale\n *\n * @example\n * const locale = getBrowserLocale({ order: [LanguageDetector.Storage, LanguageDetector.Navigator] });\n */\nexport const getBrowserLocale = (\n userOptions: LanguageDetectorOptions | undefined = {}\n): Locale => {\n const options = { ...getDefaultsOptions(), ...userOptions };\n\n const locales = detectLanguage(options.order ?? [], options);\n\n return getFirstAvailableLocale(locales, options.order ?? []);\n};\n"],"mappings":"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"}
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- let __intlayer_types = require("@intlayer/types");
2
+ let _intlayer_types = require("@intlayer/types");
3
3
 
4
4
  //#region src/localization/getHTMLTextDir.ts
5
5
  /**
@@ -17,31 +17,44 @@ let __intlayer_types = require("@intlayer/types");
17
17
  */
18
18
  const getHTMLTextDir = (locale) => {
19
19
  switch (locale) {
20
- case __intlayer_types.Locales.ARABIC:
21
- case __intlayer_types.Locales.FARSI:
22
- case __intlayer_types.Locales.URDU:
23
- case __intlayer_types.Locales.PASHTO:
24
- case __intlayer_types.Locales.SYRIAC:
25
- case __intlayer_types.Locales.ARABIC_UNITED_ARAB_EMIRATES:
26
- case __intlayer_types.Locales.ARABIC_BAHRAIN:
27
- case __intlayer_types.Locales.ARABIC_ALGERIA:
28
- case __intlayer_types.Locales.ARABIC_EGYPT:
29
- case __intlayer_types.Locales.ARABIC_IRAQ:
30
- case __intlayer_types.Locales.ARABIC_JORDAN:
31
- case __intlayer_types.Locales.ARABIC_KUWAIT:
32
- case __intlayer_types.Locales.ARABIC_LEBANON:
33
- case __intlayer_types.Locales.ARABIC_LIBYA:
34
- case __intlayer_types.Locales.ARABIC_MOROCCO:
35
- case __intlayer_types.Locales.ARABIC_OMAN:
36
- case __intlayer_types.Locales.ARABIC_QATAR:
37
- case __intlayer_types.Locales.ARABIC_SAUDI_ARABIA:
38
- case __intlayer_types.Locales.ARABIC_SYRIA:
39
- case __intlayer_types.Locales.ARABIC_TUNISIA:
40
- case __intlayer_types.Locales.ARABIC_YEMEN:
41
- case __intlayer_types.Locales.FARSI_IRAN:
42
- case __intlayer_types.Locales.URDU_ISLAMIC_REPUBLIC_OF_PAKISTAN:
43
- case __intlayer_types.Locales.PASHTO_AFGHANISTAN:
44
- case __intlayer_types.Locales.SYRIAC_SYRIA: return "rtl";
20
+ case _intlayer_types.Locales.ARABIC:
21
+ case _intlayer_types.Locales.ARABIC_UNITED_ARAB_EMIRATES:
22
+ case _intlayer_types.Locales.ARABIC_BAHRAIN:
23
+ case _intlayer_types.Locales.ARABIC_ALGERIA:
24
+ case _intlayer_types.Locales.ARABIC_EGYPT:
25
+ case _intlayer_types.Locales.ARABIC_IRAQ:
26
+ case _intlayer_types.Locales.ARABIC_JORDAN:
27
+ case _intlayer_types.Locales.ARABIC_KUWAIT:
28
+ case _intlayer_types.Locales.ARABIC_LEBANON:
29
+ case _intlayer_types.Locales.ARABIC_LIBYA:
30
+ case _intlayer_types.Locales.ARABIC_MOROCCO:
31
+ case _intlayer_types.Locales.ARABIC_OMAN:
32
+ case _intlayer_types.Locales.ARABIC_QATAR:
33
+ case _intlayer_types.Locales.ARABIC_SAUDI_ARABIA:
34
+ case _intlayer_types.Locales.ARABIC_SYRIA:
35
+ case _intlayer_types.Locales.ARABIC_TUNISIA:
36
+ case _intlayer_types.Locales.ARABIC_YEMEN:
37
+ case _intlayer_types.Locales.ARABIC_MAURITANIA:
38
+ case _intlayer_types.Locales.ARABIC_PALESTINE:
39
+ case _intlayer_types.Locales.ARABIC_SUDAN:
40
+ case _intlayer_types.Locales.ARABIC_DJIBOUTI:
41
+ case _intlayer_types.Locales.ARABIC_SOMALIA:
42
+ case _intlayer_types.Locales.ARABIC_CHAD:
43
+ case _intlayer_types.Locales.ARABIC_COMOROS:
44
+ case _intlayer_types.Locales.HEBREW:
45
+ case _intlayer_types.Locales.HEBREW_ISRAEL:
46
+ case _intlayer_types.Locales.FARSI:
47
+ case _intlayer_types.Locales.FARSI_IRAN:
48
+ case _intlayer_types.Locales.URDU:
49
+ case _intlayer_types.Locales.URDU_ISLAMIC_REPUBLIC_OF_PAKISTAN:
50
+ case _intlayer_types.Locales.PASHTO:
51
+ case _intlayer_types.Locales.PASHTO_AFGHANISTAN:
52
+ case _intlayer_types.Locales.SYRIAC:
53
+ case _intlayer_types.Locales.SYRIAC_SYRIA:
54
+ case _intlayer_types.Locales.DIVEHI:
55
+ case _intlayer_types.Locales.DIVEHI_MALDIVES:
56
+ case _intlayer_types.Locales.YIDDISH:
57
+ case _intlayer_types.Locales.YIDDISH_WORLD: return "rtl";
45
58
  default: return "ltr";
46
59
  }
47
60
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getHTMLTextDir.cjs","names":["Locales"],"sources":["../../../src/localization/getHTMLTextDir.ts"],"sourcesContent":["import { Locales, type LocalesValues } from '@intlayer/types';\n\ntype Dir = 'ltr' | 'rtl' | 'auto';\n\n/**\n * Returns the text direction of the given locale.\n *\n * Example:\n *\n * getHTMLTextDir('en-US') // 'ltr'\n * getHTMLTextDir('en') // 'ltr'\n * getHTMLTextDir('fr-CA') // 'ltr'\n * getHTMLTextDir('fr') // 'ltr'\n *\n * @param locale The locale to get the text direction for.\n * @returns The text direction of the given locale.\n */\nexport const getHTMLTextDir = (locale?: LocalesValues): Dir => {\n switch (locale) {\n case Locales.ARABIC:\n case Locales.FARSI:\n case Locales.URDU:\n case Locales.PASHTO:\n case Locales.SYRIAC:\n case Locales.ARABIC_UNITED_ARAB_EMIRATES:\n case Locales.ARABIC_BAHRAIN:\n case Locales.ARABIC_ALGERIA:\n case Locales.ARABIC_EGYPT:\n case Locales.ARABIC_IRAQ:\n case Locales.ARABIC_JORDAN:\n case Locales.ARABIC_KUWAIT:\n case Locales.ARABIC_LEBANON:\n case Locales.ARABIC_LIBYA:\n case Locales.ARABIC_MOROCCO:\n case Locales.ARABIC_OMAN:\n case Locales.ARABIC_QATAR:\n case Locales.ARABIC_SAUDI_ARABIA:\n case Locales.ARABIC_SYRIA:\n case Locales.ARABIC_TUNISIA:\n case Locales.ARABIC_YEMEN:\n case Locales.FARSI_IRAN:\n case Locales.URDU_ISLAMIC_REPUBLIC_OF_PAKISTAN:\n case Locales.PASHTO_AFGHANISTAN:\n case Locales.SYRIAC_SYRIA:\n return 'rtl';\n\n default:\n return 'ltr';\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,kBAAkB,WAAgC;AAC7D,SAAQ,QAAR;EACE,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ;EACb,KAAKA,yBAAQ,aACX,QAAO;EAET,QACE,QAAO"}
1
+ {"version":3,"file":"getHTMLTextDir.cjs","names":["Locales"],"sources":["../../../src/localization/getHTMLTextDir.ts"],"sourcesContent":["import { Locales, type LocalesValues } from '@intlayer/types';\n\ntype Dir = 'ltr' | 'rtl' | 'auto';\n\n/**\n * Returns the text direction of the given locale.\n *\n * Example:\n *\n * getHTMLTextDir('en-US') // 'ltr'\n * getHTMLTextDir('en') // 'ltr'\n * getHTMLTextDir('fr-CA') // 'ltr'\n * getHTMLTextDir('fr') // 'ltr'\n *\n * @param locale The locale to get the text direction for.\n * @returns The text direction of the given locale.\n */\nexport const getHTMLTextDir = (locale?: LocalesValues): Dir => {\n switch (locale) {\n // Arabic (uses Arabic script)\n case Locales.ARABIC:\n case Locales.ARABIC_UNITED_ARAB_EMIRATES:\n case Locales.ARABIC_BAHRAIN:\n case Locales.ARABIC_ALGERIA:\n case Locales.ARABIC_EGYPT:\n case Locales.ARABIC_IRAQ:\n case Locales.ARABIC_JORDAN:\n case Locales.ARABIC_KUWAIT:\n case Locales.ARABIC_LEBANON:\n case Locales.ARABIC_LIBYA:\n case Locales.ARABIC_MOROCCO:\n case Locales.ARABIC_OMAN:\n case Locales.ARABIC_QATAR:\n case Locales.ARABIC_SAUDI_ARABIA:\n case Locales.ARABIC_SYRIA:\n case Locales.ARABIC_TUNISIA:\n case Locales.ARABIC_YEMEN:\n case Locales.ARABIC_MAURITANIA:\n case Locales.ARABIC_PALESTINE:\n case Locales.ARABIC_SUDAN:\n case Locales.ARABIC_DJIBOUTI:\n case Locales.ARABIC_SOMALIA:\n case Locales.ARABIC_CHAD:\n case Locales.ARABIC_COMOROS:\n // Hebrew (uses Hebrew script)\n case Locales.HEBREW:\n case Locales.HEBREW_ISRAEL:\n // Farsi/Persian (uses Arabic script)\n case Locales.FARSI:\n case Locales.FARSI_IRAN:\n // Urdu (uses Arabic script)\n case Locales.URDU:\n case Locales.URDU_ISLAMIC_REPUBLIC_OF_PAKISTAN:\n // Pashto (uses Arabic script)\n case Locales.PASHTO:\n case Locales.PASHTO_AFGHANISTAN:\n // Syriac (uses Syriac script)\n case Locales.SYRIAC:\n case Locales.SYRIAC_SYRIA:\n // Divehi (uses Thaana script)\n case Locales.DIVEHI:\n case Locales.DIVEHI_MALDIVES:\n // Yiddish (uses Hebrew script)\n case Locales.YIDDISH:\n case Locales.YIDDISH_WORLD:\n return 'rtl';\n\n default:\n return 'ltr';\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,kBAAkB,WAAgC;AAC7D,SAAQ,QAAR;EAEE,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EAEb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EAEb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EAEb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EAEb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EAEb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EAEb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ;EAEb,KAAKA,wBAAQ;EACb,KAAKA,wBAAQ,cACX,QAAO;EAET,QACE,QAAO"}
@@ -1,22 +1,22 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_localization_localeDetector = require('./localeDetector.cjs');
3
- let __intlayer_config_client = require("@intlayer/config/client");
4
- let __intlayer_config_built = require("@intlayer/config/built");
5
- __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
6
- let __intlayer_core = require("@intlayer/core");
3
+ let _intlayer_config_client = require("@intlayer/config/client");
4
+ let _intlayer_config_built = require("@intlayer/config/built");
5
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
6
+ let _intlayer_core = require("@intlayer/core");
7
7
 
8
8
  //#region src/localization/getLocale.ts
9
9
  const getLocale = async (ctx = {}) => {
10
- const defaultLocale = __intlayer_config_built.default?.internationalization?.defaultLocale ?? __intlayer_config_client.DefaultValues.Internationalization.DEFAULT_LOCALE;
11
- const availableLocales = __intlayer_config_built.default?.internationalization?.locales ?? __intlayer_config_client.DefaultValues.Internationalization.LOCALES;
12
- const storedLocale = (0, __intlayer_core.getLocaleFromStorage)({
10
+ const defaultLocale = _intlayer_config_built.default?.internationalization?.defaultLocale ?? _intlayer_config_client.DefaultValues.Internationalization.DEFAULT_LOCALE;
11
+ const availableLocales = _intlayer_config_built.default?.internationalization?.locales ?? _intlayer_config_client.DefaultValues.Internationalization.LOCALES;
12
+ const storedLocale = (0, _intlayer_core.getLocaleFromStorage)({
13
13
  getCookie: ctx.getCookie,
14
14
  getHeader: ctx.getHeader
15
15
  });
16
16
  if (storedLocale) return storedLocale;
17
17
  const acceptLanguageHeader = ctx.getHeader?.("accept-language");
18
18
  if (!acceptLanguageHeader) return defaultLocale;
19
- const userFallbackLocale = (0, __intlayer_core.localeResolver)(require_localization_localeDetector.getPreferredLanguages(acceptLanguageHeader, availableLocales), availableLocales, defaultLocale);
19
+ const userFallbackLocale = (0, _intlayer_core.localeResolver)(require_localization_localeDetector.getPreferredLanguages(acceptLanguageHeader, availableLocales), availableLocales, defaultLocale);
20
20
  if (userFallbackLocale) return userFallbackLocale;
21
21
  return defaultLocale;
22
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getLocale.cjs","names":["configuration","DefaultValues","getPreferredLanguages"],"sources":["../../../src/localization/getLocale.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport { getLocaleFromStorage, localeResolver } from '@intlayer/core';\nimport type { Locale } from '@intlayer/types';\nimport { getPreferredLanguages } from './localeDetector';\n\nexport type RequestContext = {\n getHeader?: (name: string) => string | null | undefined;\n getCookie?: (name: string) => string | null | undefined;\n};\n\nexport const getLocale = async (ctx: RequestContext = {}): Promise<Locale> => {\n const defaultLocale =\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE;\n const availableLocales =\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES;\n\n // Try locale from storage (cookie or header)\n const storedLocale = getLocaleFromStorage({\n getCookie: ctx.getCookie,\n getHeader: ctx.getHeader,\n });\n\n if (storedLocale) {\n return storedLocale;\n }\n\n // Fallback to Accept-Language negotiation\n const acceptLanguageHeader = ctx.getHeader?.('accept-language');\n\n if (!acceptLanguageHeader) {\n return defaultLocale;\n }\n\n const preferredLocaleStrings = getPreferredLanguages(\n acceptLanguageHeader,\n availableLocales\n );\n\n const userFallbackLocale = localeResolver(\n preferredLocaleStrings,\n availableLocales,\n defaultLocale\n );\n\n if (userFallbackLocale) {\n return userFallbackLocale;\n }\n\n // Default locale\n return defaultLocale;\n};\n"],"mappings":";;;;;;;;AAWA,MAAa,YAAY,OAAO,MAAsB,EAAE,KAAsB;CAC5E,MAAM,gBACJA,iCAAe,sBAAsB,iBACrCC,uCAAc,qBAAqB;CACrC,MAAM,mBACJD,iCAAe,sBAAsB,WACrCC,uCAAc,qBAAqB;CAGrC,MAAM,yDAAoC;EACxC,WAAW,IAAI;EACf,WAAW,IAAI;EAChB,CAAC;AAEF,KAAI,aACF,QAAO;CAIT,MAAM,uBAAuB,IAAI,YAAY,kBAAkB;AAE/D,KAAI,CAAC,qBACH,QAAO;CAQT,MAAM,yDALyBC,0DAC7B,sBACA,iBACD,EAIC,kBACA,cACD;AAED,KAAI,mBACF,QAAO;AAIT,QAAO"}
1
+ {"version":3,"file":"getLocale.cjs","names":["configuration","DefaultValues","getPreferredLanguages"],"sources":["../../../src/localization/getLocale.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport { getLocaleFromStorage, localeResolver } from '@intlayer/core';\nimport type { Locale } from '@intlayer/types';\nimport { getPreferredLanguages } from './localeDetector';\n\nexport type RequestContext = {\n getHeader?: (name: string) => string | null | undefined;\n getCookie?: (name: string) => string | null | undefined;\n};\n\nexport const getLocale = async (ctx: RequestContext = {}): Promise<Locale> => {\n const defaultLocale =\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE;\n const availableLocales =\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES;\n\n // Try locale from storage (cookie or header)\n const storedLocale = getLocaleFromStorage({\n getCookie: ctx.getCookie,\n getHeader: ctx.getHeader,\n });\n\n if (storedLocale) {\n return storedLocale;\n }\n\n // Fallback to Accept-Language negotiation\n const acceptLanguageHeader = ctx.getHeader?.('accept-language');\n\n if (!acceptLanguageHeader) {\n return defaultLocale;\n }\n\n const preferredLocaleStrings = getPreferredLanguages(\n acceptLanguageHeader,\n availableLocales\n );\n\n const userFallbackLocale = localeResolver(\n preferredLocaleStrings,\n availableLocales,\n defaultLocale\n );\n\n if (userFallbackLocale) {\n return userFallbackLocale;\n }\n\n // Default locale\n return defaultLocale;\n};\n"],"mappings":";;;;;;;;AAWA,MAAa,YAAY,OAAO,MAAsB,EAAE,KAAsB;CAC5E,MAAM,gBACJA,gCAAe,sBAAsB,iBACrCC,sCAAc,qBAAqB;CACrC,MAAM,mBACJD,gCAAe,sBAAsB,WACrCC,sCAAc,qBAAqB;CAGrC,MAAM,wDAAoC;EACxC,WAAW,IAAI;EACf,WAAW,IAAI;EAChB,CAAC;AAEF,KAAI,aACF,QAAO;CAIT,MAAM,uBAAuB,IAAI,YAAY,kBAAkB;AAE/D,KAAI,CAAC,qBACH,QAAO;CAQT,MAAM,wDALyBC,0DAC7B,sBACA,iBACD,EAIC,kBACA,cACD;AAED,KAAI,mBACF,QAAO;AAIT,QAAO"}
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_utils_checkIsURLAbsolute = require('../utils/checkIsURLAbsolute.cjs');
3
- let __intlayer_types = require("@intlayer/types");
4
- let __intlayer_config_built = require("@intlayer/config/built");
5
- __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
3
+ let _intlayer_types = require("@intlayer/types");
4
+ let _intlayer_config_built = require("@intlayer/config/built");
5
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
6
6
 
7
7
  //#region src/localization/getLocaleFromPath.ts
8
8
  /**
@@ -25,8 +25,8 @@ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_bui
25
25
  * @returns The detected locale or default (en) if no locale is found
26
26
  */
27
27
  const getLocaleFromPath = (inputUrl) => {
28
- const { defaultLocale, locales } = __intlayer_config_built.default?.internationalization ?? {};
29
- if (!defaultLocale || !locales) return __intlayer_types.Locales.ENGLISH;
28
+ const { defaultLocale, locales } = _intlayer_config_built.default?.internationalization ?? {};
29
+ if (!defaultLocale || !locales) return _intlayer_types.Locales.ENGLISH;
30
30
  const isAbsoluteUrl = require_utils_checkIsURLAbsolute.checkIsURLAbsolute(inputUrl);
31
31
  let fixedInputUrl = inputUrl;
32
32
  if (inputUrl.endsWith("/")) fixedInputUrl = inputUrl.slice(0, -1);
@@ -1 +1 @@
1
- {"version":3,"file":"getLocaleFromPath.cjs","names":["configuration","Locales","checkIsURLAbsolute"],"sources":["../../../src/localization/getLocaleFromPath.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { type Locale, Locales } from '@intlayer/types';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\n\n/**\n * Extracts the locale segment from the given URL or pathname if present.\n * If no locale is present, returns the default locale (en).\n *\n * Example:\n *\n * ```ts\n * getLocaleFromPath('/en/dashboard') // Returns 'en'\n * getLocaleFromPath('/fr/dashboard') // Returns 'fr'\n * getLocaleFromPath('/dashboard') // Returns 'en'\n * getLocaleFromPath('dashboard') // Returns 'en'\n * getLocaleFromPath('https://example.com/es/dashboard') // Returns 'es'\n * getLocaleFromPath('https://example.com/fr/dashboard') // Returns 'fr'\n * getLocaleFromPath('https://example.com/dashboard') // Returns 'en'\n * ```\n *\n * @param inputUrl - The complete URL string or pathname to process.\n * @returns The detected locale or default (en) if no locale is found\n */\nexport const getLocaleFromPath = (inputUrl: string): Locale => {\n // Define supported locales array\n const { defaultLocale, locales } = configuration?.internationalization ?? {};\n\n if (!defaultLocale || !locales) {\n return Locales.ENGLISH;\n }\n\n // Determine if the original URL is absolute (includes protocol)\n const isAbsoluteUrl = checkIsURLAbsolute(inputUrl);\n\n let fixedInputUrl = inputUrl;\n\n if (inputUrl.endsWith('/')) {\n fixedInputUrl = inputUrl.slice(0, -1);\n }\n\n // Initialize a URL object if the URL is absolute\n // For relative URLs, use a dummy base to leverage the URL API\n const url = isAbsoluteUrl\n ? new URL(fixedInputUrl)\n : new URL(fixedInputUrl, 'http://example.com');\n\n const pathname = url.pathname;\n\n // Ensure the pathname starts with '/'\n if (!pathname.startsWith('/')) {\n // If not, return the default locale\n return defaultLocale;\n }\n\n // Split the pathname to extract the first segment\n const pathSegments = pathname.split('/');\n const firstSegment = pathSegments[1]; // The segment after the first '/'\n\n // Check if the first segment is a supported locale\n if (firstSegment && locales.includes(firstSegment as Locale)) {\n // Return the detected locale\n return firstSegment as Locale;\n }\n\n // Return the default locale if no locale is found in the path\n return defaultLocale;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,qBAAqB,aAA6B;CAE7D,MAAM,EAAE,eAAe,YAAYA,iCAAe,wBAAwB,EAAE;AAE5E,KAAI,CAAC,iBAAiB,CAAC,QACrB,QAAOC,yBAAQ;CAIjB,MAAM,gBAAgBC,oDAAmB,SAAS;CAElD,IAAI,gBAAgB;AAEpB,KAAI,SAAS,SAAS,IAAI,CACxB,iBAAgB,SAAS,MAAM,GAAG,GAAG;CASvC,MAAM,YAJM,gBACR,IAAI,IAAI,cAAc,GACtB,IAAI,IAAI,eAAe,qBAAqB,EAE3B;AAGrB,KAAI,CAAC,SAAS,WAAW,IAAI,CAE3B,QAAO;CAKT,MAAM,eADe,SAAS,MAAM,IAAI,CACN;AAGlC,KAAI,gBAAgB,QAAQ,SAAS,aAAuB,CAE1D,QAAO;AAIT,QAAO"}
1
+ {"version":3,"file":"getLocaleFromPath.cjs","names":["configuration","Locales","checkIsURLAbsolute"],"sources":["../../../src/localization/getLocaleFromPath.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { type Locale, Locales } from '@intlayer/types';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\n\n/**\n * Extracts the locale segment from the given URL or pathname if present.\n * If no locale is present, returns the default locale (en).\n *\n * Example:\n *\n * ```ts\n * getLocaleFromPath('/en/dashboard') // Returns 'en'\n * getLocaleFromPath('/fr/dashboard') // Returns 'fr'\n * getLocaleFromPath('/dashboard') // Returns 'en'\n * getLocaleFromPath('dashboard') // Returns 'en'\n * getLocaleFromPath('https://example.com/es/dashboard') // Returns 'es'\n * getLocaleFromPath('https://example.com/fr/dashboard') // Returns 'fr'\n * getLocaleFromPath('https://example.com/dashboard') // Returns 'en'\n * ```\n *\n * @param inputUrl - The complete URL string or pathname to process.\n * @returns The detected locale or default (en) if no locale is found\n */\nexport const getLocaleFromPath = (inputUrl: string): Locale => {\n // Define supported locales array\n const { defaultLocale, locales } = configuration?.internationalization ?? {};\n\n if (!defaultLocale || !locales) {\n return Locales.ENGLISH;\n }\n\n // Determine if the original URL is absolute (includes protocol)\n const isAbsoluteUrl = checkIsURLAbsolute(inputUrl);\n\n let fixedInputUrl = inputUrl;\n\n if (inputUrl.endsWith('/')) {\n fixedInputUrl = inputUrl.slice(0, -1);\n }\n\n // Initialize a URL object if the URL is absolute\n // For relative URLs, use a dummy base to leverage the URL API\n const url = isAbsoluteUrl\n ? new URL(fixedInputUrl)\n : new URL(fixedInputUrl, 'http://example.com');\n\n const pathname = url.pathname;\n\n // Ensure the pathname starts with '/'\n if (!pathname.startsWith('/')) {\n // If not, return the default locale\n return defaultLocale;\n }\n\n // Split the pathname to extract the first segment\n const pathSegments = pathname.split('/');\n const firstSegment = pathSegments[1]; // The segment after the first '/'\n\n // Check if the first segment is a supported locale\n if (firstSegment && locales.includes(firstSegment as Locale)) {\n // Return the detected locale\n return firstSegment as Locale;\n }\n\n // Return the default locale if no locale is found in the path\n return defaultLocale;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,qBAAqB,aAA6B;CAE7D,MAAM,EAAE,eAAe,YAAYA,gCAAe,wBAAwB,EAAE;AAE5E,KAAI,CAAC,iBAAiB,CAAC,QACrB,QAAOC,wBAAQ;CAIjB,MAAM,gBAAgBC,oDAAmB,SAAS;CAElD,IAAI,gBAAgB;AAEpB,KAAI,SAAS,SAAS,IAAI,CACxB,iBAAgB,SAAS,MAAM,GAAG,GAAG;CASvC,MAAM,YAJM,gBACR,IAAI,IAAI,cAAc,GACtB,IAAI,IAAI,eAAe,qBAAqB,EAE3B;AAGrB,KAAI,CAAC,SAAS,WAAW,IAAI,CAE3B,QAAO;CAKT,MAAM,eADe,SAAS,MAAM,IAAI,CACN;AAGlC,KAAI,gBAAgB,QAAQ,SAAS,aAAuB,CAE1D,QAAO;AAIT,QAAO"}
@@ -2,9 +2,9 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_utils_checkIsURLAbsolute = require('../utils/checkIsURLAbsolute.cjs');
3
3
  const require_localization_getPathWithoutLocale = require('./getPathWithoutLocale.cjs');
4
4
  const require_localization_getPrefix = require('./getPrefix.cjs');
5
- let __intlayer_config_client = require("@intlayer/config/client");
6
- let __intlayer_config_built = require("@intlayer/config/built");
7
- __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
5
+ let _intlayer_config_client = require("@intlayer/config/client");
6
+ let _intlayer_config_built = require("@intlayer/config/built");
7
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
8
8
 
9
9
  //#region src/localization/getLocalizedUrl.ts
10
10
  /**
@@ -45,9 +45,9 @@ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_bui
45
45
  */
46
46
  const getLocalizedUrl = (url, currentLocale, options = {}) => {
47
47
  const { defaultLocale, mode, locales } = {
48
- defaultLocale: __intlayer_config_built.default?.internationalization?.defaultLocale ?? __intlayer_config_client.DefaultValues.Internationalization.DEFAULT_LOCALE,
49
- mode: __intlayer_config_built.default?.routing?.mode ?? __intlayer_config_client.DefaultValues.Routing.ROUTING_MODE,
50
- locales: __intlayer_config_built.default?.internationalization?.locales ?? __intlayer_config_client.DefaultValues.Internationalization.LOCALES,
48
+ defaultLocale: _intlayer_config_built.default?.internationalization?.defaultLocale ?? _intlayer_config_client.DefaultValues.Internationalization.DEFAULT_LOCALE,
49
+ mode: _intlayer_config_built.default?.routing?.mode ?? _intlayer_config_client.DefaultValues.Routing.ROUTING_MODE,
50
+ locales: _intlayer_config_built.default?.internationalization?.locales ?? _intlayer_config_client.DefaultValues.Internationalization.LOCALES,
51
51
  ...options
52
52
  };
53
53
  const urlWithoutLocale = require_localization_getPathWithoutLocale.getPathWithoutLocale(url, locales);
@@ -1 +1 @@
1
- {"version":3,"file":"getLocalizedUrl.cjs","names":["configuration","DefaultValues","getPathWithoutLocale","checkIsURLAbsolute","getPrefix"],"sources":["../../../src/localization/getLocalizedUrl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type { LocalesValues } from '@intlayer/types';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\nimport { getPathWithoutLocale } from './getPathWithoutLocale';\nimport { getPrefix } from './getPrefix';\n\n/**\n * Generate URL by prefixing the given URL with the referenced locale or adding search parameters\n * based on the routing mode. Handles both absolute and relative URLs appropriately.\n *\n * This function gets the locales, default locale, and routing mode from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' });\n * // Returns '/fr/about' for the French locale\n * // Returns '/about' for the English locale (default)\n *\n * // prefix-all mode\n * getLocalizedUrl('/about', 'en', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' });\n * // Returns '/en/about' for the English locale\n * // Returns '/fr/about' for the French locale\n *\n * // search-params mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' });\n * // Returns '/about?locale=fr' for the French locale\n *\n * // no-prefix mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' });\n * // Returns '/about' for any locale\n * ```\n *\n * @param url - The original URL string to be processed.\n * @param currentLocale - The current locale.\n * @param options - Configuration options\n * @param options.locales - Optional array of supported locales. Defaults to configured locales.\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns The localized URL for the current locale.\n */\nexport const getLocalizedUrl = (\n url: string,\n currentLocale: LocalesValues,\n options: {\n locales?: LocalesValues[];\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n } = {}\n): string => {\n const { defaultLocale, mode, locales } = {\n defaultLocale:\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n locales:\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n ...options,\n };\n\n // Remove any existing locale segment from the URL\n const urlWithoutLocale = getPathWithoutLocale(url, locales);\n\n if (mode === 'no-prefix') {\n // No locale prefixing\n return urlWithoutLocale;\n }\n\n // Determine if the original URL is absolute (includes protocol)\n const isAbsoluteUrl = checkIsURLAbsolute(urlWithoutLocale);\n\n // Initialize a URL object if the URL is absolute\n // For relative URLs, use a dummy base to leverage the URL API\n const parsedUrl = isAbsoluteUrl\n ? new URL(urlWithoutLocale)\n : new URL(urlWithoutLocale, 'http://example.com');\n\n // Prepare the base URL (protocol + host) if it's absolute\n const baseUrl = isAbsoluteUrl\n ? `${parsedUrl.protocol}//${parsedUrl.host}`\n : '';\n\n if (mode === 'search-params') {\n // Use search parameters for locale handling\n const searchParams = new URLSearchParams(parsedUrl.search);\n searchParams.set('locale', currentLocale.toString());\n\n const queryString = searchParams.toString();\n const pathWithQuery = queryString\n ? `${parsedUrl.pathname}?${queryString}`\n : parsedUrl.pathname;\n\n if (isAbsoluteUrl) {\n return `${baseUrl}${pathWithQuery}${parsedUrl.hash}`;\n }\n\n return `${pathWithQuery}${parsedUrl.hash}`;\n }\n\n const { prefix } = getPrefix(currentLocale, {\n defaultLocale,\n mode,\n locales,\n });\n\n // Construct the new pathname with or without the locale prefix\n let localizedPath = `/${prefix}${parsedUrl.pathname}`;\n\n // Remove double slashes\n localizedPath = localizedPath.replaceAll(/\\/+/g, '/');\n\n // Remove trailing slash for non-root paths\n if (localizedPath.length > 1 && localizedPath.endsWith('/')) {\n localizedPath = localizedPath.slice(0, -1);\n }\n\n // Combine with the base URL if the original URL was absolute\n if (isAbsoluteUrl) {\n return `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;\n }\n\n return `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,mBACX,KACA,eACA,UAII,EAAE,KACK;CACX,MAAM,EAAE,eAAe,MAAM,YAAY;EACvC,eACEA,iCAAe,sBAAsB,iBACrCC,uCAAc,qBAAqB;EACrC,MAAMD,iCAAe,SAAS,QAAQC,uCAAc,QAAQ;EAC5D,SACED,iCAAe,sBAAsB,WACrCC,uCAAc,qBAAqB;EACrC,GAAG;EACJ;CAGD,MAAM,mBAAmBC,+DAAqB,KAAK,QAAQ;AAE3D,KAAI,SAAS,YAEX,QAAO;CAIT,MAAM,gBAAgBC,oDAAmB,iBAAiB;CAI1D,MAAM,YAAY,gBACd,IAAI,IAAI,iBAAiB,GACzB,IAAI,IAAI,kBAAkB,qBAAqB;CAGnD,MAAM,UAAU,gBACZ,GAAG,UAAU,SAAS,IAAI,UAAU,SACpC;AAEJ,KAAI,SAAS,iBAAiB;EAE5B,MAAM,eAAe,IAAI,gBAAgB,UAAU,OAAO;AAC1D,eAAa,IAAI,UAAU,cAAc,UAAU,CAAC;EAEpD,MAAM,cAAc,aAAa,UAAU;EAC3C,MAAM,gBAAgB,cAClB,GAAG,UAAU,SAAS,GAAG,gBACzB,UAAU;AAEd,MAAI,cACF,QAAO,GAAG,UAAU,gBAAgB,UAAU;AAGhD,SAAO,GAAG,gBAAgB,UAAU;;CAGtC,MAAM,EAAE,WAAWC,yCAAU,eAAe;EAC1C;EACA;EACA;EACD,CAAC;CAGF,IAAI,gBAAgB,IAAI,SAAS,UAAU;AAG3C,iBAAgB,cAAc,WAAW,QAAQ,IAAI;AAGrD,KAAI,cAAc,SAAS,KAAK,cAAc,SAAS,IAAI,CACzD,iBAAgB,cAAc,MAAM,GAAG,GAAG;AAI5C,KAAI,cACF,QAAO,GAAG,UAAU,gBAAgB,UAAU,SAAS,UAAU;AAGnE,QAAO,GAAG,gBAAgB,UAAU,SAAS,UAAU"}
1
+ {"version":3,"file":"getLocalizedUrl.cjs","names":["configuration","DefaultValues","getPathWithoutLocale","checkIsURLAbsolute","getPrefix"],"sources":["../../../src/localization/getLocalizedUrl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type { LocalesValues } from '@intlayer/types';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\nimport { getPathWithoutLocale } from './getPathWithoutLocale';\nimport { getPrefix } from './getPrefix';\n\n/**\n * Generate URL by prefixing the given URL with the referenced locale or adding search parameters\n * based on the routing mode. Handles both absolute and relative URLs appropriately.\n *\n * This function gets the locales, default locale, and routing mode from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' });\n * // Returns '/fr/about' for the French locale\n * // Returns '/about' for the English locale (default)\n *\n * // prefix-all mode\n * getLocalizedUrl('/about', 'en', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' });\n * // Returns '/en/about' for the English locale\n * // Returns '/fr/about' for the French locale\n *\n * // search-params mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' });\n * // Returns '/about?locale=fr' for the French locale\n *\n * // no-prefix mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' });\n * // Returns '/about' for any locale\n * ```\n *\n * @param url - The original URL string to be processed.\n * @param currentLocale - The current locale.\n * @param options - Configuration options\n * @param options.locales - Optional array of supported locales. Defaults to configured locales.\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns The localized URL for the current locale.\n */\nexport const getLocalizedUrl = (\n url: string,\n currentLocale: LocalesValues,\n options: {\n locales?: LocalesValues[];\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n } = {}\n): string => {\n const { defaultLocale, mode, locales } = {\n defaultLocale:\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n locales:\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n ...options,\n };\n\n // Remove any existing locale segment from the URL\n const urlWithoutLocale = getPathWithoutLocale(url, locales);\n\n if (mode === 'no-prefix') {\n // No locale prefixing\n return urlWithoutLocale;\n }\n\n // Determine if the original URL is absolute (includes protocol)\n const isAbsoluteUrl = checkIsURLAbsolute(urlWithoutLocale);\n\n // Initialize a URL object if the URL is absolute\n // For relative URLs, use a dummy base to leverage the URL API\n const parsedUrl = isAbsoluteUrl\n ? new URL(urlWithoutLocale)\n : new URL(urlWithoutLocale, 'http://example.com');\n\n // Prepare the base URL (protocol + host) if it's absolute\n const baseUrl = isAbsoluteUrl\n ? `${parsedUrl.protocol}//${parsedUrl.host}`\n : '';\n\n if (mode === 'search-params') {\n // Use search parameters for locale handling\n const searchParams = new URLSearchParams(parsedUrl.search);\n searchParams.set('locale', currentLocale.toString());\n\n const queryString = searchParams.toString();\n const pathWithQuery = queryString\n ? `${parsedUrl.pathname}?${queryString}`\n : parsedUrl.pathname;\n\n if (isAbsoluteUrl) {\n return `${baseUrl}${pathWithQuery}${parsedUrl.hash}`;\n }\n\n return `${pathWithQuery}${parsedUrl.hash}`;\n }\n\n const { prefix } = getPrefix(currentLocale, {\n defaultLocale,\n mode,\n locales,\n });\n\n // Construct the new pathname with or without the locale prefix\n let localizedPath = `/${prefix}${parsedUrl.pathname}`;\n\n // Remove double slashes\n localizedPath = localizedPath.replaceAll(/\\/+/g, '/');\n\n // Remove trailing slash for non-root paths\n if (localizedPath.length > 1 && localizedPath.endsWith('/')) {\n localizedPath = localizedPath.slice(0, -1);\n }\n\n // Combine with the base URL if the original URL was absolute\n if (isAbsoluteUrl) {\n return `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;\n }\n\n return `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,mBACX,KACA,eACA,UAII,EAAE,KACK;CACX,MAAM,EAAE,eAAe,MAAM,YAAY;EACvC,eACEA,gCAAe,sBAAsB,iBACrCC,sCAAc,qBAAqB;EACrC,MAAMD,gCAAe,SAAS,QAAQC,sCAAc,QAAQ;EAC5D,SACED,gCAAe,sBAAsB,WACrCC,sCAAc,qBAAqB;EACrC,GAAG;EACJ;CAGD,MAAM,mBAAmBC,+DAAqB,KAAK,QAAQ;AAE3D,KAAI,SAAS,YAEX,QAAO;CAIT,MAAM,gBAAgBC,oDAAmB,iBAAiB;CAI1D,MAAM,YAAY,gBACd,IAAI,IAAI,iBAAiB,GACzB,IAAI,IAAI,kBAAkB,qBAAqB;CAGnD,MAAM,UAAU,gBACZ,GAAG,UAAU,SAAS,IAAI,UAAU,SACpC;AAEJ,KAAI,SAAS,iBAAiB;EAE5B,MAAM,eAAe,IAAI,gBAAgB,UAAU,OAAO;AAC1D,eAAa,IAAI,UAAU,cAAc,UAAU,CAAC;EAEpD,MAAM,cAAc,aAAa,UAAU;EAC3C,MAAM,gBAAgB,cAClB,GAAG,UAAU,SAAS,GAAG,gBACzB,UAAU;AAEd,MAAI,cACF,QAAO,GAAG,UAAU,gBAAgB,UAAU;AAGhD,SAAO,GAAG,gBAAgB,UAAU;;CAGtC,MAAM,EAAE,WAAWC,yCAAU,eAAe;EAC1C;EACA;EACA;EACD,CAAC;CAGF,IAAI,gBAAgB,IAAI,SAAS,UAAU;AAG3C,iBAAgB,cAAc,WAAW,QAAQ,IAAI;AAGrD,KAAI,cAAc,SAAS,KAAK,cAAc,SAAS,IAAI,CACzD,iBAAgB,cAAc,MAAM,GAAG,GAAG;AAI5C,KAAI,cACF,QAAO,GAAG,UAAU,gBAAgB,UAAU,SAAS,UAAU;AAGnE,QAAO,GAAG,gBAAgB,UAAU,SAAS,UAAU"}
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_localization_getLocalizedUrl = require('./getLocalizedUrl.cjs');
3
- let __intlayer_config_client = require("@intlayer/config/client");
4
- let __intlayer_config_built = require("@intlayer/config/built");
5
- __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
3
+ let _intlayer_config_client = require("@intlayer/config/client");
4
+ let _intlayer_config_built = require("@intlayer/config/built");
5
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
6
6
 
7
7
  //#region src/localization/getMultilingualUrls.ts
8
8
  /**
@@ -41,9 +41,9 @@ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_bui
41
41
  */
42
42
  const getMultilingualUrls = (url, options = {}) => {
43
43
  const { defaultLocale, mode, locales } = {
44
- defaultLocale: __intlayer_config_built.default?.internationalization?.defaultLocale ?? __intlayer_config_client.DefaultValues.Internationalization.DEFAULT_LOCALE,
45
- mode: __intlayer_config_built.default?.routing?.mode ?? __intlayer_config_client.DefaultValues.Routing.ROUTING_MODE,
46
- locales: __intlayer_config_built.default?.internationalization?.locales ?? __intlayer_config_client.DefaultValues.Internationalization.LOCALES,
44
+ defaultLocale: _intlayer_config_built.default?.internationalization?.defaultLocale ?? _intlayer_config_client.DefaultValues.Internationalization.DEFAULT_LOCALE,
45
+ mode: _intlayer_config_built.default?.routing?.mode ?? _intlayer_config_client.DefaultValues.Routing.ROUTING_MODE,
46
+ locales: _intlayer_config_built.default?.internationalization?.locales ?? _intlayer_config_client.DefaultValues.Internationalization.LOCALES,
47
47
  ...options
48
48
  };
49
49
  return (locales ?? []).reduce((acc, locale) => {
@@ -1 +1 @@
1
- {"version":3,"file":"getMultilingualUrls.cjs","names":["configuration","DefaultValues","getLocalizedUrl"],"sources":["../../../src/localization/getMultilingualUrls.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type { LocalesValues, StrictModeLocaleMap } from '@intlayer/types';\nimport { getLocalizedUrl } from './getLocalizedUrl';\n\n/**\n * Generates multilingual URLs by prefixing the given URL with each supported locale\n * or adding search parameters based on the routing mode.\n * Handles both absolute and relative URLs appropriately.\n *\n * This function gets the locales, default locale, and routing mode from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { en: '/dashboard', fr: '/fr/dashboard' }\n *\n * // prefix-all mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns { en: '/en/dashboard', fr: '/fr/dashboard' }\n *\n * // search-params mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' })\n * // Returns { en: '/dashboard?locale=en', fr: '/dashboard?locale=fr' }\n *\n * // no-prefix mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns { en: '/dashboard', fr: '/dashboard' }\n * ```\n *\n * @param url - The original URL string to be processed.\n * @param options - Configuration options\n * @param options.locales - Optional array of supported locales. Defaults to configured locales.\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns An object mapping each locale to its corresponding multilingual URL.\n */\nexport const getMultilingualUrls = (\n url: string,\n options: {\n locales?: LocalesValues[];\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n } = {}\n): StrictModeLocaleMap<string> => {\n const { defaultLocale, mode, locales } = {\n defaultLocale:\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n locales:\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n ...options,\n };\n\n // Generate multilingual URLs by iterating over each locale and calling getLocalizedUrl\n const multilingualUrls = (locales ?? []).reduce<StrictModeLocaleMap<string>>(\n (acc, locale) => {\n // Get the localized URL for this locale\n const localizedUrl = getLocalizedUrl(url, locale, {\n locales,\n defaultLocale,\n mode,\n });\n\n // Assign the constructed URL to the corresponding locale key\n acc[locale as unknown as keyof typeof acc] = localizedUrl;\n\n return acc;\n },\n {} as StrictModeLocaleMap<string>\n );\n\n return multilingualUrls;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAa,uBACX,KACA,UAII,EAAE,KAC0B;CAChC,MAAM,EAAE,eAAe,MAAM,YAAY;EACvC,eACEA,iCAAe,sBAAsB,iBACrCC,uCAAc,qBAAqB;EACrC,MAAMD,iCAAe,SAAS,QAAQC,uCAAc,QAAQ;EAC5D,SACED,iCAAe,sBAAsB,WACrCC,uCAAc,qBAAqB;EACrC,GAAG;EACJ;AAoBD,SAjB0B,WAAW,EAAE,EAAE,QACtC,KAAK,WAAW;AASf,MAAI,UAPiBC,qDAAgB,KAAK,QAAQ;GAChD;GACA;GACA;GACD,CAAC;AAKF,SAAO;IAET,EAAE,CACH"}
1
+ {"version":3,"file":"getMultilingualUrls.cjs","names":["configuration","DefaultValues","getLocalizedUrl"],"sources":["../../../src/localization/getMultilingualUrls.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type { LocalesValues, StrictModeLocaleMap } from '@intlayer/types';\nimport { getLocalizedUrl } from './getLocalizedUrl';\n\n/**\n * Generates multilingual URLs by prefixing the given URL with each supported locale\n * or adding search parameters based on the routing mode.\n * Handles both absolute and relative URLs appropriately.\n *\n * This function gets the locales, default locale, and routing mode from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { en: '/dashboard', fr: '/fr/dashboard' }\n *\n * // prefix-all mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns { en: '/en/dashboard', fr: '/fr/dashboard' }\n *\n * // search-params mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' })\n * // Returns { en: '/dashboard?locale=en', fr: '/dashboard?locale=fr' }\n *\n * // no-prefix mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns { en: '/dashboard', fr: '/dashboard' }\n * ```\n *\n * @param url - The original URL string to be processed.\n * @param options - Configuration options\n * @param options.locales - Optional array of supported locales. Defaults to configured locales.\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns An object mapping each locale to its corresponding multilingual URL.\n */\nexport const getMultilingualUrls = (\n url: string,\n options: {\n locales?: LocalesValues[];\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n } = {}\n): StrictModeLocaleMap<string> => {\n const { defaultLocale, mode, locales } = {\n defaultLocale:\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n locales:\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n ...options,\n };\n\n // Generate multilingual URLs by iterating over each locale and calling getLocalizedUrl\n const multilingualUrls = (locales ?? []).reduce<StrictModeLocaleMap<string>>(\n (acc, locale) => {\n // Get the localized URL for this locale\n const localizedUrl = getLocalizedUrl(url, locale, {\n locales,\n defaultLocale,\n mode,\n });\n\n // Assign the constructed URL to the corresponding locale key\n acc[locale as unknown as keyof typeof acc] = localizedUrl;\n\n return acc;\n },\n {} as StrictModeLocaleMap<string>\n );\n\n return multilingualUrls;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAa,uBACX,KACA,UAII,EAAE,KAC0B;CAChC,MAAM,EAAE,eAAe,MAAM,YAAY;EACvC,eACEA,gCAAe,sBAAsB,iBACrCC,sCAAc,qBAAqB;EACrC,MAAMD,gCAAe,SAAS,QAAQC,sCAAc,QAAQ;EAC5D,SACED,gCAAe,sBAAsB,WACrCC,sCAAc,qBAAqB;EACrC,GAAG;EACJ;AAoBD,SAjB0B,WAAW,EAAE,EAAE,QACtC,KAAK,WAAW;AASf,MAAI,UAPiBC,qDAAgB,KAAK,QAAQ;GAChD;GACA;GACA;GACD,CAAC;AAKF,SAAO;IAET,EAAE,CACH"}
@@ -1,7 +1,7 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_utils_checkIsURLAbsolute = require('../utils/checkIsURLAbsolute.cjs');
3
- let __intlayer_config_built = require("@intlayer/config/built");
4
- __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
3
+ let _intlayer_config_built = require("@intlayer/config/built");
4
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
5
5
 
6
6
  //#region src/localization/getPathWithoutLocale.ts
7
7
  /**
@@ -28,7 +28,7 @@ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_bui
28
28
  * @param locales - Optional array of supported locales. Defaults to `localesDefault`.
29
29
  * @returns The URL string or pathname without the locale segment or locale search parameter.
30
30
  */
31
- const getPathWithoutLocale = (inputUrl, locales = __intlayer_config_built.default?.internationalization?.locales) => {
31
+ const getPathWithoutLocale = (inputUrl, locales = _intlayer_config_built.default?.internationalization?.locales) => {
32
32
  const isAbsoluteUrl = require_utils_checkIsURLAbsolute.checkIsURLAbsolute(inputUrl);
33
33
  let fixedInputUrl = inputUrl;
34
34
  if (inputUrl.endsWith("/")) fixedInputUrl = inputUrl.slice(0, -1);
@@ -1 +1 @@
1
- {"version":3,"file":"getPathWithoutLocale.cjs","names":["configuration","checkIsURLAbsolute"],"sources":["../../../src/localization/getPathWithoutLocale.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\n\n/**\n * Removes the locale segment from the given URL or pathname if present.\n * Also removes locale from search parameters if present.\n *\n * This function get the locales from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * getPathWithoutLocale('/en/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('/fr/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('dashboard') // Returns 'dashboard'\n * getPathWithoutLocale('/dashboard?locale=fr') // Returns '/dashboard'\n * getPathWithoutLocale('https://example.com/en/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/fr/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/dashboard?locale=fr') // Returns 'https://example.com/dashboard'\n * ```\n *\n * @param inputUrl - The complete URL string or pathname to process.\n * @param locales - Optional array of supported locales. Defaults to `localesDefault`.\n * @returns The URL string or pathname without the locale segment or locale search parameter.\n */\nexport const getPathWithoutLocale = (\n inputUrl: string,\n locales: LocalesValues[] = configuration?.internationalization?.locales\n): string => {\n // Determine if the original URL is absolute (includes protocol)\n const isAbsoluteUrl = checkIsURLAbsolute(inputUrl);\n\n let fixedInputUrl = inputUrl;\n\n if (inputUrl.endsWith('/')) {\n fixedInputUrl = inputUrl.slice(0, -1);\n }\n\n // Initialize a URL object if the URL is absolute\n // For relative URLs, use a dummy base to leverage the URL API\n const url = isAbsoluteUrl\n ? new URL(fixedInputUrl)\n : new URL(fixedInputUrl, 'http://example.com');\n\n const pathname = url.pathname;\n\n // Ensure the pathname starts with '/'\n if (!pathname.startsWith('/')) {\n // If not, return the URL as is\n url.pathname = `/${pathname}`;\n }\n\n // Split the pathname to extract the first segment\n const pathSegments = pathname.split('/');\n const firstSegment = pathSegments[1]; // The segment after the first '/'\n\n // Check if the first segment is a supported locale\n if (locales?.includes(firstSegment as LocalesValues)) {\n // Remove the locale segment from the pathname\n pathSegments.splice(1, 1); // Remove the first segment\n\n // Reconstruct the pathname\n const newPathname = pathSegments.join('/') ?? '/';\n url.pathname = newPathname;\n }\n\n // Remove locale from search parameters if present\n const searchParams = new URLSearchParams(url.search);\n if (searchParams.has('locale')) {\n searchParams.delete('locale');\n url.search = searchParams.toString();\n }\n\n if (isAbsoluteUrl) {\n // Return the modified URL as a string\n return url.toString();\n }\n\n // Return the modified URL as a string\n return url.toString().replace('http://example.com', '');\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,wBACX,UACA,UAA2BA,iCAAe,sBAAsB,YACrD;CAEX,MAAM,gBAAgBC,oDAAmB,SAAS;CAElD,IAAI,gBAAgB;AAEpB,KAAI,SAAS,SAAS,IAAI,CACxB,iBAAgB,SAAS,MAAM,GAAG,GAAG;CAKvC,MAAM,MAAM,gBACR,IAAI,IAAI,cAAc,GACtB,IAAI,IAAI,eAAe,qBAAqB;CAEhD,MAAM,WAAW,IAAI;AAGrB,KAAI,CAAC,SAAS,WAAW,IAAI,CAE3B,KAAI,WAAW,IAAI;CAIrB,MAAM,eAAe,SAAS,MAAM,IAAI;CACxC,MAAM,eAAe,aAAa;AAGlC,KAAI,SAAS,SAAS,aAA8B,EAAE;AAEpD,eAAa,OAAO,GAAG,EAAE;AAIzB,MAAI,WADgB,aAAa,KAAK,IAAI,IAAI;;CAKhD,MAAM,eAAe,IAAI,gBAAgB,IAAI,OAAO;AACpD,KAAI,aAAa,IAAI,SAAS,EAAE;AAC9B,eAAa,OAAO,SAAS;AAC7B,MAAI,SAAS,aAAa,UAAU;;AAGtC,KAAI,cAEF,QAAO,IAAI,UAAU;AAIvB,QAAO,IAAI,UAAU,CAAC,QAAQ,sBAAsB,GAAG"}
1
+ {"version":3,"file":"getPathWithoutLocale.cjs","names":["configuration","checkIsURLAbsolute"],"sources":["../../../src/localization/getPathWithoutLocale.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\n\n/**\n * Removes the locale segment from the given URL or pathname if present.\n * Also removes locale from search parameters if present.\n *\n * This function get the locales from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * getPathWithoutLocale('/en/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('/fr/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('dashboard') // Returns 'dashboard'\n * getPathWithoutLocale('/dashboard?locale=fr') // Returns '/dashboard'\n * getPathWithoutLocale('https://example.com/en/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/fr/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/dashboard?locale=fr') // Returns 'https://example.com/dashboard'\n * ```\n *\n * @param inputUrl - The complete URL string or pathname to process.\n * @param locales - Optional array of supported locales. Defaults to `localesDefault`.\n * @returns The URL string or pathname without the locale segment or locale search parameter.\n */\nexport const getPathWithoutLocale = (\n inputUrl: string,\n locales: LocalesValues[] = configuration?.internationalization?.locales\n): string => {\n // Determine if the original URL is absolute (includes protocol)\n const isAbsoluteUrl = checkIsURLAbsolute(inputUrl);\n\n let fixedInputUrl = inputUrl;\n\n if (inputUrl.endsWith('/')) {\n fixedInputUrl = inputUrl.slice(0, -1);\n }\n\n // Initialize a URL object if the URL is absolute\n // For relative URLs, use a dummy base to leverage the URL API\n const url = isAbsoluteUrl\n ? new URL(fixedInputUrl)\n : new URL(fixedInputUrl, 'http://example.com');\n\n const pathname = url.pathname;\n\n // Ensure the pathname starts with '/'\n if (!pathname.startsWith('/')) {\n // If not, return the URL as is\n url.pathname = `/${pathname}`;\n }\n\n // Split the pathname to extract the first segment\n const pathSegments = pathname.split('/');\n const firstSegment = pathSegments[1]; // The segment after the first '/'\n\n // Check if the first segment is a supported locale\n if (locales?.includes(firstSegment as LocalesValues)) {\n // Remove the locale segment from the pathname\n pathSegments.splice(1, 1); // Remove the first segment\n\n // Reconstruct the pathname\n const newPathname = pathSegments.join('/') ?? '/';\n url.pathname = newPathname;\n }\n\n // Remove locale from search parameters if present\n const searchParams = new URLSearchParams(url.search);\n if (searchParams.has('locale')) {\n searchParams.delete('locale');\n url.search = searchParams.toString();\n }\n\n if (isAbsoluteUrl) {\n // Return the modified URL as a string\n return url.toString();\n }\n\n // Return the modified URL as a string\n return url.toString().replace('http://example.com', '');\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,wBACX,UACA,UAA2BA,gCAAe,sBAAsB,YACrD;CAEX,MAAM,gBAAgBC,oDAAmB,SAAS;CAElD,IAAI,gBAAgB;AAEpB,KAAI,SAAS,SAAS,IAAI,CACxB,iBAAgB,SAAS,MAAM,GAAG,GAAG;CAKvC,MAAM,MAAM,gBACR,IAAI,IAAI,cAAc,GACtB,IAAI,IAAI,eAAe,qBAAqB;CAEhD,MAAM,WAAW,IAAI;AAGrB,KAAI,CAAC,SAAS,WAAW,IAAI,CAE3B,KAAI,WAAW,IAAI;CAIrB,MAAM,eAAe,SAAS,MAAM,IAAI;CACxC,MAAM,eAAe,aAAa;AAGlC,KAAI,SAAS,SAAS,aAA8B,EAAE;AAEpD,eAAa,OAAO,GAAG,EAAE;AAIzB,MAAI,WADgB,aAAa,KAAK,IAAI,IAAI;;CAKhD,MAAM,eAAe,IAAI,gBAAgB,IAAI,OAAO;AACpD,KAAI,aAAa,IAAI,SAAS,EAAE;AAC9B,eAAa,OAAO,SAAS;AAC7B,MAAI,SAAS,aAAa,UAAU;;AAGtC,KAAI,cAEF,QAAO,IAAI,UAAU;AAIvB,QAAO,IAAI,UAAU,CAAC,QAAQ,sBAAsB,GAAG"}
@@ -1,7 +1,7 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- let __intlayer_config_client = require("@intlayer/config/client");
3
- let __intlayer_config_built = require("@intlayer/config/built");
4
- __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
2
+ let _intlayer_config_client = require("@intlayer/config/client");
3
+ let _intlayer_config_built = require("@intlayer/config/built");
4
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
5
5
 
6
6
  //#region src/localization/getPrefix.ts
7
7
  /**
@@ -39,9 +39,9 @@ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_bui
39
39
  */
40
40
  const getPrefix = (locale, options = {}) => {
41
41
  const { defaultLocale, mode, locales } = {
42
- defaultLocale: __intlayer_config_built.default?.internationalization?.defaultLocale ?? __intlayer_config_client.DefaultValues.Internationalization.DEFAULT_LOCALE,
43
- mode: __intlayer_config_built.default?.routing?.mode ?? __intlayer_config_client.DefaultValues.Routing.ROUTING_MODE,
44
- locales: __intlayer_config_built.default?.internationalization?.locales ?? __intlayer_config_client.DefaultValues.Internationalization.LOCALES,
42
+ defaultLocale: _intlayer_config_built.default?.internationalization?.defaultLocale ?? _intlayer_config_client.DefaultValues.Internationalization.DEFAULT_LOCALE,
43
+ mode: _intlayer_config_built.default?.routing?.mode ?? _intlayer_config_client.DefaultValues.Routing.ROUTING_MODE,
44
+ locales: _intlayer_config_built.default?.internationalization?.locales ?? _intlayer_config_client.DefaultValues.Internationalization.LOCALES,
45
45
  ...options
46
46
  };
47
47
  if (!locale || !locales.includes(locale)) return {
@@ -1 +1 @@
1
- {"version":3,"file":"getPrefix.cjs","names":["configuration","DefaultValues"],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type { Locale, LocalesValues } from '@intlayer/types';\n\nexport type GetPrefixOptions = {\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n};\n\nexport type GetPrefixResult = {\n /**\n * The complete base URL path with leading and trailing slashes.\n *\n * @example\n * // https://example.com/fr/about -> '/fr'\n * // https://example.com/about -> ''\n */\n prefix: string;\n /**\n * The locale identifier without slashes.\n *\n * @example\n * // https://example.com/fr/about -> 'fr'\n * // https://example.com/about -> undefined\n */\n localePrefix: Locale | undefined;\n};\n\n/**\n * Determines the URL prefix for a given locale based on the routing mode configuration.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode with default locale\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { prefix: '', localePrefix: undefined }\n *\n * // prefix-no-default mode with non-default locale\n * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { prefix: '/fr', localePrefix: 'fr' }\n *\n * // prefix-all mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns { prefix: '/en', localePrefix: locale }\n *\n * // search-params mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })\n * // Returns { prefix: '', localePrefix: undefined }\n *\n * // no-prefix mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns { prefix: '', localePrefix: undefined }\n * ```\n *\n * @param locale - The locale to check for prefix. If not provided, uses configured default locale.\n * @param options - Configuration options\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns An object containing pathPrefix, prefix, and localePrefix for the given locale.\n */\nexport const getPrefix = (\n locale: LocalesValues | undefined,\n options: {\n defaultLocale?: LocalesValues;\n locales?: LocalesValues[];\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n } = {}\n): GetPrefixResult => {\n const { defaultLocale, mode, locales } = {\n defaultLocale:\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n locales:\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n ...options,\n };\n\n if (!locale || !locales.includes(locale)) {\n return {\n prefix: '',\n localePrefix: undefined,\n };\n }\n\n // Handle prefix-based modes (prefix-all or prefix-no-default)\n const shouldPrefix =\n mode === 'prefix-all' ||\n (mode === 'prefix-no-default' && defaultLocale !== locale);\n\n if (shouldPrefix) {\n return {\n prefix: `${locale}/`,\n localePrefix: locale as Locale,\n };\n }\n\n return {\n prefix: '',\n localePrefix: undefined,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAa,aACX,QACA,UAII,EAAE,KACc;CACpB,MAAM,EAAE,eAAe,MAAM,YAAY;EACvC,eACEA,iCAAe,sBAAsB,iBACrCC,uCAAc,qBAAqB;EACrC,MAAMD,iCAAe,SAAS,QAAQC,uCAAc,QAAQ;EAC5D,SACED,iCAAe,sBAAsB,WACrCC,uCAAc,qBAAqB;EACrC,GAAG;EACJ;AAED,KAAI,CAAC,UAAU,CAAC,QAAQ,SAAS,OAAO,CACtC,QAAO;EACL,QAAQ;EACR,cAAc;EACf;AAQH,KAHE,SAAS,gBACR,SAAS,uBAAuB,kBAAkB,OAGnD,QAAO;EACL,QAAQ,GAAG,OAAO;EAClB,cAAc;EACf;AAGH,QAAO;EACL,QAAQ;EACR,cAAc;EACf"}
1
+ {"version":3,"file":"getPrefix.cjs","names":["configuration","DefaultValues"],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type { Locale, LocalesValues } from '@intlayer/types';\n\nexport type GetPrefixOptions = {\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n};\n\nexport type GetPrefixResult = {\n /**\n * The complete base URL path with leading and trailing slashes.\n *\n * @example\n * // https://example.com/fr/about -> '/fr'\n * // https://example.com/about -> ''\n */\n prefix: string;\n /**\n * The locale identifier without slashes.\n *\n * @example\n * // https://example.com/fr/about -> 'fr'\n * // https://example.com/about -> undefined\n */\n localePrefix: Locale | undefined;\n};\n\n/**\n * Determines the URL prefix for a given locale based on the routing mode configuration.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode with default locale\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { prefix: '', localePrefix: undefined }\n *\n * // prefix-no-default mode with non-default locale\n * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { prefix: '/fr', localePrefix: 'fr' }\n *\n * // prefix-all mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns { prefix: '/en', localePrefix: locale }\n *\n * // search-params mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })\n * // Returns { prefix: '', localePrefix: undefined }\n *\n * // no-prefix mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns { prefix: '', localePrefix: undefined }\n * ```\n *\n * @param locale - The locale to check for prefix. If not provided, uses configured default locale.\n * @param options - Configuration options\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns An object containing pathPrefix, prefix, and localePrefix for the given locale.\n */\nexport const getPrefix = (\n locale: LocalesValues | undefined,\n options: {\n defaultLocale?: LocalesValues;\n locales?: LocalesValues[];\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n } = {}\n): GetPrefixResult => {\n const { defaultLocale, mode, locales } = {\n defaultLocale:\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n locales:\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n ...options,\n };\n\n if (!locale || !locales.includes(locale)) {\n return {\n prefix: '',\n localePrefix: undefined,\n };\n }\n\n // Handle prefix-based modes (prefix-all or prefix-no-default)\n const shouldPrefix =\n mode === 'prefix-all' ||\n (mode === 'prefix-no-default' && defaultLocale !== locale);\n\n if (shouldPrefix) {\n return {\n prefix: `${locale}/`,\n localePrefix: locale as Locale,\n };\n }\n\n return {\n prefix: '',\n localePrefix: undefined,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAa,aACX,QACA,UAII,EAAE,KACc;CACpB,MAAM,EAAE,eAAe,MAAM,YAAY;EACvC,eACEA,gCAAe,sBAAsB,iBACrCC,sCAAc,qBAAqB;EACrC,MAAMD,gCAAe,SAAS,QAAQC,sCAAc,QAAQ;EAC5D,SACED,gCAAe,sBAAsB,WACrCC,sCAAc,qBAAqB;EACrC,GAAG;EACJ;AAED,KAAI,CAAC,UAAU,CAAC,QAAQ,SAAS,OAAO,CACtC,QAAO;EACL,QAAQ;EACR,cAAc;EACf;AAQH,KAHE,SAAS,gBACR,SAAS,uBAAuB,kBAAkB,OAGnD,QAAO;EACL,QAAQ,GAAG,OAAO;EAClB,cAAc;EACf;AAGH,QAAO;EACL,QAAQ;EACR,cAAc;EACf"}
@@ -1,7 +1,7 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- let __intlayer_types = require("@intlayer/types");
3
- let __intlayer_config_built = require("@intlayer/config/built");
4
- __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
2
+ let _intlayer_types = require("@intlayer/types");
3
+ let _intlayer_config_built = require("@intlayer/config/built");
4
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
5
5
 
6
6
  //#region src/localization/localeMapper.ts
7
7
  /**
@@ -38,7 +38,7 @@ const shouldPrefixLocale = (locale, defaultLocale, mode) => {
38
38
  * @param mapper - The mapper function that returns an object
39
39
  * @returns An array of objects
40
40
  */
41
- const localeMap = (mapper, locales = __intlayer_config_built.default?.internationalization.locales ?? [], defaultLocale = __intlayer_config_built.default?.internationalization.defaultLocale ?? __intlayer_types.Locales.ENGLISH, mode = __intlayer_config_built.default?.routing?.mode ?? "prefix-no-default") => (locales ?? []).map((locale) => mapper({
41
+ const localeMap = (mapper, locales = _intlayer_config_built.default?.internationalization.locales ?? [], defaultLocale = _intlayer_config_built.default?.internationalization.defaultLocale ?? _intlayer_types.Locales.ENGLISH, mode = _intlayer_config_built.default?.routing?.mode ?? "prefix-no-default") => (locales ?? []).map((locale) => mapper({
42
42
  locale,
43
43
  defaultLocale,
44
44
  locales,
@@ -71,7 +71,7 @@ const localeMap = (mapper, locales = __intlayer_config_built.default?.internatio
71
71
  * @param mapper - The mapper function that returns an array of objects
72
72
  * @returns An array of objects
73
73
  */
74
- const localeFlatMap = (mapper, locales = __intlayer_config_built.default?.internationalization.locales ?? [], defaultLocale = __intlayer_config_built.default?.internationalization.defaultLocale ?? __intlayer_types.Locales.ENGLISH, mode = __intlayer_config_built.default?.routing?.mode ?? "prefix-no-default") => locales.flatMap((locale) => mapper({
74
+ const localeFlatMap = (mapper, locales = _intlayer_config_built.default?.internationalization.locales ?? [], defaultLocale = _intlayer_config_built.default?.internationalization.defaultLocale ?? _intlayer_types.Locales.ENGLISH, mode = _intlayer_config_built.default?.routing?.mode ?? "prefix-no-default") => locales.flatMap((locale) => mapper({
75
75
  locale,
76
76
  defaultLocale,
77
77
  locales,
@@ -101,7 +101,7 @@ const localeFlatMap = (mapper, locales = __intlayer_config_built.default?.intern
101
101
  * @param mode - URL routing mode for locale handling (defaults to configured value)
102
102
  * @returns Record mapping locale codes to mapped values
103
103
  */
104
- const localeRecord = (mapper, locales = __intlayer_config_built.default?.internationalization.locales ?? [], defaultLocale = __intlayer_config_built.default?.internationalization.defaultLocale ?? __intlayer_types.Locales.ENGLISH, mode = __intlayer_config_built.default?.routing?.mode ?? "prefix-no-default") => (locales ?? []).reduce((acc, locale) => {
104
+ const localeRecord = (mapper, locales = _intlayer_config_built.default?.internationalization.locales ?? [], defaultLocale = _intlayer_config_built.default?.internationalization.defaultLocale ?? _intlayer_types.Locales.ENGLISH, mode = _intlayer_config_built.default?.routing?.mode ?? "prefix-no-default") => (locales ?? []).reduce((acc, locale) => {
105
105
  acc[locale] = mapper({
106
106
  locale,
107
107
  defaultLocale,