@intlayer/core 7.0.9-canary.2 → 7.0.9-canary.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +3 -1
- package/dist/cjs/localization/getLocalizedUrl.cjs +33 -10
- package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
- package/dist/cjs/localization/getMultilingualUrls.cjs +16 -33
- package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
- package/dist/cjs/localization/getPrefix.cjs +47 -0
- package/dist/cjs/localization/getPrefix.cjs.map +1 -0
- package/dist/cjs/localization/index.cjs +3 -1
- package/dist/esm/index.mjs +3 -2
- package/dist/esm/localization/getLocalizedUrl.mjs +33 -10
- package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
- package/dist/esm/localization/getMultilingualUrls.mjs +16 -33
- package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
- package/dist/esm/localization/getPrefix.mjs +45 -0
- package/dist/esm/localization/getPrefix.mjs.map +1 -0
- package/dist/esm/localization/index.mjs +3 -2
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +7 -7
- package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +7 -7
- package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +7 -7
- package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +2 -2
- package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
- package/dist/types/localization/getLocalizedUrl.d.ts +13 -8
- package/dist/types/localization/getLocalizedUrl.d.ts.map +1 -1
- package/dist/types/localization/getMultilingualUrls.d.ts +13 -8
- package/dist/types/localization/getMultilingualUrls.d.ts.map +1 -1
- package/dist/types/localization/getPrefix.d.ts +46 -0
- package/dist/types/localization/getPrefix.d.ts.map +1 -0
- package/dist/types/localization/index.d.ts +2 -1
- package/dist/types/transpiler/translation/translation.d.ts +1 -1
- package/dist/types/transpiler/translation/translation.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -60,8 +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_getMultilingualUrls = require('./localization/getMultilingualUrls.cjs');
|
|
64
63
|
const require_localization_getLocalizedUrl = require('./localization/getLocalizedUrl.cjs');
|
|
64
|
+
const require_localization_getMultilingualUrls = require('./localization/getMultilingualUrls.cjs');
|
|
65
|
+
const require_localization_getPrefix = require('./localization/getPrefix.cjs');
|
|
65
66
|
const require_localization_localeMapper = require('./localization/localeMapper.cjs');
|
|
66
67
|
const require_utils_isSameKeyPath = require('./utils/isSameKeyPath.cjs');
|
|
67
68
|
|
|
@@ -121,6 +122,7 @@ exports.getNodeChildren = require_dictionaryManipulator_getNodeChildren.getNodeC
|
|
|
121
122
|
exports.getNodeType = require_dictionaryManipulator_getNodeType.getNodeType;
|
|
122
123
|
exports.getPathWithoutLocale = require_localization_getPathWithoutLocale.getPathWithoutLocale;
|
|
123
124
|
exports.getPerLocaleDictionary = require_deepTransformPlugins_getLocalizedContent.getPerLocaleDictionary;
|
|
125
|
+
exports.getPrefix = require_localization_getPrefix.getPrefix;
|
|
124
126
|
exports.getReplacedValuesContent = require_deepTransformPlugins_getReplacedValuesContent.getReplacedValuesContent;
|
|
125
127
|
exports.getSplittedContent = require_deepTransformPlugins_getSplittedContent.getSplittedContent;
|
|
126
128
|
exports.getSplittedDictionaryContent = require_deepTransformPlugins_getSplittedContent.getSplittedDictionaryContent;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const
|
|
2
|
+
const require_utils_checkIsURLAbsolute = require('../utils/checkIsURLAbsolute.cjs');
|
|
3
|
+
const require_localization_getPathWithoutLocale = require('./getPathWithoutLocale.cjs');
|
|
4
|
+
let __intlayer_config_client = require("@intlayer/config/client");
|
|
3
5
|
let __intlayer_config_built = require("@intlayer/config/built");
|
|
4
6
|
__intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
|
|
5
7
|
|
|
@@ -14,33 +16,54 @@ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_bui
|
|
|
14
16
|
*
|
|
15
17
|
* ```ts
|
|
16
18
|
* // prefix-no-default mode
|
|
17
|
-
* getLocalizedUrl('/about', 'fr', ['en', 'fr'], 'en', 'prefix-no-default');
|
|
19
|
+
* getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' });
|
|
18
20
|
* // Returns '/fr/about' for the French locale
|
|
19
21
|
* // Returns '/about' for the English locale (default)
|
|
20
22
|
*
|
|
21
23
|
* // prefix-all mode
|
|
22
|
-
* getLocalizedUrl('/about', 'en', ['en', 'fr'], 'en', 'prefix-all');
|
|
24
|
+
* getLocalizedUrl('/about', 'en', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' });
|
|
23
25
|
* // Returns '/en/about' for the English locale
|
|
24
26
|
* // Returns '/fr/about' for the French locale
|
|
25
27
|
*
|
|
26
28
|
* // search-params mode
|
|
27
|
-
* getLocalizedUrl('/about', 'fr', ['en', 'fr'], 'en', 'search-params');
|
|
29
|
+
* getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' });
|
|
28
30
|
* // Returns '/about?locale=fr' for the French locale
|
|
29
31
|
*
|
|
30
32
|
* // no-prefix mode
|
|
31
|
-
* getLocalizedUrl('/about', 'fr', ['en', 'fr'], 'en', 'no-prefix');
|
|
33
|
+
* getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' });
|
|
32
34
|
* // Returns '/about' for any locale
|
|
33
35
|
* ```
|
|
34
36
|
*
|
|
35
37
|
* @param url - The original URL string to be processed.
|
|
36
38
|
* @param currentLocale - The current locale.
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
* @param
|
|
39
|
+
* @param options - Configuration options
|
|
40
|
+
* @param options.locales - Optional array of supported locales. Defaults to configured locales.
|
|
41
|
+
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
42
|
+
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
40
43
|
* @returns The localized URL for the current locale.
|
|
41
44
|
*/
|
|
42
|
-
const getLocalizedUrl = (url, currentLocale,
|
|
43
|
-
|
|
45
|
+
const getLocalizedUrl = (url, currentLocale, options = {}) => {
|
|
46
|
+
const { locales = __intlayer_config_built.default?.internationalization?.locales ?? __intlayer_config_client.DefaultValues.Internationalization.LOCALES, defaultLocale = __intlayer_config_built.default?.internationalization?.defaultLocale ?? __intlayer_config_client.DefaultValues.Internationalization.DEFAULT_LOCALE, mode = __intlayer_config_built.default?.routing?.mode ?? __intlayer_config_client.DefaultValues.Routing.ROUTING_MODE } = options;
|
|
47
|
+
const urlWithoutLocale = require_localization_getPathWithoutLocale.getPathWithoutLocale(url, locales);
|
|
48
|
+
if (mode === "no-prefix") return urlWithoutLocale;
|
|
49
|
+
const isAbsoluteUrl = require_utils_checkIsURLAbsolute.checkIsURLAbsolute(urlWithoutLocale);
|
|
50
|
+
const parsedUrl = isAbsoluteUrl ? new URL(urlWithoutLocale) : new URL(urlWithoutLocale, "http://example.com");
|
|
51
|
+
let pathname = parsedUrl.pathname;
|
|
52
|
+
if (!pathname.startsWith("/")) pathname = `/${pathname}`;
|
|
53
|
+
const baseUrl = isAbsoluteUrl ? `${parsedUrl.protocol}//${parsedUrl.host}` : "";
|
|
54
|
+
if (mode === "search-params") {
|
|
55
|
+
const searchParams = new URLSearchParams(parsedUrl.search);
|
|
56
|
+
searchParams.set("locale", currentLocale.toString());
|
|
57
|
+
const queryString = searchParams.toString();
|
|
58
|
+
const pathWithQuery = queryString ? `${pathname}?${queryString}` : pathname;
|
|
59
|
+
if (isAbsoluteUrl) return `${baseUrl}${pathWithQuery}${parsedUrl.hash}`;
|
|
60
|
+
return `${pathWithQuery}${parsedUrl.hash}`;
|
|
61
|
+
}
|
|
62
|
+
const isDefaultLocale = currentLocale?.toString() === defaultLocale?.toString();
|
|
63
|
+
let localizedPath = mode === "prefix-all" || mode === "prefix-no-default" && !isDefaultLocale ? `/${currentLocale}${pathname}` : pathname;
|
|
64
|
+
if (localizedPath.length > 1 && localizedPath.endsWith("/")) localizedPath = localizedPath.slice(0, -1);
|
|
65
|
+
if (isAbsoluteUrl) return `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;
|
|
66
|
+
return `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;
|
|
44
67
|
};
|
|
45
68
|
|
|
46
69
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocalizedUrl.cjs","names":["configuration","
|
|
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,7 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const
|
|
3
|
-
const require_localization_getPathWithoutLocale = require('./getPathWithoutLocale.cjs');
|
|
4
|
-
let __intlayer_config_client = require("@intlayer/config/client");
|
|
2
|
+
const require_localization_getLocalizedUrl = require('./getLocalizedUrl.cjs');
|
|
5
3
|
let __intlayer_config_built = require("@intlayer/config/built");
|
|
6
4
|
__intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
|
|
7
5
|
|
|
@@ -17,52 +15,37 @@ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_bui
|
|
|
17
15
|
*
|
|
18
16
|
* ```ts
|
|
19
17
|
* // prefix-no-default mode
|
|
20
|
-
* getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', 'prefix-no-default')
|
|
18
|
+
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
21
19
|
* // Returns { en: '/dashboard', fr: '/fr/dashboard' }
|
|
22
20
|
*
|
|
23
21
|
* // prefix-all mode
|
|
24
|
-
* getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', 'prefix-all')
|
|
22
|
+
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' })
|
|
25
23
|
* // Returns { en: '/en/dashboard', fr: '/fr/dashboard' }
|
|
26
24
|
*
|
|
27
25
|
* // search-params mode
|
|
28
|
-
* getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', 'search-params')
|
|
26
|
+
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' })
|
|
29
27
|
* // Returns { en: '/dashboard?locale=en', fr: '/dashboard?locale=fr' }
|
|
30
28
|
*
|
|
31
29
|
* // no-prefix mode
|
|
32
|
-
* getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', 'no-prefix')
|
|
30
|
+
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' })
|
|
33
31
|
* // Returns { en: '/dashboard', fr: '/dashboard' }
|
|
34
32
|
* ```
|
|
35
33
|
*
|
|
36
34
|
* @param url - The original URL string to be processed.
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
* @param
|
|
35
|
+
* @param options - Configuration options
|
|
36
|
+
* @param options.locales - Optional array of supported locales. Defaults to configured locales.
|
|
37
|
+
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
38
|
+
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
40
39
|
* @returns An object mapping each locale to its corresponding multilingual URL.
|
|
41
40
|
*/
|
|
42
|
-
const getMultilingualUrls = (url,
|
|
43
|
-
const
|
|
44
|
-
const isAbsoluteUrl = require_utils_checkIsURLAbsolute.checkIsURLAbsolute(urlWithoutLocale);
|
|
45
|
-
const parsedUrl = isAbsoluteUrl ? new URL(urlWithoutLocale) : new URL(urlWithoutLocale, "http://example.com");
|
|
46
|
-
let pathname = parsedUrl.pathname;
|
|
47
|
-
if (!pathname.startsWith("/")) pathname = `/${pathname}`;
|
|
48
|
-
const baseUrl = isAbsoluteUrl ? `${parsedUrl.protocol}//${parsedUrl.host}` : "";
|
|
49
|
-
const routingMode = mode ?? __intlayer_config_client.DefaultValues.Routing.ROUTING_MODE;
|
|
41
|
+
const getMultilingualUrls = (url, options = {}) => {
|
|
42
|
+
const { locales = __intlayer_config_built.default?.internationalization?.locales, defaultLocale = __intlayer_config_built.default?.internationalization?.defaultLocale, mode = __intlayer_config_built.default?.routing?.mode } = options;
|
|
50
43
|
return (locales ?? []).reduce((acc, locale) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const queryString = searchParams.toString();
|
|
57
|
-
const pathWithQuery = queryString ? `${pathname}?${queryString}` : pathname;
|
|
58
|
-
localizedUrl = isAbsoluteUrl ? `${baseUrl}${pathWithQuery}${parsedUrl.hash}` : `${pathWithQuery}${parsedUrl.hash}`;
|
|
59
|
-
} else if (routingMode === "no-prefix") localizedUrl = isAbsoluteUrl ? `${baseUrl}${pathname}${parsedUrl.search}${parsedUrl.hash}` : `${pathname}${parsedUrl.search}${parsedUrl.hash}`;
|
|
60
|
-
else {
|
|
61
|
-
let localizedPath = routingMode === "prefix-all" || routingMode === "prefix-no-default" && !isDefaultLocale ? `/${locale}${pathname}` : pathname;
|
|
62
|
-
if (localizedPath.length > 1 && localizedPath.endsWith("/")) localizedPath = localizedPath.slice(0, -1);
|
|
63
|
-
localizedUrl = isAbsoluteUrl ? `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}` : `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;
|
|
64
|
-
}
|
|
65
|
-
acc[locale] = localizedUrl;
|
|
44
|
+
acc[locale] = require_localization_getLocalizedUrl.getLocalizedUrl(url, locale, {
|
|
45
|
+
locales,
|
|
46
|
+
defaultLocale,
|
|
47
|
+
mode
|
|
48
|
+
});
|
|
66
49
|
return acc;
|
|
67
50
|
}, {});
|
|
68
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMultilingualUrls.cjs","names":["configuration","
|
|
1
|
+
{"version":3,"file":"getMultilingualUrls.cjs","names":["configuration","getLocalizedUrl"],"sources":["../../../src/localization/getMultilingualUrls.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\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 {\n locales = configuration?.internationalization?.locales,\n defaultLocale = configuration?.internationalization?.defaultLocale,\n mode = configuration?.routing?.mode,\n } = options;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,uBACX,KACA,UAII,EAAE,KAC0B;CAChC,MAAM,EACJ,UAAUA,iCAAe,sBAAsB,SAC/C,gBAAgBA,iCAAe,sBAAsB,eACrD,OAAOA,iCAAe,SAAS,SAC7B;AAoBJ,SAjB0B,WAAW,EAAE,EAAE,QACtC,KAAK,WAAW;AASf,MAAI,UAPiBC,qDAAgB,KAAK,QAAQ;GAChD;GACA;GACA;GACD,CAAC;AAKF,SAAO;IAET,EAAE,CACH"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __intlayer_config_built = require("@intlayer/config/built");
|
|
3
|
+
__intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
|
|
4
|
+
|
|
5
|
+
//#region src/localization/getPrefix.ts
|
|
6
|
+
/**
|
|
7
|
+
* Determines the URL prefix for a given locale based on the routing mode configuration.
|
|
8
|
+
*
|
|
9
|
+
* Example:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* // prefix-no-default mode with default locale
|
|
13
|
+
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
14
|
+
* // Returns ''
|
|
15
|
+
*
|
|
16
|
+
* // prefix-no-default mode with non-default locale
|
|
17
|
+
* getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
18
|
+
* // Returns 'en/'
|
|
19
|
+
*
|
|
20
|
+
* // prefix-all mode
|
|
21
|
+
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })
|
|
22
|
+
* // Returns 'en/'
|
|
23
|
+
*
|
|
24
|
+
* // search-params mode
|
|
25
|
+
* getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })
|
|
26
|
+
* // Returns ''
|
|
27
|
+
*
|
|
28
|
+
* // no-prefix mode
|
|
29
|
+
* getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })
|
|
30
|
+
* // Returns ''
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param locale - The locale to check for prefix. If not provided, uses configured default locale.
|
|
34
|
+
* @param options - Configuration options
|
|
35
|
+
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
36
|
+
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
37
|
+
* @param options.addSlash - Whether to add a trailing slash to the prefix. Defaults to true.
|
|
38
|
+
* @returns The prefix string for the given locale (e.g., 'en/', 'fr/') or an empty string.
|
|
39
|
+
*/
|
|
40
|
+
const getPrefix = (locale, options = {}) => {
|
|
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 ? "/" : ""}` : "";
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.getPrefix = getPrefix;
|
|
47
|
+
//# sourceMappingURL=getPrefix.cjs.map
|
|
@@ -0,0 +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"}
|
|
@@ -6,8 +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_getMultilingualUrls = require('./getMultilingualUrls.cjs');
|
|
10
9
|
const require_localization_getLocalizedUrl = require('./getLocalizedUrl.cjs');
|
|
10
|
+
const require_localization_getMultilingualUrls = require('./getMultilingualUrls.cjs');
|
|
11
|
+
const require_localization_getPrefix = require('./getPrefix.cjs');
|
|
11
12
|
const require_localization_localeMapper = require('./localeMapper.cjs');
|
|
12
13
|
|
|
13
14
|
exports.getBrowserLocale = require_localization_getBrowserLocale.getBrowserLocale;
|
|
@@ -18,6 +19,7 @@ exports.getLocaleName = require_localization_getLocaleName.getLocaleName;
|
|
|
18
19
|
exports.getLocalizedUrl = require_localization_getLocalizedUrl.getLocalizedUrl;
|
|
19
20
|
exports.getMultilingualUrls = require_localization_getMultilingualUrls.getMultilingualUrls;
|
|
20
21
|
exports.getPathWithoutLocale = require_localization_getPathWithoutLocale.getPathWithoutLocale;
|
|
22
|
+
exports.getPrefix = require_localization_getPrefix.getPrefix;
|
|
21
23
|
exports.localeDetector = require_localization_localeDetector.localeDetector;
|
|
22
24
|
exports.localeFlatMap = require_localization_localeMapper.localeFlatMap;
|
|
23
25
|
exports.localeMap = require_localization_localeMapper.localeMap;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -60,9 +60,10 @@ 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 { getMultilingualUrls } from "./localization/getMultilingualUrls.mjs";
|
|
64
63
|
import { getLocalizedUrl } from "./localization/getLocalizedUrl.mjs";
|
|
64
|
+
import { getMultilingualUrls } from "./localization/getMultilingualUrls.mjs";
|
|
65
|
+
import { getPrefix } from "./localization/getPrefix.mjs";
|
|
65
66
|
import { localeFlatMap, localeMap, localeRecord } from "./localization/localeMapper.mjs";
|
|
66
67
|
import { isSameKeyPath } from "./utils/isSameKeyPath.mjs";
|
|
67
68
|
|
|
68
|
-
export { CachedIntl, CachedIntl as Intl, LocaleStorage, buildMaskPlugin, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, condition as cond, conditionPlugin, createCachedIntl, currency, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, getBrowserLocale, getCondition, getContent, getContentNodeByKeyPath, getDefaultNode, getDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getHTMLTextDir, getInsertionValues, getIntlayer, getLocaleFromPath, getLocaleFromStorage, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getReplacedValuesContent, getSplittedContent, getSplittedDictionaryContent, getStorageAttributes, getTranslation, insertion as insert, insertContentInDictionary, insertionPlugin, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, nesting as nest, nestedPlugin, normalizeDictionaries, normalizeDictionary, number, orderDictionaries, parseYaml, percentage, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, setLocaleInStorage, translation as t, translationPlugin, units, updateNodeChildren };
|
|
69
|
+
export { CachedIntl, CachedIntl as Intl, LocaleStorage, buildMaskPlugin, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, condition as cond, conditionPlugin, createCachedIntl, currency, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, getBrowserLocale, getCondition, getContent, getContentNodeByKeyPath, getDefaultNode, getDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getHTMLTextDir, getInsertionValues, getIntlayer, getLocaleFromPath, getLocaleFromStorage, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPrefix, getReplacedValuesContent, getSplittedContent, getSplittedDictionaryContent, getStorageAttributes, getTranslation, insertion as insert, insertContentInDictionary, insertionPlugin, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, nesting as nest, nestedPlugin, normalizeDictionaries, normalizeDictionary, number, orderDictionaries, parseYaml, percentage, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, setLocaleInStorage, translation as t, translationPlugin, units, updateNodeChildren };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { checkIsURLAbsolute } from "../utils/checkIsURLAbsolute.mjs";
|
|
2
|
+
import { getPathWithoutLocale } from "./getPathWithoutLocale.mjs";
|
|
3
|
+
import { DefaultValues } from "@intlayer/config/client";
|
|
2
4
|
import configuration from "@intlayer/config/built";
|
|
3
5
|
|
|
4
6
|
//#region src/localization/getLocalizedUrl.ts
|
|
@@ -12,33 +14,54 @@ import configuration from "@intlayer/config/built";
|
|
|
12
14
|
*
|
|
13
15
|
* ```ts
|
|
14
16
|
* // prefix-no-default mode
|
|
15
|
-
* getLocalizedUrl('/about', 'fr', ['en', 'fr'], 'en', 'prefix-no-default');
|
|
17
|
+
* getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' });
|
|
16
18
|
* // Returns '/fr/about' for the French locale
|
|
17
19
|
* // Returns '/about' for the English locale (default)
|
|
18
20
|
*
|
|
19
21
|
* // prefix-all mode
|
|
20
|
-
* getLocalizedUrl('/about', 'en', ['en', 'fr'], 'en', 'prefix-all');
|
|
22
|
+
* getLocalizedUrl('/about', 'en', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' });
|
|
21
23
|
* // Returns '/en/about' for the English locale
|
|
22
24
|
* // Returns '/fr/about' for the French locale
|
|
23
25
|
*
|
|
24
26
|
* // search-params mode
|
|
25
|
-
* getLocalizedUrl('/about', 'fr', ['en', 'fr'], 'en', 'search-params');
|
|
27
|
+
* getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' });
|
|
26
28
|
* // Returns '/about?locale=fr' for the French locale
|
|
27
29
|
*
|
|
28
30
|
* // no-prefix mode
|
|
29
|
-
* getLocalizedUrl('/about', 'fr', ['en', 'fr'], 'en', 'no-prefix');
|
|
31
|
+
* getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' });
|
|
30
32
|
* // Returns '/about' for any locale
|
|
31
33
|
* ```
|
|
32
34
|
*
|
|
33
35
|
* @param url - The original URL string to be processed.
|
|
34
36
|
* @param currentLocale - The current locale.
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
37
|
+
* @param options - Configuration options
|
|
38
|
+
* @param options.locales - Optional array of supported locales. Defaults to configured locales.
|
|
39
|
+
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
40
|
+
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
38
41
|
* @returns The localized URL for the current locale.
|
|
39
42
|
*/
|
|
40
|
-
const getLocalizedUrl = (url, currentLocale,
|
|
41
|
-
|
|
43
|
+
const getLocalizedUrl = (url, currentLocale, options = {}) => {
|
|
44
|
+
const { locales = configuration?.internationalization?.locales ?? DefaultValues.Internationalization.LOCALES, defaultLocale = configuration?.internationalization?.defaultLocale ?? DefaultValues.Internationalization.DEFAULT_LOCALE, mode = configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE } = options;
|
|
45
|
+
const urlWithoutLocale = getPathWithoutLocale(url, locales);
|
|
46
|
+
if (mode === "no-prefix") return urlWithoutLocale;
|
|
47
|
+
const isAbsoluteUrl = checkIsURLAbsolute(urlWithoutLocale);
|
|
48
|
+
const parsedUrl = isAbsoluteUrl ? new URL(urlWithoutLocale) : new URL(urlWithoutLocale, "http://example.com");
|
|
49
|
+
let pathname = parsedUrl.pathname;
|
|
50
|
+
if (!pathname.startsWith("/")) pathname = `/${pathname}`;
|
|
51
|
+
const baseUrl = isAbsoluteUrl ? `${parsedUrl.protocol}//${parsedUrl.host}` : "";
|
|
52
|
+
if (mode === "search-params") {
|
|
53
|
+
const searchParams = new URLSearchParams(parsedUrl.search);
|
|
54
|
+
searchParams.set("locale", currentLocale.toString());
|
|
55
|
+
const queryString = searchParams.toString();
|
|
56
|
+
const pathWithQuery = queryString ? `${pathname}?${queryString}` : pathname;
|
|
57
|
+
if (isAbsoluteUrl) return `${baseUrl}${pathWithQuery}${parsedUrl.hash}`;
|
|
58
|
+
return `${pathWithQuery}${parsedUrl.hash}`;
|
|
59
|
+
}
|
|
60
|
+
const isDefaultLocale = currentLocale?.toString() === defaultLocale?.toString();
|
|
61
|
+
let localizedPath = mode === "prefix-all" || mode === "prefix-no-default" && !isDefaultLocale ? `/${currentLocale}${pathname}` : pathname;
|
|
62
|
+
if (localizedPath.length > 1 && localizedPath.endsWith("/")) localizedPath = localizedPath.slice(0, -1);
|
|
63
|
+
if (isAbsoluteUrl) return `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;
|
|
64
|
+
return `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;
|
|
42
65
|
};
|
|
43
66
|
|
|
44
67
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocalizedUrl.mjs","names":[],"sources":["../../../src/localization/getLocalizedUrl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport {
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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athWithoutLocale } from "./getPathWithoutLocale.mjs";
|
|
3
|
-
import { DefaultValues } from "@intlayer/config/client";
|
|
1
|
+
import { getLocalizedUrl } from "./getLocalizedUrl.mjs";
|
|
4
2
|
import configuration from "@intlayer/config/built";
|
|
5
3
|
|
|
6
4
|
//#region src/localization/getMultilingualUrls.ts
|
|
@@ -15,52 +13,37 @@ import configuration from "@intlayer/config/built";
|
|
|
15
13
|
*
|
|
16
14
|
* ```ts
|
|
17
15
|
* // prefix-no-default mode
|
|
18
|
-
* getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', 'prefix-no-default')
|
|
16
|
+
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
19
17
|
* // Returns { en: '/dashboard', fr: '/fr/dashboard' }
|
|
20
18
|
*
|
|
21
19
|
* // prefix-all mode
|
|
22
|
-
* getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', 'prefix-all')
|
|
20
|
+
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' })
|
|
23
21
|
* // Returns { en: '/en/dashboard', fr: '/fr/dashboard' }
|
|
24
22
|
*
|
|
25
23
|
* // search-params mode
|
|
26
|
-
* getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', 'search-params')
|
|
24
|
+
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' })
|
|
27
25
|
* // Returns { en: '/dashboard?locale=en', fr: '/dashboard?locale=fr' }
|
|
28
26
|
*
|
|
29
27
|
* // no-prefix mode
|
|
30
|
-
* getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', 'no-prefix')
|
|
28
|
+
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' })
|
|
31
29
|
* // Returns { en: '/dashboard', fr: '/dashboard' }
|
|
32
30
|
* ```
|
|
33
31
|
*
|
|
34
32
|
* @param url - The original URL string to be processed.
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
33
|
+
* @param options - Configuration options
|
|
34
|
+
* @param options.locales - Optional array of supported locales. Defaults to configured locales.
|
|
35
|
+
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
36
|
+
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
38
37
|
* @returns An object mapping each locale to its corresponding multilingual URL.
|
|
39
38
|
*/
|
|
40
|
-
const getMultilingualUrls = (url,
|
|
41
|
-
const
|
|
42
|
-
const isAbsoluteUrl = checkIsURLAbsolute(urlWithoutLocale);
|
|
43
|
-
const parsedUrl = isAbsoluteUrl ? new URL(urlWithoutLocale) : new URL(urlWithoutLocale, "http://example.com");
|
|
44
|
-
let pathname = parsedUrl.pathname;
|
|
45
|
-
if (!pathname.startsWith("/")) pathname = `/${pathname}`;
|
|
46
|
-
const baseUrl = isAbsoluteUrl ? `${parsedUrl.protocol}//${parsedUrl.host}` : "";
|
|
47
|
-
const routingMode = mode ?? DefaultValues.Routing.ROUTING_MODE;
|
|
39
|
+
const getMultilingualUrls = (url, options = {}) => {
|
|
40
|
+
const { locales = configuration?.internationalization?.locales, defaultLocale = configuration?.internationalization?.defaultLocale, mode = configuration?.routing?.mode } = options;
|
|
48
41
|
return (locales ?? []).reduce((acc, locale) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const queryString = searchParams.toString();
|
|
55
|
-
const pathWithQuery = queryString ? `${pathname}?${queryString}` : pathname;
|
|
56
|
-
localizedUrl = isAbsoluteUrl ? `${baseUrl}${pathWithQuery}${parsedUrl.hash}` : `${pathWithQuery}${parsedUrl.hash}`;
|
|
57
|
-
} else if (routingMode === "no-prefix") localizedUrl = isAbsoluteUrl ? `${baseUrl}${pathname}${parsedUrl.search}${parsedUrl.hash}` : `${pathname}${parsedUrl.search}${parsedUrl.hash}`;
|
|
58
|
-
else {
|
|
59
|
-
let localizedPath = routingMode === "prefix-all" || routingMode === "prefix-no-default" && !isDefaultLocale ? `/${locale}${pathname}` : pathname;
|
|
60
|
-
if (localizedPath.length > 1 && localizedPath.endsWith("/")) localizedPath = localizedPath.slice(0, -1);
|
|
61
|
-
localizedUrl = isAbsoluteUrl ? `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}` : `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;
|
|
62
|
-
}
|
|
63
|
-
acc[locale] = localizedUrl;
|
|
42
|
+
acc[locale] = getLocalizedUrl(url, locale, {
|
|
43
|
+
locales,
|
|
44
|
+
defaultLocale,
|
|
45
|
+
mode
|
|
46
|
+
});
|
|
64
47
|
return acc;
|
|
65
48
|
}, {});
|
|
66
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMultilingualUrls.mjs","names":[
|
|
1
|
+
{"version":3,"file":"getMultilingualUrls.mjs","names":[],"sources":["../../../src/localization/getMultilingualUrls.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\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 {\n locales = configuration?.internationalization?.locales,\n defaultLocale = configuration?.internationalization?.defaultLocale,\n mode = configuration?.routing?.mode,\n } = options;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,uBACX,KACA,UAII,EAAE,KAC0B;CAChC,MAAM,EACJ,UAAU,eAAe,sBAAsB,SAC/C,gBAAgB,eAAe,sBAAsB,eACrD,OAAO,eAAe,SAAS,SAC7B;AAoBJ,SAjB0B,WAAW,EAAE,EAAE,QACtC,KAAK,WAAW;AASf,MAAI,UAPiB,gBAAgB,KAAK,QAAQ;GAChD;GACA;GACA;GACD,CAAC;AAKF,SAAO;IAET,EAAE,CACH"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import configuration from "@intlayer/config/built";
|
|
2
|
+
|
|
3
|
+
//#region src/localization/getPrefix.ts
|
|
4
|
+
/**
|
|
5
|
+
* Determines the URL prefix for a given locale based on the routing mode configuration.
|
|
6
|
+
*
|
|
7
|
+
* Example:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* // prefix-no-default mode with default locale
|
|
11
|
+
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
12
|
+
* // Returns ''
|
|
13
|
+
*
|
|
14
|
+
* // prefix-no-default mode with non-default locale
|
|
15
|
+
* getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
16
|
+
* // Returns 'en/'
|
|
17
|
+
*
|
|
18
|
+
* // prefix-all mode
|
|
19
|
+
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })
|
|
20
|
+
* // Returns 'en/'
|
|
21
|
+
*
|
|
22
|
+
* // search-params mode
|
|
23
|
+
* getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })
|
|
24
|
+
* // Returns ''
|
|
25
|
+
*
|
|
26
|
+
* // no-prefix mode
|
|
27
|
+
* getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })
|
|
28
|
+
* // Returns ''
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param locale - The locale to check for prefix. If not provided, uses configured default locale.
|
|
32
|
+
* @param options - Configuration options
|
|
33
|
+
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
34
|
+
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
35
|
+
* @param options.addSlash - Whether to add a trailing slash to the prefix. Defaults to true.
|
|
36
|
+
* @returns The prefix string for the given locale (e.g., 'en/', 'fr/') or an empty string.
|
|
37
|
+
*/
|
|
38
|
+
const getPrefix = (locale, options = {}) => {
|
|
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 ? "/" : ""}` : "";
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { getPrefix };
|
|
45
|
+
//# sourceMappingURL=getPrefix.mjs.map
|
|
@@ -0,0 +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"}
|
|
@@ -6,8 +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 { getMultilingualUrls } from "./getMultilingualUrls.mjs";
|
|
10
9
|
import { getLocalizedUrl } from "./getLocalizedUrl.mjs";
|
|
10
|
+
import { getMultilingualUrls } from "./getMultilingualUrls.mjs";
|
|
11
|
+
import { getPrefix } from "./getPrefix.mjs";
|
|
11
12
|
import { localeFlatMap, localeMap, localeRecord } from "./localeMapper.mjs";
|
|
12
13
|
|
|
13
|
-
export { getBrowserLocale, getHTMLTextDir, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions };
|
|
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
|
|
3
|
+
import * as _intlayer_types5 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?:
|
|
27
|
+
id?: _intlayer_types5.DictionaryId;
|
|
28
28
|
projectIds?: string[];
|
|
29
|
-
localId?:
|
|
30
|
-
localIds?:
|
|
31
|
-
key:
|
|
29
|
+
localId?: _intlayer_types5.LocalDictionaryId;
|
|
30
|
+
localIds?: _intlayer_types5.LocalDictionaryId[];
|
|
31
|
+
key: _intlayer_types5.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?:
|
|
39
|
+
fill?: _intlayer_types5.Fill;
|
|
40
40
|
filled?: true;
|
|
41
41
|
priority?: number;
|
|
42
42
|
live?: boolean;
|
|
43
|
-
location?:
|
|
43
|
+
location?: _intlayer_types5.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
|
|
3
|
+
import * as _intlayer_types11 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?:
|
|
19
|
+
id?: _intlayer_types11.DictionaryId;
|
|
20
20
|
projectIds?: string[];
|
|
21
|
-
localId?:
|
|
22
|
-
localIds?:
|
|
23
|
-
key:
|
|
21
|
+
localId?: _intlayer_types11.LocalDictionaryId;
|
|
22
|
+
localIds?: _intlayer_types11.LocalDictionaryId[];
|
|
23
|
+
key: _intlayer_types11.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?:
|
|
31
|
+
fill?: _intlayer_types11.Fill;
|
|
32
32
|
filled?: true;
|
|
33
33
|
priority?: number;
|
|
34
34
|
live?: boolean;
|
|
35
|
-
location?:
|
|
35
|
+
location?: _intlayer_types11.DictionaryLocation;
|
|
36
36
|
};
|
|
37
37
|
//#endregion
|
|
38
38
|
export { filterTranslationsOnlyPlugin, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFilterTranslationsOnlyContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getFilterTranslationsOnlyContent.ts"],"sourcesContent":[],"mappings":";;;;;;;cAoCa,uCACH,0BACG,kBACV;;AAHH;;;;;AAuFa,cAAA,gCAkBZ,EAAA,CAAA,UAjBW,WAiBX,EAAA,UAhBW,aAgBX,GAhB2B,eAgB3B,CAAA,CAAA,IAAA,EAdO,CAcP,EAAA,MAAA,EAbS,CAaT,EAAA,SAAA,EAZY,SAYZ,EAAA,QAAA,CAAA,EAXY,aAWZ,EAAA,GADO,oBACP,CAD4B,CAC5B,CAAA;AAjBW,cAmBC,mCAnBD,EAAA,CAAA,UAAA,EAoBE,UApBF,EAAA,MAAA,CAAA,EAqBF,aArBE,EAAA,QAAA,CAAA,EAuBC,aAvBD,EAAA,GAAA;EACA,OAAA,EAAA,GAAA;EAAgB,OAAA,CAAA,EAAA,MAAA;EAEpB,EAAA,CAAA,EAoBkB,
|
|
1
|
+
{"version":3,"file":"getFilterTranslationsOnlyContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getFilterTranslationsOnlyContent.ts"],"sourcesContent":[],"mappings":";;;;;;;cAoCa,uCACH,0BACG,kBACV;;AAHH;;;;;AAuFa,cAAA,gCAkBZ,EAAA,CAAA,UAjBW,WAiBX,EAAA,UAhBW,aAgBX,GAhB2B,eAgB3B,CAAA,CAAA,IAAA,EAdO,CAcP,EAAA,MAAA,EAbS,CAaT,EAAA,SAAA,EAZY,SAYZ,EAAA,QAAA,CAAA,EAXY,aAWZ,EAAA,GADO,oBACP,CAD4B,CAC5B,CAAA;AAjBW,cAmBC,mCAnBD,EAAA,CAAA,UAAA,EAoBE,UApBF,EAAA,MAAA,CAAA,EAqBF,aArBE,EAAA,QAAA,CAAA,EAuBC,aAvBD,EAAA,GAAA;EACA,OAAA,EAAA,GAAA;EAAgB,OAAA,CAAA,EAAA,MAAA;EAEpB,EAAA,CAAA,EAoBkB,iBAAA,CAAA,YApBlB;EACE,UAAA,CAAA,EAAA,MAAA,EAAA;EACG,OAAA,CAAA,qCAAA;EACA,QAAA,CAAA,uCAAA;EAUgB,GAAA,iCAAA;EAArB,KAAA,CAAA,EAAA,MAAA;EAAoB,WAAA,CAAA,EAAA,MAAA;EAGf,QAAA,CAAA,EAAA,MAAA,EAAA;EACC,OAAA,CAAA,EAAA,MAAA;EACJ,QAAA,CAAA,EAAA,MAAA;EAEG,IAAA,CAAA,EAAA,MAAA,EAAA;EAAa,MAAA,CAAA,eAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeProps } from "../interpreter/getContent/plugins.js";
|
|
2
2
|
import "../interpreter/index.js";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _intlayer_types0 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?:
|
|
11
|
+
id?: _intlayer_types0.DictionaryId;
|
|
12
12
|
projectIds?: string[];
|
|
13
|
-
localId?:
|
|
14
|
-
localIds?:
|
|
15
|
-
key:
|
|
13
|
+
localId?: _intlayer_types0.LocalDictionaryId;
|
|
14
|
+
localIds?: _intlayer_types0.LocalDictionaryId[];
|
|
15
|
+
key: _intlayer_types0.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?:
|
|
23
|
+
fill?: _intlayer_types0.Fill;
|
|
24
24
|
filled?: true;
|
|
25
25
|
priority?: number;
|
|
26
26
|
live?: boolean;
|
|
27
|
-
location?:
|
|
27
|
+
location?: _intlayer_types0.DictionaryLocation;
|
|
28
28
|
};
|
|
29
29
|
//#endregion
|
|
30
30
|
export { getFilteredLocalesContent, getFilteredLocalesDictionary };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFilteredLocalesContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getFilteredLocalesContent.ts"],"sourcesContent":[],"mappings":";;;;;;cAsCa,kCACL,sBACG,gBAAgB,4BACd;cAwBA,2CACC,oBACJ,gBAAgB;;;EA7Bb,EAAA,CAAA,EA6B0B,
|
|
1
|
+
{"version":3,"file":"getFilteredLocalesContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getFilteredLocalesContent.ts"],"sourcesContent":[],"mappings":";;;;;;cAsCa,kCACL,sBACG,gBAAgB,4BACd;cAwBA,2CACC,oBACJ,gBAAgB;;;EA7Bb,EAAA,CAAA,EA6B0B,gBAAA,CAAA,YAbtC;EAfO,UAAA,CAAA,EAAA,MAAA,EAAA;EACG,OAAA,CAAA,oCAAA;EAAgB,QAAA,CAAA,sCAAA;EACd,GAAA,gCAAA;EAAS,KAAA,CAAA,EAAA,MAAA;EAwBT,WAAA,CAAA,EAAA,MAAA;EACC,QAAA,CAAA,EAAA,MAAA,EAAA;EACJ,OAAA,CAAA,EAAA,MAAA;EAAgB,QAAA,CAAA,EAAA,MAAA;EAAa,IAAA,CAAA,EAAA,MAAA,EAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types17 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?:
|
|
13
|
+
declare const orderDictionaries: (dictionaries: Dictionary[], configuration?: _intlayer_types17.IntlayerConfig) => Dictionary[];
|
|
14
14
|
//#endregion
|
|
15
15
|
export { orderDictionaries };
|
|
16
16
|
//# sourceMappingURL=orderDictionaries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderDictionaries.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/orderDictionaries.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUA;;;;AAGa,cAHA,iBAGA,EAAA,CAAA,YAAA,EAFG,UAEH,EAAA,EAAA,aAAA,CAAA,EAFa,
|
|
1
|
+
{"version":3,"file":"orderDictionaries.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/orderDictionaries.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUA;;;;AAGa,cAHA,iBAGA,EAAA,CAAA,YAAA,EAFG,UAEH,EAAA,EAAA,aAAA,CAAA,EAFa,iBAAA,CACxB,cACW,EAAA,GAAV,UAAU,EAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ import { getLocaleName } from "./localization/getLocaleName.js";
|
|
|
62
62
|
import { getLocalizedUrl } from "./localization/getLocalizedUrl.js";
|
|
63
63
|
import { getMultilingualUrls } from "./localization/getMultilingualUrls.js";
|
|
64
64
|
import { getPathWithoutLocale } from "./localization/getPathWithoutLocale.js";
|
|
65
|
+
import { getPrefix } from "./localization/getPrefix.js";
|
|
65
66
|
import { localeDetector } from "./localization/localeDetector.js";
|
|
66
67
|
import { localeFlatMap, localeMap, localeRecord } from "./localization/localeMapper.js";
|
|
67
68
|
import { localeResolver } from "./localization/localeResolver.js";
|
|
@@ -71,4 +72,4 @@ import { CachedIntl, createCachedIntl } from "./utils/intl.js";
|
|
|
71
72
|
import { isSameKeyPath } from "./utils/isSameKeyPath.js";
|
|
72
73
|
import { isValidElement } from "./utils/isValidReactElement.js";
|
|
73
74
|
import { parseYaml } from "./utils/parseYaml.js";
|
|
74
|
-
export { CachedIntl, CachedIntl as Intl, ConditionCond, ConditionContent, ConditionContentStates, DeepTransformContent, DotPath, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, FileCond, FileContent, FileContentConstructor, Gender, GenderCond, GenderContent, GenderContentStates, GetNestingResult, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, InsertionContent, InsertionContentConstructor, IsAny, LocaleStorage, LocaleStorageOptions, MarkdownContent, MarkdownContentConstructor, NestedCond, NestedContent, NestedContentState, NodeProps, Plugins, ProcessedStorageAttributes, TranslationCond, TranslationContent, ValidDotPathsFor, buildMaskPlugin, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, condition as cond, conditionPlugin, createCachedIntl, currency, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, file, fileContent, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, getBrowserLocale, getCondition, getContent, getContentNodeByKeyPath, getDefaultNode, getDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getHTMLTextDir, getInsertionValues, getIntlayer, getLocaleFromPath, getLocaleFromStorage, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getReplacedValuesContent, getSplittedContent, getSplittedDictionaryContent, getStorageAttributes, getTranslation, insertion as insert, insertContentInDictionary, insertionPlugin, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, nesting as nest, nestedPlugin, normalizeDictionaries, normalizeDictionary, number, orderDictionaries, parseYaml, percentage, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, setLocaleInStorage, translation as t, translationPlugin, units, updateNodeChildren };
|
|
75
|
+
export { CachedIntl, CachedIntl as Intl, ConditionCond, ConditionContent, ConditionContentStates, DeepTransformContent, DotPath, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, FileCond, FileContent, FileContentConstructor, Gender, GenderCond, GenderContent, GenderContentStates, GetNestingResult, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, InsertionContent, InsertionContentConstructor, IsAny, LocaleStorage, LocaleStorageOptions, MarkdownContent, MarkdownContentConstructor, NestedCond, NestedContent, NestedContentState, NodeProps, Plugins, ProcessedStorageAttributes, TranslationCond, TranslationContent, ValidDotPathsFor, buildMaskPlugin, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, condition as cond, conditionPlugin, createCachedIntl, currency, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, file, fileContent, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, getBrowserLocale, getCondition, getContent, getContentNodeByKeyPath, getDefaultNode, getDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getHTMLTextDir, getInsertionValues, getIntlayer, getLocaleFromPath, getLocaleFromStorage, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPrefix, getReplacedValuesContent, getSplittedContent, getSplittedDictionaryContent, getStorageAttributes, getTranslation, insertion as insert, insertContentInDictionary, insertionPlugin, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, nesting as nest, nestedPlugin, normalizeDictionaries, normalizeDictionary, number, orderDictionaries, parseYaml, percentage, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, setLocaleInStorage, translation as t, translationPlugin, units, updateNodeChildren };
|
|
@@ -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,E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Ce,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"}
|
|
@@ -12,32 +12,37 @@ import { LocalesValues } from "@intlayer/types";
|
|
|
12
12
|
*
|
|
13
13
|
* ```ts
|
|
14
14
|
* // prefix-no-default mode
|
|
15
|
-
* getLocalizedUrl('/about', 'fr', ['en', 'fr'], 'en', 'prefix-no-default');
|
|
15
|
+
* getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' });
|
|
16
16
|
* // Returns '/fr/about' for the French locale
|
|
17
17
|
* // Returns '/about' for the English locale (default)
|
|
18
18
|
*
|
|
19
19
|
* // prefix-all mode
|
|
20
|
-
* getLocalizedUrl('/about', 'en', ['en', 'fr'], 'en', 'prefix-all');
|
|
20
|
+
* getLocalizedUrl('/about', 'en', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' });
|
|
21
21
|
* // Returns '/en/about' for the English locale
|
|
22
22
|
* // Returns '/fr/about' for the French locale
|
|
23
23
|
*
|
|
24
24
|
* // search-params mode
|
|
25
|
-
* getLocalizedUrl('/about', 'fr', ['en', 'fr'], 'en', 'search-params');
|
|
25
|
+
* getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' });
|
|
26
26
|
* // Returns '/about?locale=fr' for the French locale
|
|
27
27
|
*
|
|
28
28
|
* // no-prefix mode
|
|
29
|
-
* getLocalizedUrl('/about', 'fr', ['en', 'fr'], 'en', 'no-prefix');
|
|
29
|
+
* getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' });
|
|
30
30
|
* // Returns '/about' for any locale
|
|
31
31
|
* ```
|
|
32
32
|
*
|
|
33
33
|
* @param url - The original URL string to be processed.
|
|
34
34
|
* @param currentLocale - The current locale.
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
35
|
+
* @param options - Configuration options
|
|
36
|
+
* @param options.locales - Optional array of supported locales. Defaults to configured locales.
|
|
37
|
+
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
38
|
+
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
38
39
|
* @returns The localized URL for the current locale.
|
|
39
40
|
*/
|
|
40
|
-
declare const getLocalizedUrl: (url: string, currentLocale: LocalesValues,
|
|
41
|
+
declare const getLocalizedUrl: (url: string, currentLocale: LocalesValues, options?: {
|
|
42
|
+
locales?: LocalesValues[];
|
|
43
|
+
defaultLocale?: LocalesValues;
|
|
44
|
+
mode?: "prefix-no-default" | "prefix-all" | "no-prefix" | "search-params";
|
|
45
|
+
}) => string;
|
|
41
46
|
//#endregion
|
|
42
47
|
export { getLocalizedUrl };
|
|
43
48
|
//# sourceMappingURL=getLocalizedUrl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocalizedUrl.d.ts","names":[],"sources":["../../../src/localization/getLocalizedUrl.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"getLocalizedUrl.d.ts","names":[],"sources":["../../../src/localization/getLocalizedUrl.ts"],"sourcesContent":[],"mappings":";;;;;;AA0CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,8CAEI;YAEH;kBACM"}
|
|
@@ -13,29 +13,34 @@ import { LocalesValues, StrictModeLocaleMap } from "@intlayer/types";
|
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
15
|
* // prefix-no-default mode
|
|
16
|
-
* getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', 'prefix-no-default')
|
|
16
|
+
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
17
17
|
* // Returns { en: '/dashboard', fr: '/fr/dashboard' }
|
|
18
18
|
*
|
|
19
19
|
* // prefix-all mode
|
|
20
|
-
* getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', 'prefix-all')
|
|
20
|
+
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' })
|
|
21
21
|
* // Returns { en: '/en/dashboard', fr: '/fr/dashboard' }
|
|
22
22
|
*
|
|
23
23
|
* // search-params mode
|
|
24
|
-
* getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', 'search-params')
|
|
24
|
+
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' })
|
|
25
25
|
* // Returns { en: '/dashboard?locale=en', fr: '/dashboard?locale=fr' }
|
|
26
26
|
*
|
|
27
27
|
* // no-prefix mode
|
|
28
|
-
* getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', 'no-prefix')
|
|
28
|
+
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' })
|
|
29
29
|
* // Returns { en: '/dashboard', fr: '/dashboard' }
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
32
32
|
* @param url - The original URL string to be processed.
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
33
|
+
* @param options - Configuration options
|
|
34
|
+
* @param options.locales - Optional array of supported locales. Defaults to configured locales.
|
|
35
|
+
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
36
|
+
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
36
37
|
* @returns An object mapping each locale to its corresponding multilingual URL.
|
|
37
38
|
*/
|
|
38
|
-
declare const getMultilingualUrls: (url: string,
|
|
39
|
+
declare const getMultilingualUrls: (url: string, options?: {
|
|
40
|
+
locales?: LocalesValues[];
|
|
41
|
+
defaultLocale?: LocalesValues;
|
|
42
|
+
mode?: "prefix-no-default" | "prefix-all" | "no-prefix" | "search-params";
|
|
43
|
+
}) => StrictModeLocaleMap<string>;
|
|
39
44
|
//#endregion
|
|
40
45
|
export { getMultilingualUrls };
|
|
41
46
|
//# sourceMappingURL=getMultilingualUrls.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMultilingualUrls.d.ts","names":[],"sources":["../../../src/localization/getMultilingualUrls.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"getMultilingualUrls.d.ts","names":[],"sources":["../../../src/localization/getMultilingualUrls.ts"],"sourcesContent":[],"mappings":";;;;;;AAsCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa;YAGC;kBACM;;MAGjB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { LocalesValues } from "@intlayer/types";
|
|
2
|
+
|
|
3
|
+
//#region src/localization/getPrefix.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Determines the URL prefix for a given locale based on the routing mode configuration.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* // prefix-no-default mode with default locale
|
|
12
|
+
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
13
|
+
* // Returns ''
|
|
14
|
+
*
|
|
15
|
+
* // prefix-no-default mode with non-default locale
|
|
16
|
+
* getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
17
|
+
* // Returns 'en/'
|
|
18
|
+
*
|
|
19
|
+
* // prefix-all mode
|
|
20
|
+
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })
|
|
21
|
+
* // Returns 'en/'
|
|
22
|
+
*
|
|
23
|
+
* // search-params mode
|
|
24
|
+
* getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })
|
|
25
|
+
* // Returns ''
|
|
26
|
+
*
|
|
27
|
+
* // no-prefix mode
|
|
28
|
+
* getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })
|
|
29
|
+
* // Returns ''
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param locale - The locale to check for prefix. If not provided, uses configured default locale.
|
|
33
|
+
* @param options - Configuration options
|
|
34
|
+
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
35
|
+
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
36
|
+
* @param options.addSlash - Whether to add a trailing slash to the prefix. Defaults to true.
|
|
37
|
+
* @returns The prefix string for the given locale (e.g., 'en/', 'fr/') or an empty string.
|
|
38
|
+
*/
|
|
39
|
+
declare const getPrefix: (locale?: LocalesValues, options?: {
|
|
40
|
+
defaultLocale?: LocalesValues;
|
|
41
|
+
mode?: "prefix-no-default" | "prefix-all" | "no-prefix" | "search-params";
|
|
42
|
+
addSlash?: boolean;
|
|
43
|
+
}) => string;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { getPrefix };
|
|
46
|
+
//# sourceMappingURL=getPrefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPrefix.d.ts","names":[],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":[],"mappings":";;;;;;AAqCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,qBACF;kBAES"}
|
|
@@ -6,7 +6,8 @@ import { getLocaleName } from "./getLocaleName.js";
|
|
|
6
6
|
import { getLocalizedUrl } from "./getLocalizedUrl.js";
|
|
7
7
|
import { getMultilingualUrls } from "./getMultilingualUrls.js";
|
|
8
8
|
import { getPathWithoutLocale } from "./getPathWithoutLocale.js";
|
|
9
|
+
import { getPrefix } from "./getPrefix.js";
|
|
9
10
|
import { localeDetector } from "./localeDetector.js";
|
|
10
11
|
import { localeFlatMap, localeMap, localeRecord } from "./localeMapper.js";
|
|
11
12
|
import { localeResolver } from "./localeResolver.js";
|
|
12
|
-
export { getBrowserLocale, getHTMLTextDir, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions };
|
|
13
|
+
export { getBrowserLocale, getHTMLTextDir, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions };
|
|
@@ -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: NodeType.Translation
|
|
26
|
+
nodeType: "translation" | NodeType.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,
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/core",
|
|
3
|
-
"version": "7.0.9-canary.
|
|
3
|
+
"version": "7.0.9-canary.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
|
|
6
6
|
"keywords": [
|
|
@@ -93,9 +93,9 @@
|
|
|
93
93
|
"lint:fix": "biome lint --write .",
|
|
94
94
|
"process-files": "ts-node src/transpiler/processFilesCLI.ts --dir $npm_config_dir --extension $npm_config_extension --no-node-snapshot",
|
|
95
95
|
"prepublish": "cp -f ../../../README.md ./README.md",
|
|
96
|
-
"publish": "bun publish
|
|
97
|
-
"publish:canary": "bun publish --tag canary
|
|
98
|
-
"publish:latest": "bun publish --tag latest
|
|
96
|
+
"publish": "bun publish || true",
|
|
97
|
+
"publish:canary": "bun publish --tag canary || true",
|
|
98
|
+
"publish:latest": "bun publish --tag latest || true",
|
|
99
99
|
"test": "vitest run",
|
|
100
100
|
"test:watch": "vitest",
|
|
101
101
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|