@intlayer/core 7.1.0-canary.0 → 7.1.0-canary.1

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.
@@ -60,9 +60,9 @@ const require_localization_getLocaleFromPath = require('./localization/getLocale
60
60
  const require_localization_getLocaleLang = require('./localization/getLocaleLang.cjs');
61
61
  const require_localization_getLocaleName = require('./localization/getLocaleName.cjs');
62
62
  const require_localization_getPathWithoutLocale = require('./localization/getPathWithoutLocale.cjs');
63
+ const require_localization_getPrefix = require('./localization/getPrefix.cjs');
63
64
  const require_localization_getLocalizedUrl = require('./localization/getLocalizedUrl.cjs');
64
65
  const require_localization_getMultilingualUrls = require('./localization/getMultilingualUrls.cjs');
65
- const require_localization_getPrefix = require('./localization/getPrefix.cjs');
66
66
  const require_localization_localeMapper = require('./localization/localeMapper.cjs');
67
67
  const require_utils_isSameKeyPath = require('./utils/isSameKeyPath.cjs');
68
68
 
@@ -1,6 +1,7 @@
1
1
  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
+ const require_localization_getPrefix = require('./getPrefix.cjs');
4
5
  let __intlayer_config_client = require("@intlayer/config/client");
5
6
  let __intlayer_config_built = require("@intlayer/config/built");
6
7
  __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
@@ -48,19 +49,21 @@ const getLocalizedUrl = (url, currentLocale, options = {}) => {
48
49
  if (mode === "no-prefix") return urlWithoutLocale;
49
50
  const isAbsoluteUrl = require_utils_checkIsURLAbsolute.checkIsURLAbsolute(urlWithoutLocale);
50
51
  const parsedUrl = isAbsoluteUrl ? new URL(urlWithoutLocale) : new URL(urlWithoutLocale, "http://example.com");
51
- let pathname = parsedUrl.pathname;
52
- if (!pathname.startsWith("/")) pathname = `/${pathname}`;
53
52
  const baseUrl = isAbsoluteUrl ? `${parsedUrl.protocol}//${parsedUrl.host}` : "";
54
53
  if (mode === "search-params") {
55
54
  const searchParams = new URLSearchParams(parsedUrl.search);
56
55
  searchParams.set("locale", currentLocale.toString());
57
56
  const queryString = searchParams.toString();
58
- const pathWithQuery = queryString ? `${pathname}?${queryString}` : pathname;
57
+ const pathWithQuery = queryString ? `${parsedUrl.pathname}?${queryString}` : parsedUrl.pathname;
59
58
  if (isAbsoluteUrl) return `${baseUrl}${pathWithQuery}${parsedUrl.hash}`;
60
59
  return `${pathWithQuery}${parsedUrl.hash}`;
61
60
  }
62
- const isDefaultLocale = currentLocale?.toString() === defaultLocale?.toString();
63
- let localizedPath = mode === "prefix-all" || mode === "prefix-no-default" && !isDefaultLocale ? `/${currentLocale}${pathname}` : pathname;
61
+ let localizedPath = `/${require_localization_getPrefix.getPrefix(currentLocale, {
62
+ defaultLocale,
63
+ mode,
64
+ addSlash: false
65
+ })}/${parsedUrl.pathname}`;
66
+ localizedPath = localizedPath.replaceAll(/\/+/g, "/");
64
67
  if (localizedPath.length > 1 && localizedPath.endsWith("/")) localizedPath = localizedPath.slice(0, -1);
65
68
  if (isAbsoluteUrl) return `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;
66
69
  return `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;
@@ -1 +1 @@
1
- {"version":3,"file":"getLocalizedUrl.cjs","names":["configuration","DefaultValues","getPathWithoutLocale","checkIsURLAbsolute"],"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';\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 {\n locales = configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n defaultLocale = configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode = configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n } = options;\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 // Extract the pathname from the parsed URL\n let pathname = parsedUrl.pathname;\n\n // Ensure the pathname starts with a '/'\n if (!pathname.startsWith('/')) {\n pathname = `/${pathname}`;\n }\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 ? `${pathname}?${queryString}` : pathname;\n\n if (isAbsoluteUrl) {\n return `${baseUrl}${pathWithQuery}${parsedUrl.hash}`;\n }\n\n return `${pathWithQuery}${parsedUrl.hash}`;\n }\n\n // Prefix-based routing (prefix-all or prefix-no-default)\n const isDefaultLocale =\n currentLocale?.toString() === defaultLocale?.toString();\n\n const shouldPrefix =\n mode === 'prefix-all' || (mode === 'prefix-no-default' && !isDefaultLocale);\n\n // Construct the new pathname with or without the locale prefix\n let localizedPath = shouldPrefix ? `/${currentLocale}${pathname}` : pathname;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,mBACX,KACA,eACA,UAII,EAAE,KACK;CACX,MAAM,EACJ,UAAUA,iCAAe,sBAAsB,WAC7CC,uCAAc,qBAAqB,SACrC,gBAAgBD,iCAAe,sBAAsB,iBACnDC,uCAAc,qBAAqB,gBACrC,OAAOD,iCAAe,SAAS,QAAQC,uCAAc,QAAQ,iBAC3D;CAEJ,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,IAAI,WAAW,UAAU;AAGzB,KAAI,CAAC,SAAS,WAAW,IAAI,CAC3B,YAAW,IAAI;CAIjB,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,cAAc,GAAG,SAAS,GAAG,gBAAgB;AAEnE,MAAI,cACF,QAAO,GAAG,UAAU,gBAAgB,UAAU;AAGhD,SAAO,GAAG,gBAAgB,UAAU;;CAItC,MAAM,kBACJ,eAAe,UAAU,KAAK,eAAe,UAAU;CAMzD,IAAI,gBAHF,SAAS,gBAAiB,SAAS,uBAAuB,CAAC,kBAG1B,IAAI,gBAAgB,aAAa;AAGpE,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 {\n locales = configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n defaultLocale = configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode = configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n } = options;\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 addSlash: false,\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,EACJ,UAAUA,iCAAe,sBAAsB,WAC7CC,uCAAc,qBAAqB,SACrC,gBAAgBD,iCAAe,sBAAsB,iBACnDC,uCAAc,qBAAqB,gBACrC,OAAOD,iCAAe,SAAS,QAAQC,uCAAc,QAAQ,iBAC3D;CAEJ,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;;CAUtC,IAAI,gBAAgB,IAPLC,yCAAU,eAAe;EACtC;EACA;EACA,UAAU;EACX,CAAC,CAG6B,GAAG,UAAU;AAG5C,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"}
@@ -15,7 +15,7 @@ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_bui
15
15
  *
16
16
  * // prefix-no-default mode with non-default locale
17
17
  * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })
18
- * // Returns 'en/'
18
+ * // Returns 'fr/'
19
19
  *
20
20
  * // prefix-all mode
21
21
  * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })
@@ -39,7 +39,12 @@ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_bui
39
39
  */
40
40
  const getPrefix = (locale, options = {}) => {
41
41
  const { defaultLocale = __intlayer_config_built.default?.internationalization?.defaultLocale, mode = __intlayer_config_built.default?.routing?.mode, addSlash = true } = options;
42
- return mode === "prefix-all" || mode === "prefix-no-default" && defaultLocale !== locale ? `${defaultLocale}${addSlash ? "/" : ""}` : "";
42
+ if (!locale) return "";
43
+ if (mode === "prefix-all" || mode === "prefix-no-default" && defaultLocale !== locale) {
44
+ if (addSlash) return `${locale}/`;
45
+ return `${locale}`;
46
+ }
47
+ return "";
43
48
  };
44
49
 
45
50
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getPrefix.cjs","names":["configuration"],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\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 ''\n *\n * // prefix-no-default mode with non-default locale\n * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns 'en/'\n *\n * // prefix-all mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns 'en/'\n *\n * // search-params mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })\n * // Returns ''\n *\n * // no-prefix mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns ''\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 * @param options.addSlash - Whether to add a trailing slash to the prefix. Defaults to true.\n * @returns The prefix string for the given locale (e.g., 'en/', 'fr/') or an empty string.\n */\nexport const getPrefix = (\n locale?: LocalesValues,\n options: {\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n addSlash?: boolean;\n } = {}\n): string => {\n const {\n defaultLocale = configuration?.internationalization?.defaultLocale,\n mode = configuration?.routing?.mode,\n addSlash = true,\n } = options;\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 return shouldPrefix ? `${defaultLocale}${addSlash ? '/' : ''}` : '';\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,aACX,QACA,UAII,EAAE,KACK;CACX,MAAM,EACJ,gBAAgBA,iCAAe,sBAAsB,eACrD,OAAOA,iCAAe,SAAS,MAC/B,WAAW,SACT;AAOJ,QAHE,SAAS,gBACR,SAAS,uBAAuB,kBAAkB,SAE/B,GAAG,gBAAgB,WAAW,MAAM,OAAO"}
1
+ {"version":3,"file":"getPrefix.cjs","names":["configuration"],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\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 ''\n *\n * // prefix-no-default mode with non-default locale\n * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns 'fr/'\n *\n * // prefix-all mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns 'en/'\n *\n * // search-params mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })\n * // Returns ''\n *\n * // no-prefix mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns ''\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 * @param options.addSlash - Whether to add a trailing slash to the prefix. Defaults to true.\n * @returns The prefix string for the given locale (e.g., 'en/', 'fr/') or an empty string.\n */\nexport const getPrefix = (\n locale: LocalesValues,\n options: {\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n addSlash?: boolean;\n } = {}\n): string => {\n const {\n defaultLocale = configuration?.internationalization?.defaultLocale,\n mode = configuration?.routing?.mode,\n addSlash = true,\n } = options;\n\n if (!locale) return '';\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 if (addSlash) {\n return `${locale}/`;\n }\n\n return `${locale}`;\n }\n\n return '';\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,aACX,QACA,UAII,EAAE,KACK;CACX,MAAM,EACJ,gBAAgBA,iCAAe,sBAAsB,eACrD,OAAOA,iCAAe,SAAS,MAC/B,WAAW,SACT;AAEJ,KAAI,CAAC,OAAQ,QAAO;AAOpB,KAHE,SAAS,gBACR,SAAS,uBAAuB,kBAAkB,QAEnC;AAChB,MAAI,SACF,QAAO,GAAG,OAAO;AAGnB,SAAO,GAAG;;AAGZ,QAAO"}
@@ -6,9 +6,9 @@ const require_localization_getLocaleFromPath = require('./getLocaleFromPath.cjs'
6
6
  const require_localization_getLocaleLang = require('./getLocaleLang.cjs');
7
7
  const require_localization_getLocaleName = require('./getLocaleName.cjs');
8
8
  const require_localization_getPathWithoutLocale = require('./getPathWithoutLocale.cjs');
9
+ const require_localization_getPrefix = require('./getPrefix.cjs');
9
10
  const require_localization_getLocalizedUrl = require('./getLocalizedUrl.cjs');
10
11
  const require_localization_getMultilingualUrls = require('./getMultilingualUrls.cjs');
11
- const require_localization_getPrefix = require('./getPrefix.cjs');
12
12
  const require_localization_localeMapper = require('./localeMapper.cjs');
13
13
 
14
14
  exports.getBrowserLocale = require_localization_getBrowserLocale.getBrowserLocale;
@@ -60,9 +60,9 @@ import { getLocaleFromPath } from "./localization/getLocaleFromPath.mjs";
60
60
  import { getLocaleLang } from "./localization/getLocaleLang.mjs";
61
61
  import { getLocaleName } from "./localization/getLocaleName.mjs";
62
62
  import { getPathWithoutLocale } from "./localization/getPathWithoutLocale.mjs";
63
+ import { getPrefix } from "./localization/getPrefix.mjs";
63
64
  import { getLocalizedUrl } from "./localization/getLocalizedUrl.mjs";
64
65
  import { getMultilingualUrls } from "./localization/getMultilingualUrls.mjs";
65
- import { getPrefix } from "./localization/getPrefix.mjs";
66
66
  import { localeFlatMap, localeMap, localeRecord } from "./localization/localeMapper.mjs";
67
67
  import { isSameKeyPath } from "./utils/isSameKeyPath.mjs";
68
68
 
@@ -1,5 +1,6 @@
1
1
  import { checkIsURLAbsolute } from "../utils/checkIsURLAbsolute.mjs";
2
2
  import { getPathWithoutLocale } from "./getPathWithoutLocale.mjs";
3
+ import { getPrefix } from "./getPrefix.mjs";
3
4
  import { DefaultValues } from "@intlayer/config/client";
4
5
  import configuration from "@intlayer/config/built";
5
6
 
@@ -46,19 +47,21 @@ const getLocalizedUrl = (url, currentLocale, options = {}) => {
46
47
  if (mode === "no-prefix") return urlWithoutLocale;
47
48
  const isAbsoluteUrl = checkIsURLAbsolute(urlWithoutLocale);
48
49
  const parsedUrl = isAbsoluteUrl ? new URL(urlWithoutLocale) : new URL(urlWithoutLocale, "http://example.com");
49
- let pathname = parsedUrl.pathname;
50
- if (!pathname.startsWith("/")) pathname = `/${pathname}`;
51
50
  const baseUrl = isAbsoluteUrl ? `${parsedUrl.protocol}//${parsedUrl.host}` : "";
52
51
  if (mode === "search-params") {
53
52
  const searchParams = new URLSearchParams(parsedUrl.search);
54
53
  searchParams.set("locale", currentLocale.toString());
55
54
  const queryString = searchParams.toString();
56
- const pathWithQuery = queryString ? `${pathname}?${queryString}` : pathname;
55
+ const pathWithQuery = queryString ? `${parsedUrl.pathname}?${queryString}` : parsedUrl.pathname;
57
56
  if (isAbsoluteUrl) return `${baseUrl}${pathWithQuery}${parsedUrl.hash}`;
58
57
  return `${pathWithQuery}${parsedUrl.hash}`;
59
58
  }
60
- const isDefaultLocale = currentLocale?.toString() === defaultLocale?.toString();
61
- let localizedPath = mode === "prefix-all" || mode === "prefix-no-default" && !isDefaultLocale ? `/${currentLocale}${pathname}` : pathname;
59
+ let localizedPath = `/${getPrefix(currentLocale, {
60
+ defaultLocale,
61
+ mode,
62
+ addSlash: false
63
+ })}/${parsedUrl.pathname}`;
64
+ localizedPath = localizedPath.replaceAll(/\/+/g, "/");
62
65
  if (localizedPath.length > 1 && localizedPath.endsWith("/")) localizedPath = localizedPath.slice(0, -1);
63
66
  if (isAbsoluteUrl) return `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;
64
67
  return `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;
@@ -1 +1 @@
1
- {"version":3,"file":"getLocalizedUrl.mjs","names":[],"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';\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 {\n locales = configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n defaultLocale = configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode = configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n } = options;\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 // Extract the pathname from the parsed URL\n let pathname = parsedUrl.pathname;\n\n // Ensure the pathname starts with a '/'\n if (!pathname.startsWith('/')) {\n pathname = `/${pathname}`;\n }\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 ? `${pathname}?${queryString}` : pathname;\n\n if (isAbsoluteUrl) {\n return `${baseUrl}${pathWithQuery}${parsedUrl.hash}`;\n }\n\n return `${pathWithQuery}${parsedUrl.hash}`;\n }\n\n // Prefix-based routing (prefix-all or prefix-no-default)\n const isDefaultLocale =\n currentLocale?.toString() === defaultLocale?.toString();\n\n const shouldPrefix =\n mode === 'prefix-all' || (mode === 'prefix-no-default' && !isDefaultLocale);\n\n // Construct the new pathname with or without the locale prefix\n let localizedPath = shouldPrefix ? `/${currentLocale}${pathname}` : pathname;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,mBACX,KACA,eACA,UAII,EAAE,KACK;CACX,MAAM,EACJ,UAAU,eAAe,sBAAsB,WAC7C,cAAc,qBAAqB,SACrC,gBAAgB,eAAe,sBAAsB,iBACnD,cAAc,qBAAqB,gBACrC,OAAO,eAAe,SAAS,QAAQ,cAAc,QAAQ,iBAC3D;CAEJ,MAAM,mBAAmB,qBAAqB,KAAK,QAAQ;AAE3D,KAAI,SAAS,YAEX,QAAO;CAIT,MAAM,gBAAgB,mBAAmB,iBAAiB;CAI1D,MAAM,YAAY,gBACd,IAAI,IAAI,iBAAiB,GACzB,IAAI,IAAI,kBAAkB,qBAAqB;CAGnD,IAAI,WAAW,UAAU;AAGzB,KAAI,CAAC,SAAS,WAAW,IAAI,CAC3B,YAAW,IAAI;CAIjB,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,cAAc,GAAG,SAAS,GAAG,gBAAgB;AAEnE,MAAI,cACF,QAAO,GAAG,UAAU,gBAAgB,UAAU;AAGhD,SAAO,GAAG,gBAAgB,UAAU;;CAItC,MAAM,kBACJ,eAAe,UAAU,KAAK,eAAe,UAAU;CAMzD,IAAI,gBAHF,SAAS,gBAAiB,SAAS,uBAAuB,CAAC,kBAG1B,IAAI,gBAAgB,aAAa;AAGpE,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.mjs","names":[],"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 {\n locales = configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n defaultLocale = configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode = configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n } = options;\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 addSlash: false,\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,EACJ,UAAU,eAAe,sBAAsB,WAC7C,cAAc,qBAAqB,SACrC,gBAAgB,eAAe,sBAAsB,iBACnD,cAAc,qBAAqB,gBACrC,OAAO,eAAe,SAAS,QAAQ,cAAc,QAAQ,iBAC3D;CAEJ,MAAM,mBAAmB,qBAAqB,KAAK,QAAQ;AAE3D,KAAI,SAAS,YAEX,QAAO;CAIT,MAAM,gBAAgB,mBAAmB,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;;CAUtC,IAAI,gBAAgB,IAPL,UAAU,eAAe;EACtC;EACA;EACA,UAAU;EACX,CAAC,CAG6B,GAAG,UAAU;AAG5C,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"}
@@ -13,7 +13,7 @@ import configuration from "@intlayer/config/built";
13
13
  *
14
14
  * // prefix-no-default mode with non-default locale
15
15
  * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })
16
- * // Returns 'en/'
16
+ * // Returns 'fr/'
17
17
  *
18
18
  * // prefix-all mode
19
19
  * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })
@@ -37,7 +37,12 @@ import configuration from "@intlayer/config/built";
37
37
  */
38
38
  const getPrefix = (locale, options = {}) => {
39
39
  const { defaultLocale = configuration?.internationalization?.defaultLocale, mode = configuration?.routing?.mode, addSlash = true } = options;
40
- return mode === "prefix-all" || mode === "prefix-no-default" && defaultLocale !== locale ? `${defaultLocale}${addSlash ? "/" : ""}` : "";
40
+ if (!locale) return "";
41
+ if (mode === "prefix-all" || mode === "prefix-no-default" && defaultLocale !== locale) {
42
+ if (addSlash) return `${locale}/`;
43
+ return `${locale}`;
44
+ }
45
+ return "";
41
46
  };
42
47
 
43
48
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getPrefix.mjs","names":[],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\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 ''\n *\n * // prefix-no-default mode with non-default locale\n * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns 'en/'\n *\n * // prefix-all mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns 'en/'\n *\n * // search-params mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })\n * // Returns ''\n *\n * // no-prefix mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns ''\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 * @param options.addSlash - Whether to add a trailing slash to the prefix. Defaults to true.\n * @returns The prefix string for the given locale (e.g., 'en/', 'fr/') or an empty string.\n */\nexport const getPrefix = (\n locale?: LocalesValues,\n options: {\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n addSlash?: boolean;\n } = {}\n): string => {\n const {\n defaultLocale = configuration?.internationalization?.defaultLocale,\n mode = configuration?.routing?.mode,\n addSlash = true,\n } = options;\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 return shouldPrefix ? `${defaultLocale}${addSlash ? '/' : ''}` : '';\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,aACX,QACA,UAII,EAAE,KACK;CACX,MAAM,EACJ,gBAAgB,eAAe,sBAAsB,eACrD,OAAO,eAAe,SAAS,MAC/B,WAAW,SACT;AAOJ,QAHE,SAAS,gBACR,SAAS,uBAAuB,kBAAkB,SAE/B,GAAG,gBAAgB,WAAW,MAAM,OAAO"}
1
+ {"version":3,"file":"getPrefix.mjs","names":[],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\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 ''\n *\n * // prefix-no-default mode with non-default locale\n * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns 'fr/'\n *\n * // prefix-all mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns 'en/'\n *\n * // search-params mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })\n * // Returns ''\n *\n * // no-prefix mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns ''\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 * @param options.addSlash - Whether to add a trailing slash to the prefix. Defaults to true.\n * @returns The prefix string for the given locale (e.g., 'en/', 'fr/') or an empty string.\n */\nexport const getPrefix = (\n locale: LocalesValues,\n options: {\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n addSlash?: boolean;\n } = {}\n): string => {\n const {\n defaultLocale = configuration?.internationalization?.defaultLocale,\n mode = configuration?.routing?.mode,\n addSlash = true,\n } = options;\n\n if (!locale) return '';\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 if (addSlash) {\n return `${locale}/`;\n }\n\n return `${locale}`;\n }\n\n return '';\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,aACX,QACA,UAII,EAAE,KACK;CACX,MAAM,EACJ,gBAAgB,eAAe,sBAAsB,eACrD,OAAO,eAAe,SAAS,MAC/B,WAAW,SACT;AAEJ,KAAI,CAAC,OAAQ,QAAO;AAOpB,KAHE,SAAS,gBACR,SAAS,uBAAuB,kBAAkB,QAEnC;AAChB,MAAI,SACF,QAAO,GAAG,OAAO;AAGnB,SAAO,GAAG;;AAGZ,QAAO"}
@@ -6,9 +6,9 @@ import { getLocaleFromPath } from "./getLocaleFromPath.mjs";
6
6
  import { getLocaleLang } from "./getLocaleLang.mjs";
7
7
  import { getLocaleName } from "./getLocaleName.mjs";
8
8
  import { getPathWithoutLocale } from "./getPathWithoutLocale.mjs";
9
+ import { getPrefix } from "./getPrefix.mjs";
9
10
  import { getLocalizedUrl } from "./getLocalizedUrl.mjs";
10
11
  import { getMultilingualUrls } from "./getMultilingualUrls.mjs";
11
- import { getPrefix } from "./getPrefix.mjs";
12
12
  import { localeFlatMap, localeMap, localeRecord } from "./localeMapper.mjs";
13
13
 
14
14
  export { getBrowserLocale, getHTMLTextDir, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions };
@@ -1,6 +1,6 @@
1
1
  import { NodeProps, Plugins } from "../interpreter/getContent/plugins.js";
2
2
  import "../interpreter/index.js";
3
- import * as _intlayer_types5 from "@intlayer/types";
3
+ import * as _intlayer_types0 from "@intlayer/types";
4
4
  import { ContentNode, DeclaredLocales, Dictionary, LocalesValues } from "@intlayer/types";
5
5
 
6
6
  //#region src/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts
@@ -24,11 +24,11 @@ declare const getFilterMissingTranslationsContent: <T extends ContentNode, L ext
24
24
  declare const getFilterMissingTranslationsDictionary: (dictionary: Dictionary, localeToCheck: LocalesValues) => {
25
25
  content: any;
26
26
  $schema?: string;
27
- id?: _intlayer_types5.DictionaryId;
27
+ id?: _intlayer_types0.DictionaryId;
28
28
  projectIds?: string[];
29
- localId?: _intlayer_types5.LocalDictionaryId;
30
- localIds?: _intlayer_types5.LocalDictionaryId[];
31
- key: _intlayer_types5.DictionaryKey;
29
+ localId?: _intlayer_types0.LocalDictionaryId;
30
+ localIds?: _intlayer_types0.LocalDictionaryId[];
31
+ key: _intlayer_types0.DictionaryKey;
32
32
  title?: string;
33
33
  description?: string;
34
34
  versions?: string[];
@@ -36,11 +36,11 @@ declare const getFilterMissingTranslationsDictionary: (dictionary: Dictionary, l
36
36
  filePath?: string;
37
37
  tags?: string[];
38
38
  locale?: LocalesValues;
39
- fill?: _intlayer_types5.Fill;
39
+ fill?: _intlayer_types0.Fill;
40
40
  filled?: true;
41
41
  priority?: number;
42
42
  live?: boolean;
43
- location?: _intlayer_types5.DictionaryLocation;
43
+ location?: _intlayer_types0.DictionaryLocation;
44
44
  };
45
45
  //#endregion
46
46
  export { filterMissingTranslationsOnlyPlugin, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary };
@@ -1,6 +1,6 @@
1
1
  import { DeepTransformContent, NodeProps, Plugins } from "../interpreter/getContent/plugins.js";
2
2
  import "../interpreter/index.js";
3
- import * as _intlayer_types11 from "@intlayer/types";
3
+ import * as _intlayer_types12 from "@intlayer/types";
4
4
  import { ContentNode, DeclaredLocales, Dictionary, LocalesValues } from "@intlayer/types";
5
5
 
6
6
  //#region src/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts
@@ -16,11 +16,11 @@ declare const getFilterTranslationsOnlyContent: <T extends ContentNode, L extend
16
16
  declare const getFilterTranslationsOnlyDictionary: (dictionary: Dictionary, locale?: LocalesValues, fallback?: LocalesValues) => {
17
17
  content: any;
18
18
  $schema?: string;
19
- id?: _intlayer_types11.DictionaryId;
19
+ id?: _intlayer_types12.DictionaryId;
20
20
  projectIds?: string[];
21
- localId?: _intlayer_types11.LocalDictionaryId;
22
- localIds?: _intlayer_types11.LocalDictionaryId[];
23
- key: _intlayer_types11.DictionaryKey;
21
+ localId?: _intlayer_types12.LocalDictionaryId;
22
+ localIds?: _intlayer_types12.LocalDictionaryId[];
23
+ key: _intlayer_types12.DictionaryKey;
24
24
  title?: string;
25
25
  description?: string;
26
26
  versions?: string[];
@@ -28,11 +28,11 @@ declare const getFilterTranslationsOnlyDictionary: (dictionary: Dictionary, loca
28
28
  filePath?: string;
29
29
  tags?: string[];
30
30
  locale?: LocalesValues;
31
- fill?: _intlayer_types11.Fill;
31
+ fill?: _intlayer_types12.Fill;
32
32
  filled?: true;
33
33
  priority?: number;
34
34
  live?: boolean;
35
- location?: _intlayer_types11.DictionaryLocation;
35
+ location?: _intlayer_types12.DictionaryLocation;
36
36
  };
37
37
  //#endregion
38
38
  export { filterTranslationsOnlyPlugin, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary };
@@ -1,6 +1,6 @@
1
1
  import { NodeProps } from "../interpreter/getContent/plugins.js";
2
2
  import "../interpreter/index.js";
3
- import * as _intlayer_types0 from "@intlayer/types";
3
+ import * as _intlayer_types5 from "@intlayer/types";
4
4
  import { ContentNode, Dictionary, LocalesValues } from "@intlayer/types";
5
5
 
6
6
  //#region src/deepTransformPlugins/getFilteredLocalesContent.d.ts
@@ -8,11 +8,11 @@ declare const getFilteredLocalesContent: (node: ContentNode, locales: LocalesVal
8
8
  declare const getFilteredLocalesDictionary: (dictionary: Dictionary, locale: LocalesValues | LocalesValues[]) => {
9
9
  content: any;
10
10
  $schema?: string;
11
- id?: _intlayer_types0.DictionaryId;
11
+ id?: _intlayer_types5.DictionaryId;
12
12
  projectIds?: string[];
13
- localId?: _intlayer_types0.LocalDictionaryId;
14
- localIds?: _intlayer_types0.LocalDictionaryId[];
15
- key: _intlayer_types0.DictionaryKey;
13
+ localId?: _intlayer_types5.LocalDictionaryId;
14
+ localIds?: _intlayer_types5.LocalDictionaryId[];
15
+ key: _intlayer_types5.DictionaryKey;
16
16
  title?: string;
17
17
  description?: string;
18
18
  versions?: string[];
@@ -20,11 +20,11 @@ declare const getFilteredLocalesDictionary: (dictionary: Dictionary, locale: Loc
20
20
  filePath?: string;
21
21
  tags?: string[];
22
22
  locale?: LocalesValues;
23
- fill?: _intlayer_types0.Fill;
23
+ fill?: _intlayer_types5.Fill;
24
24
  filled?: true;
25
25
  priority?: number;
26
26
  live?: boolean;
27
- location?: _intlayer_types0.DictionaryLocation;
27
+ location?: _intlayer_types5.DictionaryLocation;
28
28
  };
29
29
  //#endregion
30
30
  export { getFilteredLocalesContent, getFilteredLocalesDictionary };
@@ -1,4 +1,4 @@
1
- import * as _intlayer_types17 from "@intlayer/types";
1
+ import * as _intlayer_types11 from "@intlayer/types";
2
2
  import { Dictionary } from "@intlayer/types";
3
3
 
4
4
  //#region src/dictionaryManipulator/orderDictionaries.d.ts
@@ -10,7 +10,7 @@ import { Dictionary } from "@intlayer/types";
10
10
  * @param priorityStrategy - The priority strategy ('local_first' or 'distant_first')
11
11
  * @returns Ordered array of dictionaries
12
12
  */
13
- declare const orderDictionaries: (dictionaries: Dictionary[], configuration?: _intlayer_types17.IntlayerConfig) => Dictionary[];
13
+ declare const orderDictionaries: (dictionaries: Dictionary[], configuration?: _intlayer_types11.IntlayerConfig) => Dictionary[];
14
14
  //#endregion
15
15
  export { orderDictionaries };
16
16
  //# sourceMappingURL=orderDictionaries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","names":[],"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAoCA;AAcA;;;;;;AAIqB,KAlBT,OAAA,GAkBS;EAAP,EAAA,EAAA,MAAA;EACR,SAAA,EAAA,CAAA,IAAA,EAAA,GAAA,EAAA,GAAA,OAAA;EAAgB,SAAA,EAAA,CAAA,IAAA,EAAA,GAAA,EAAA,KAAA,EAdX,SAcW,EAAA,WAAA,EAAA,CAAA,IAAA,EAAA,GAAA,EAAA,KAAA,EAbc,SAad,EAAA,GAAA,GAAA,EAAA,GAAA,GAAA;CACO;;;;AACA,KAPjB,eAOiB,CAAA,CAAA,EAAA,CAAA,EAAA,UAPe,aAOf,CAAA,GAPgC,CAOhC,SAAA;EAAQ,QAAA,EANzB,QAMyB,GAAA,MAAA;EAAI,CALtC,QAAA,CAAS,WAAA,CAK6B,EAAA,KAAA,EAAA;CAAjC,GAHJ,CAGI,SAHM,MAGN,CAHa,WAGb,EAAA,OAAA,CAAA,GAFF,CAEE,SAAA,MAFc,CAEd,GADA,oBACA,CADqB,CACrB,CADuB,CACvB,CAAA,EAD2B,CAC3B,CAAA,GAAA,oBAAA,CAAqB,CAArB,CAAA,MAA6B,CAA7B,CAAA,EAAiC,CAAjC,CAAA,GAAA,KAAA,GAAA,KAAA;;AAKK,cAAA,iBA2BX,EAAA,CAAA,MAAA,EA1BQ,aA0BR,EAAA,QAAA,CAAA,EAzBW,aAyBX,EAAA,GAxBC,OAwBD;;;;AAAA,KAMU,eANV,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,GAMqC,CANrC,SAAA;EAMU,QAAA,EACA,QADe,GAAA,MAAA;EAAY,CAEpC,QAAA,CAAS,WAAA,CAF2B,EAAA,MAAA;CAC3B,GAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GAKH,oBALG,CAMN,CANM,CAM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CA7C3B,EA6C8B,CA7C9B,CAAA,EAAG,GA8CrB,CA9CqB;AAAjB,KAgDE,KAhDF,CAAA,CAAA,CAAA,GAAA,CAAA,SAAA,CAAA,GAgD2B,CAhD3B,GAAA,IAAA,GAAA,KAAA;;AAOV;AAOE;AAOmC,KAgCzB,oBAhCyB,CAAA,CAAA,EAAA,IAkC/B,uBAlC+B,EAAA,UAmCzB,aAnCyB,GAmCT,eAnCS,CAAA,GAoCjC,KApCiC,CAoC3B,CApC2B,CAAA,SAAA,IAAA,GAqCjC,CArCiC,GAsCjC,gBAtCiC,CAsChB,CAtCgB,EAAA,MAsCP,kBAtCO,CAsCY,CAtCZ,EAsCe,CAtCf,EAsCkB,CAtClB,CAAA,EAsCsB,CAtCtB,CAAA,SAAA,KAAA,GAwC/B,QAxC+B,CAwCtB,CAxCsB,EAwCnB,CAxCmB,EAwChB,CAxCgB,CAAA,GA0C/B,kBA1C+B,CA0CZ,CA1CY,EA0CT,CA1CS,EA0CN,CA1CM,CAAA,CAAA,MA0CG,kBA1CH,CA0CsB,CA1CtB,EA0CyB,CA1CzB,EA0C4B,CA1C5B,CAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getLocalizedUrl.d.ts","names":[],"sources":["../../../src/localization/getLocalizedUrl.ts"],"sourcesContent":[],"mappings":";;;;;;AA0CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,8CAEI;YAEH;kBACM"}
1
+ {"version":3,"file":"getLocalizedUrl.d.ts","names":[],"sources":["../../../src/localization/getLocalizedUrl.ts"],"sourcesContent":[],"mappings":";;;;;;AA2CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,8CAEI;YAEH;kBACM"}
@@ -14,7 +14,7 @@ import { LocalesValues } from "@intlayer/types";
14
14
  *
15
15
  * // prefix-no-default mode with non-default locale
16
16
  * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })
17
- * // Returns 'en/'
17
+ * // Returns 'fr/'
18
18
  *
19
19
  * // prefix-all mode
20
20
  * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })
@@ -36,7 +36,7 @@ import { LocalesValues } from "@intlayer/types";
36
36
  * @param options.addSlash - Whether to add a trailing slash to the prefix. Defaults to true.
37
37
  * @returns The prefix string for the given locale (e.g., 'en/', 'fr/') or an empty string.
38
38
  */
39
- declare const getPrefix: (locale?: LocalesValues, options?: {
39
+ declare const getPrefix: (locale: LocalesValues, options?: {
40
40
  defaultLocale?: LocalesValues;
41
41
  mode?: "prefix-no-default" | "prefix-all" | "no-prefix" | "search-params";
42
42
  addSlash?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"getPrefix.d.ts","names":[],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":[],"mappings":";;;;;;AAqCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,qBACF;kBAES"}
1
+ {"version":3,"file":"getPrefix.d.ts","names":[],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":[],"mappings":";;;;;;AAqCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,oBACH;kBAEU"}
@@ -23,7 +23,7 @@ type TranslationContent<Content = unknown, RecordContent extends StrictModeLocal
23
23
  * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
24
24
  */
25
25
  declare const translation: <Content = unknown, ContentRecord extends StrictModeLocaleMap<Content> = StrictModeLocaleMap<Content>>(content: ContentRecord) => TypedNodeModel<NodeType.Translation, ContentRecord, {
26
- nodeType: "translation" | NodeType.Translation;
26
+ nodeType: NodeType.Translation | "translation";
27
27
  } & {
28
28
  translation: ContentRecord;
29
29
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"translation.d.ts","names":[],"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":[],"mappings":";;;KAOY,4DAGR,oBAAoB,WAAW,oBAAoB,YACnD,eAAe,QAAA,CAAS,aAAa;;AAJzC;;;;;;;;;AAIwD;;;;;;;;;;cAsBlD,WAKkB,EAAA,CAAA,UAAA,OAAA,EAAA,sBAFpB,mBAEoB,CAFA,OAEA,CAAA,GAFW,mBAEX,CAF+B,OAE/B,CAAA,CAAA,CAAA,OAAA,EAAb,aAAa,EAAA,GAAA,cAAA,CAAA,QAAA,CAAA,WAAA,EAAA,aAAA,EAAA;EAAA,QAAA,EAAA,aAAA,uBAAA"}
1
+ {"version":3,"file":"translation.d.ts","names":[],"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":[],"mappings":";;;KAOY,4DAGR,oBAAoB,WAAW,oBAAoB,YACnD,eAAe,QAAA,CAAS,aAAa;;AAJzC;;;;;;;;;AAIwD;;;;;;;;;;cAsBlD,WAKkB,EAAA,CAAA,UAAA,OAAA,EAAA,sBAFpB,mBAEoB,CAFA,OAEA,CAAA,GAFW,mBAEX,CAF+B,OAE/B,CAAA,CAAA,CAAA,OAAA,EAAb,aAAa,EAAA,GAAA,cAAA,CAAA,QAAA,CAAA,WAAA,EAAA,aAAA,EAAA;EAAA,QAAA,sBAAA,GAAA,aAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/core",
3
- "version": "7.1.0-canary.0",
3
+ "version": "7.1.0-canary.1",
4
4
  "private": false,
5
5
  "description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
6
6
  "keywords": [
@@ -101,11 +101,11 @@
101
101
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
102
102
  },
103
103
  "dependencies": {
104
- "@intlayer/api": "7.1.0-canary.0",
105
- "@intlayer/config": "7.1.0-canary.0",
106
- "@intlayer/dictionaries-entry": "7.1.0-canary.0",
107
- "@intlayer/types": "7.1.0-canary.0",
108
- "@intlayer/unmerged-dictionaries-entry": "7.1.0-canary.0",
104
+ "@intlayer/api": "7.1.0-canary.1",
105
+ "@intlayer/config": "7.1.0-canary.1",
106
+ "@intlayer/dictionaries-entry": "7.1.0-canary.1",
107
+ "@intlayer/types": "7.1.0-canary.1",
108
+ "@intlayer/unmerged-dictionaries-entry": "7.1.0-canary.1",
109
109
  "deepmerge": "4.3.1"
110
110
  },
111
111
  "devDependencies": {
@@ -119,11 +119,11 @@
119
119
  "vitest": "4.0.8"
120
120
  },
121
121
  "peerDependencies": {
122
- "@intlayer/api": "7.1.0-canary.0",
123
- "@intlayer/config": "7.1.0-canary.0",
124
- "@intlayer/dictionaries-entry": "7.1.0-canary.0",
125
- "@intlayer/types": "7.1.0-canary.0",
126
- "@intlayer/unmerged-dictionaries-entry": "7.1.0-canary.0"
122
+ "@intlayer/api": "7.1.0-canary.1",
123
+ "@intlayer/config": "7.1.0-canary.1",
124
+ "@intlayer/dictionaries-entry": "7.1.0-canary.1",
125
+ "@intlayer/types": "7.1.0-canary.1",
126
+ "@intlayer/unmerged-dictionaries-entry": "7.1.0-canary.1"
127
127
  },
128
128
  "engines": {
129
129
  "node": ">=14.18"