@intlayer/core 7.1.0-canary.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/localization/getLocalizedUrl.cjs +4 -4
- package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
- package/dist/cjs/localization/getPrefix.cjs +19 -14
- package/dist/cjs/localization/getPrefix.cjs.map +1 -1
- package/dist/esm/localization/getLocalizedUrl.mjs +4 -4
- package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
- package/dist/esm/localization/getPrefix.mjs +19 -14
- package/dist/esm/localization/getPrefix.mjs.map +1 -1
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +7 -7
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +1 -1
- 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/dictionaryManipulator/orderDictionaries.d.ts +2 -2
- package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
- package/dist/types/localization/getPrefix.d.ts +31 -12
- package/dist/types/localization/getPrefix.d.ts.map +1 -1
- package/dist/types/localization/index.d.ts +2 -2
- package/package.json +11 -11
|
@@ -58,11 +58,11 @@ const getLocalizedUrl = (url, currentLocale, options = {}) => {
|
|
|
58
58
|
if (isAbsoluteUrl) return `${baseUrl}${pathWithQuery}${parsedUrl.hash}`;
|
|
59
59
|
return `${pathWithQuery}${parsedUrl.hash}`;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
const { prefix } = require_localization_getPrefix.getPrefix(currentLocale, {
|
|
62
62
|
defaultLocale,
|
|
63
|
-
mode
|
|
64
|
-
|
|
65
|
-
}
|
|
63
|
+
mode
|
|
64
|
+
});
|
|
65
|
+
let localizedPath = `/${prefix}${parsedUrl.pathname}`;
|
|
66
66
|
localizedPath = localizedPath.replaceAll(/\/+/g, "/");
|
|
67
67
|
if (localizedPath.length > 1 && localizedPath.endsWith("/")) localizedPath = localizedPath.slice(0, -1);
|
|
68
68
|
if (isAbsoluteUrl) return `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocalizedUrl.cjs","names":["configuration","DefaultValues","getPathWithoutLocale","checkIsURLAbsolute","getPrefix"],"sources":["../../../src/localization/getLocalizedUrl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type { LocalesValues } from '@intlayer/types';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\nimport { getPathWithoutLocale } from './getPathWithoutLocale';\nimport { getPrefix } from './getPrefix';\n\n/**\n * Generate URL by prefixing the given URL with the referenced locale or adding search parameters\n * based on the routing mode. Handles both absolute and relative URLs appropriately.\n *\n * This function gets the locales, default locale, and routing mode from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' });\n * // Returns '/fr/about' for the French locale\n * // Returns '/about' for the English locale (default)\n *\n * // prefix-all mode\n * getLocalizedUrl('/about', 'en', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' });\n * // Returns '/en/about' for the English locale\n * // Returns '/fr/about' for the French locale\n *\n * // search-params mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' });\n * // Returns '/about?locale=fr' for the French locale\n *\n * // no-prefix mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' });\n * // Returns '/about' for any locale\n * ```\n *\n * @param url - The original URL string to be processed.\n * @param currentLocale - The current locale.\n * @param options - Configuration options\n * @param options.locales - Optional array of supported locales. Defaults to configured locales.\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns The localized URL for the current locale.\n */\nexport const getLocalizedUrl = (\n url: string,\n currentLocale: LocalesValues,\n options: {\n locales?: LocalesValues[];\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n } = {}\n): string => {\n const {\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
|
|
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 });\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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AU;AAGnE,QAAO,GAAG,gBAAgB,UAAU,SAAS,UAAU"}
|
|
@@ -11,40 +11,45 @@ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_bui
|
|
|
11
11
|
* ```ts
|
|
12
12
|
* // prefix-no-default mode with default locale
|
|
13
13
|
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
14
|
-
* // Returns ''
|
|
14
|
+
* // Returns { prefix: '', localePrefix: undefined }
|
|
15
15
|
*
|
|
16
16
|
* // prefix-no-default mode with non-default locale
|
|
17
17
|
* getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
18
|
-
* // Returns 'fr
|
|
18
|
+
* // Returns { prefix: '/fr', localePrefix: 'fr' }
|
|
19
19
|
*
|
|
20
20
|
* // prefix-all mode
|
|
21
21
|
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })
|
|
22
|
-
* // Returns 'en
|
|
22
|
+
* // Returns { prefix: '/en', localePrefix: locale }
|
|
23
23
|
*
|
|
24
24
|
* // search-params mode
|
|
25
25
|
* getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })
|
|
26
|
-
* // Returns ''
|
|
26
|
+
* // Returns { prefix: '', localePrefix: undefined }
|
|
27
27
|
*
|
|
28
28
|
* // no-prefix mode
|
|
29
29
|
* getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })
|
|
30
|
-
* // Returns ''
|
|
30
|
+
* // Returns { prefix: '', localePrefix: undefined }
|
|
31
31
|
* ```
|
|
32
32
|
*
|
|
33
33
|
* @param locale - The locale to check for prefix. If not provided, uses configured default locale.
|
|
34
34
|
* @param options - Configuration options
|
|
35
35
|
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
36
36
|
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
37
|
-
* @
|
|
38
|
-
* @returns The prefix string for the given locale (e.g., 'en/', 'fr/') or an empty string.
|
|
37
|
+
* @returns An object containing pathPrefix, prefix, and localePrefix for the given locale.
|
|
39
38
|
*/
|
|
40
39
|
const getPrefix = (locale, options = {}) => {
|
|
41
|
-
const { defaultLocale = __intlayer_config_built.default?.internationalization?.defaultLocale, mode = __intlayer_config_built.default?.routing?.mode
|
|
42
|
-
if (!locale) return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
const { defaultLocale = __intlayer_config_built.default?.internationalization?.defaultLocale, mode = __intlayer_config_built.default?.routing?.mode } = options;
|
|
41
|
+
if (!locale) return {
|
|
42
|
+
prefix: "",
|
|
43
|
+
localePrefix: void 0
|
|
44
|
+
};
|
|
45
|
+
if (mode === "prefix-all" || mode === "prefix-no-default" && defaultLocale !== locale) return {
|
|
46
|
+
prefix: `${locale}/`,
|
|
47
|
+
localePrefix: locale
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
prefix: "",
|
|
51
|
+
localePrefix: void 0
|
|
52
|
+
};
|
|
48
53
|
};
|
|
49
54
|
|
|
50
55
|
//#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 'fr
|
|
1
|
+
{"version":3,"file":"getPrefix.cjs","names":["configuration"],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale, LocalesValues } from '@intlayer/types';\n\nexport type GetPrefixOptions = {\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n};\n\nexport type GetPrefixResult = {\n /**\n * The complete base URL path with leading and trailing slashes.\n *\n * @example\n * // https://example.com/fr/about -> '/fr'\n * // https://example.com/about -> ''\n */\n prefix: string;\n /**\n * The locale identifier without slashes.\n *\n * @example\n * // https://example.com/fr/about -> 'fr'\n * // https://example.com/about -> undefined\n */\n localePrefix: Locale | undefined;\n};\n\n/**\n * Determines the URL prefix for a given locale based on the routing mode configuration.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode with default locale\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { prefix: '', localePrefix: undefined }\n *\n * // prefix-no-default mode with non-default locale\n * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { prefix: '/fr', localePrefix: 'fr' }\n *\n * // prefix-all mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns { prefix: '/en', localePrefix: locale }\n *\n * // search-params mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })\n * // Returns { prefix: '', localePrefix: undefined }\n *\n * // no-prefix mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns { prefix: '', localePrefix: undefined }\n * ```\n *\n * @param locale - The locale to check for prefix. If not provided, uses configured default locale.\n * @param options - Configuration options\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns An object containing pathPrefix, prefix, and localePrefix for the given locale.\n */\nexport const getPrefix = (\n locale: LocalesValues,\n options: {\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n } = {}\n): GetPrefixResult => {\n const {\n defaultLocale = configuration?.internationalization?.defaultLocale,\n mode = configuration?.routing?.mode,\n } = options;\n\n if (!locale) {\n return {\n prefix: '',\n localePrefix: undefined,\n };\n }\n\n // Handle prefix-based modes (prefix-all or prefix-no-default)\n const shouldPrefix =\n mode === 'prefix-all' ||\n (mode === 'prefix-no-default' && defaultLocale !== locale);\n\n if (shouldPrefix) {\n return {\n prefix: `${locale}/`,\n localePrefix: locale as Locale,\n };\n }\n\n return {\n prefix: '',\n localePrefix: undefined,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAa,aACX,QACA,UAGI,EAAE,KACc;CACpB,MAAM,EACJ,gBAAgBA,iCAAe,sBAAsB,eACrD,OAAOA,iCAAe,SAAS,SAC7B;AAEJ,KAAI,CAAC,OACH,QAAO;EACL,QAAQ;EACR,cAAc;EACf;AAQH,KAHE,SAAS,gBACR,SAAS,uBAAuB,kBAAkB,OAGnD,QAAO;EACL,QAAQ,GAAG,OAAO;EAClB,cAAc;EACf;AAGH,QAAO;EACL,QAAQ;EACR,cAAc;EACf"}
|
|
@@ -56,11 +56,11 @@ const getLocalizedUrl = (url, currentLocale, options = {}) => {
|
|
|
56
56
|
if (isAbsoluteUrl) return `${baseUrl}${pathWithQuery}${parsedUrl.hash}`;
|
|
57
57
|
return `${pathWithQuery}${parsedUrl.hash}`;
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
const { prefix } = getPrefix(currentLocale, {
|
|
60
60
|
defaultLocale,
|
|
61
|
-
mode
|
|
62
|
-
|
|
63
|
-
}
|
|
61
|
+
mode
|
|
62
|
+
});
|
|
63
|
+
let localizedPath = `/${prefix}${parsedUrl.pathname}`;
|
|
64
64
|
localizedPath = localizedPath.replaceAll(/\/+/g, "/");
|
|
65
65
|
if (localizedPath.length > 1 && localizedPath.endsWith("/")) localizedPath = localizedPath.slice(0, -1);
|
|
66
66
|
if (isAbsoluteUrl) return `${baseUrl}${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';\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
|
|
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 });\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;;CAGtC,MAAM,EAAE,WAAW,UAAU,eAAe;EAC1C;EACA;EACD,CAAC;CAGF,IAAI,gBAAgB,IAAI,SAAS,UAAU;AAG3C,iBAAgB,cAAc,WAAW,QAAQ,IAAI;AAGrD,KAAI,cAAc,SAAS,KAAK,cAAc,SAAS,IAAI,CACzD,iBAAgB,cAAc,MAAM,GAAG,GAAG;AAI5C,KAAI,cACF,QAAO,GAAG,UAAU,gBAAgB,UAAU,SAAS,UAAU;AAGnE,QAAO,GAAG,gBAAgB,UAAU,SAAS,UAAU"}
|
|
@@ -9,40 +9,45 @@ import configuration from "@intlayer/config/built";
|
|
|
9
9
|
* ```ts
|
|
10
10
|
* // prefix-no-default mode with default locale
|
|
11
11
|
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
12
|
-
* // Returns ''
|
|
12
|
+
* // Returns { prefix: '', localePrefix: undefined }
|
|
13
13
|
*
|
|
14
14
|
* // prefix-no-default mode with non-default locale
|
|
15
15
|
* getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
16
|
-
* // Returns 'fr
|
|
16
|
+
* // Returns { prefix: '/fr', localePrefix: 'fr' }
|
|
17
17
|
*
|
|
18
18
|
* // prefix-all mode
|
|
19
19
|
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })
|
|
20
|
-
* // Returns 'en
|
|
20
|
+
* // Returns { prefix: '/en', localePrefix: locale }
|
|
21
21
|
*
|
|
22
22
|
* // search-params mode
|
|
23
23
|
* getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })
|
|
24
|
-
* // Returns ''
|
|
24
|
+
* // Returns { prefix: '', localePrefix: undefined }
|
|
25
25
|
*
|
|
26
26
|
* // no-prefix mode
|
|
27
27
|
* getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })
|
|
28
|
-
* // Returns ''
|
|
28
|
+
* // Returns { prefix: '', localePrefix: undefined }
|
|
29
29
|
* ```
|
|
30
30
|
*
|
|
31
31
|
* @param locale - The locale to check for prefix. If not provided, uses configured default locale.
|
|
32
32
|
* @param options - Configuration options
|
|
33
33
|
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
34
34
|
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
35
|
-
* @
|
|
36
|
-
* @returns The prefix string for the given locale (e.g., 'en/', 'fr/') or an empty string.
|
|
35
|
+
* @returns An object containing pathPrefix, prefix, and localePrefix for the given locale.
|
|
37
36
|
*/
|
|
38
37
|
const getPrefix = (locale, options = {}) => {
|
|
39
|
-
const { defaultLocale = configuration?.internationalization?.defaultLocale, mode = configuration?.routing?.mode
|
|
40
|
-
if (!locale) return
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
const { defaultLocale = configuration?.internationalization?.defaultLocale, mode = configuration?.routing?.mode } = options;
|
|
39
|
+
if (!locale) return {
|
|
40
|
+
prefix: "",
|
|
41
|
+
localePrefix: void 0
|
|
42
|
+
};
|
|
43
|
+
if (mode === "prefix-all" || mode === "prefix-no-default" && defaultLocale !== locale) return {
|
|
44
|
+
prefix: `${locale}/`,
|
|
45
|
+
localePrefix: locale
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
prefix: "",
|
|
49
|
+
localePrefix: void 0
|
|
50
|
+
};
|
|
46
51
|
};
|
|
47
52
|
|
|
48
53
|
//#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 'fr
|
|
1
|
+
{"version":3,"file":"getPrefix.mjs","names":[],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale, LocalesValues } from '@intlayer/types';\n\nexport type GetPrefixOptions = {\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n};\n\nexport type GetPrefixResult = {\n /**\n * The complete base URL path with leading and trailing slashes.\n *\n * @example\n * // https://example.com/fr/about -> '/fr'\n * // https://example.com/about -> ''\n */\n prefix: string;\n /**\n * The locale identifier without slashes.\n *\n * @example\n * // https://example.com/fr/about -> 'fr'\n * // https://example.com/about -> undefined\n */\n localePrefix: Locale | undefined;\n};\n\n/**\n * Determines the URL prefix for a given locale based on the routing mode configuration.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode with default locale\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { prefix: '', localePrefix: undefined }\n *\n * // prefix-no-default mode with non-default locale\n * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { prefix: '/fr', localePrefix: 'fr' }\n *\n * // prefix-all mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns { prefix: '/en', localePrefix: locale }\n *\n * // search-params mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })\n * // Returns { prefix: '', localePrefix: undefined }\n *\n * // no-prefix mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns { prefix: '', localePrefix: undefined }\n * ```\n *\n * @param locale - The locale to check for prefix. If not provided, uses configured default locale.\n * @param options - Configuration options\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns An object containing pathPrefix, prefix, and localePrefix for the given locale.\n */\nexport const getPrefix = (\n locale: LocalesValues,\n options: {\n defaultLocale?: LocalesValues;\n mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';\n } = {}\n): GetPrefixResult => {\n const {\n defaultLocale = configuration?.internationalization?.defaultLocale,\n mode = configuration?.routing?.mode,\n } = options;\n\n if (!locale) {\n return {\n prefix: '',\n localePrefix: undefined,\n };\n }\n\n // Handle prefix-based modes (prefix-all or prefix-no-default)\n const shouldPrefix =\n mode === 'prefix-all' ||\n (mode === 'prefix-no-default' && defaultLocale !== locale);\n\n if (shouldPrefix) {\n return {\n prefix: `${locale}/`,\n localePrefix: locale as Locale,\n };\n }\n\n return {\n prefix: '',\n localePrefix: undefined,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAa,aACX,QACA,UAGI,EAAE,KACc;CACpB,MAAM,EACJ,gBAAgB,eAAe,sBAAsB,eACrD,OAAO,eAAe,SAAS,SAC7B;AAEJ,KAAI,CAAC,OACH,QAAO;EACL,QAAQ;EACR,cAAc;EACf;AAQH,KAHE,SAAS,gBACR,SAAS,uBAAuB,kBAAkB,OAGnD,QAAO;EACL,QAAQ,GAAG,OAAO;EAClB,cAAc;EACf;AAGH,QAAO;EACL,QAAQ;EACR,cAAc;EACf"}
|
|
@@ -1,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_types12 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_types12.DictionaryId;
|
|
28
28
|
projectIds?: string[];
|
|
29
|
-
localId?:
|
|
30
|
-
localIds?:
|
|
31
|
-
key:
|
|
29
|
+
localId?: _intlayer_types12.LocalDictionaryId;
|
|
30
|
+
localIds?: _intlayer_types12.LocalDictionaryId[];
|
|
31
|
+
key: _intlayer_types12.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_types12.Fill;
|
|
40
40
|
filled?: true;
|
|
41
41
|
priority?: number;
|
|
42
42
|
live?: boolean;
|
|
43
|
-
location?:
|
|
43
|
+
location?: _intlayer_types12.DictionaryLocation;
|
|
44
44
|
};
|
|
45
45
|
//#endregion
|
|
46
46
|
export { filterMissingTranslationsOnlyPlugin, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFilterMissingTranslationsContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getFilterMissingTranslationsContent.ts"],"sourcesContent":[],"mappings":";;;;;;;cAmMa,qDACI,kBACd;;AAFH;AA8LA;;;;;;;;AA0BA;;;;cA1Ba,gDACD,uBACA,gBAAgB,uBAEpB,kBACS,cACJ;cAoBA,qDACC,2BACG;;;OAAa,
|
|
1
|
+
{"version":3,"file":"getFilterMissingTranslationsContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getFilterMissingTranslationsContent.ts"],"sourcesContent":[],"mappings":";;;;;;;cAmMa,qDACI,kBACd;;AAFH;AA8LA;;;;;;;;AA0BA;;;;cA1Ba,gDACD,uBACA,gBAAgB,uBAEpB,kBACS,cACJ;cAoBA,qDACC,2BACG;;;OAAa,iBAAA,CAAA"}
|
|
@@ -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_types0 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_types0.DictionaryId;
|
|
20
20
|
projectIds?: string[];
|
|
21
|
-
localId?:
|
|
22
|
-
localIds?:
|
|
23
|
-
key:
|
|
21
|
+
localId?: _intlayer_types0.LocalDictionaryId;
|
|
22
|
+
localIds?: _intlayer_types0.LocalDictionaryId[];
|
|
23
|
+
key: _intlayer_types0.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_types0.Fill;
|
|
32
32
|
filled?: true;
|
|
33
33
|
priority?: number;
|
|
34
34
|
live?: boolean;
|
|
35
|
-
location?:
|
|
35
|
+
location?: _intlayer_types0.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,gBAAA,CAAA,YApBlB;EACE,UAAA,CAAA,EAAA,MAAA,EAAA;EACG,OAAA,CAAA,oCAAA;EACA,QAAA,CAAA,sCAAA;EAUgB,GAAA,gCAAA;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_types6 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_types6.DictionaryId;
|
|
12
12
|
projectIds?: string[];
|
|
13
|
-
localId?:
|
|
14
|
-
localIds?:
|
|
15
|
-
key:
|
|
13
|
+
localId?: _intlayer_types6.LocalDictionaryId;
|
|
14
|
+
localIds?: _intlayer_types6.LocalDictionaryId[];
|
|
15
|
+
key: _intlayer_types6.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_types6.Fill;
|
|
24
24
|
filled?: true;
|
|
25
25
|
priority?: number;
|
|
26
26
|
live?: boolean;
|
|
27
|
-
location?:
|
|
27
|
+
location?: _intlayer_types6.DictionaryLocation;
|
|
28
28
|
};
|
|
29
29
|
//#endregion
|
|
30
30
|
export { getFilteredLocalesContent, getFilteredLocalesDictionary };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types5 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_types5.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,gBAAA,CACxB,cACW,EAAA,GAAV,UAAU,EAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -62,7 +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
|
+
import { GetPrefixOptions, GetPrefixResult, getPrefix } from "./localization/getPrefix.js";
|
|
66
66
|
import { localeDetector } from "./localization/localeDetector.js";
|
|
67
67
|
import { localeFlatMap, localeMap, localeRecord } from "./localization/localeMapper.js";
|
|
68
68
|
import { localeResolver } from "./localization/localeResolver.js";
|
|
@@ -72,4 +72,4 @@ import { CachedIntl, createCachedIntl } from "./utils/intl.js";
|
|
|
72
72
|
import { isSameKeyPath } from "./utils/isSameKeyPath.js";
|
|
73
73
|
import { isValidElement } from "./utils/isValidReactElement.js";
|
|
74
74
|
import { parseYaml } from "./utils/parseYaml.js";
|
|
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 };
|
|
75
|
+
export { CachedIntl, CachedIntl as Intl, ConditionCond, ConditionContent, ConditionContentStates, DeepTransformContent, DotPath, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, FileCond, FileContent, FileContentConstructor, Gender, GenderCond, GenderContent, GenderContentStates, GetNestingResult, GetPrefixOptions, GetPrefixResult, 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,EAAA,CAAA,CAAA,GAMqC,CANrC,SAAA;EAMU,QAAA,EACA,QADe,GAAA,MAAA;EAAY,CAEpC,QAAA,CAAS,WAAA,CAF2B,EAAA,MAAA;CAC3B,GAA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B,CAAA,GA0C/B,kBA1C+B,CA0CZ,CA1CY,EA0CT,CA1CS,EA0CN,CA1CM,CAAA,CAAA,MA0CG,kBA1CH,CA0CsB,CA1CtB,EA0CyB,CA1CzB,EA0C4B,CA1C5B,CAAA,CAAA"}
|
|
@@ -1,7 +1,28 @@
|
|
|
1
|
-
import { LocalesValues } from "@intlayer/types";
|
|
1
|
+
import { Locale, LocalesValues } from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/localization/getPrefix.d.ts
|
|
4
|
-
|
|
4
|
+
type GetPrefixOptions = {
|
|
5
|
+
defaultLocale?: LocalesValues;
|
|
6
|
+
mode?: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params';
|
|
7
|
+
};
|
|
8
|
+
type GetPrefixResult = {
|
|
9
|
+
/**
|
|
10
|
+
* The complete base URL path with leading and trailing slashes.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // https://example.com/fr/about -> '/fr'
|
|
14
|
+
* // https://example.com/about -> ''
|
|
15
|
+
*/
|
|
16
|
+
prefix: string;
|
|
17
|
+
/**
|
|
18
|
+
* The locale identifier without slashes.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // https://example.com/fr/about -> 'fr'
|
|
22
|
+
* // https://example.com/about -> undefined
|
|
23
|
+
*/
|
|
24
|
+
localePrefix: Locale | undefined;
|
|
25
|
+
};
|
|
5
26
|
/**
|
|
6
27
|
* Determines the URL prefix for a given locale based on the routing mode configuration.
|
|
7
28
|
*
|
|
@@ -10,37 +31,35 @@ import { LocalesValues } from "@intlayer/types";
|
|
|
10
31
|
* ```ts
|
|
11
32
|
* // prefix-no-default mode with default locale
|
|
12
33
|
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
13
|
-
* // Returns ''
|
|
34
|
+
* // Returns { prefix: '', localePrefix: undefined }
|
|
14
35
|
*
|
|
15
36
|
* // prefix-no-default mode with non-default locale
|
|
16
37
|
* getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
17
|
-
* // Returns 'fr
|
|
38
|
+
* // Returns { prefix: '/fr', localePrefix: 'fr' }
|
|
18
39
|
*
|
|
19
40
|
* // prefix-all mode
|
|
20
41
|
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })
|
|
21
|
-
* // Returns 'en
|
|
42
|
+
* // Returns { prefix: '/en', localePrefix: locale }
|
|
22
43
|
*
|
|
23
44
|
* // search-params mode
|
|
24
45
|
* getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })
|
|
25
|
-
* // Returns ''
|
|
46
|
+
* // Returns { prefix: '', localePrefix: undefined }
|
|
26
47
|
*
|
|
27
48
|
* // no-prefix mode
|
|
28
49
|
* getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })
|
|
29
|
-
* // Returns ''
|
|
50
|
+
* // Returns { prefix: '', localePrefix: undefined }
|
|
30
51
|
* ```
|
|
31
52
|
*
|
|
32
53
|
* @param locale - The locale to check for prefix. If not provided, uses configured default locale.
|
|
33
54
|
* @param options - Configuration options
|
|
34
55
|
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
35
56
|
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
36
|
-
* @
|
|
37
|
-
* @returns The prefix string for the given locale (e.g., 'en/', 'fr/') or an empty string.
|
|
57
|
+
* @returns An object containing pathPrefix, prefix, and localePrefix for the given locale.
|
|
38
58
|
*/
|
|
39
59
|
declare const getPrefix: (locale: LocalesValues, options?: {
|
|
40
60
|
defaultLocale?: LocalesValues;
|
|
41
61
|
mode?: "prefix-no-default" | "prefix-all" | "no-prefix" | "search-params";
|
|
42
|
-
|
|
43
|
-
}) => string;
|
|
62
|
+
}) => GetPrefixResult;
|
|
44
63
|
//#endregion
|
|
45
|
-
export { getPrefix };
|
|
64
|
+
export { GetPrefixOptions, GetPrefixResult, getPrefix };
|
|
46
65
|
//# sourceMappingURL=getPrefix.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrefix.d.ts","names":[],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPrefix.d.ts","names":[],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":[],"mappings":";;;KAGY,gBAAA;kBACM;EADN,IAAA,CAAA,EAAA,mBAAgB,GAAA,YACV,GAAA,WAAa,GAAA,eAAA;AAI/B,CAAA;AAoDa,KApDD,eAAA,GAuFX;EAlCS;;;;;;;;;;;;;;;gBArCM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoCH,oBACH;kBAEU;;MAGjB"}
|
|
@@ -6,8 +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
|
+
import { GetPrefixOptions, GetPrefixResult, getPrefix } from "./getPrefix.js";
|
|
10
10
|
import { localeDetector } from "./localeDetector.js";
|
|
11
11
|
import { localeFlatMap, localeMap, localeRecord } from "./localeMapper.js";
|
|
12
12
|
import { localeResolver } from "./localeResolver.js";
|
|
13
|
-
export { getBrowserLocale, getHTMLTextDir, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions };
|
|
13
|
+
export { type GetPrefixOptions, type GetPrefixResult, getBrowserLocale, getHTMLTextDir, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/core",
|
|
3
|
-
"version": "7.1.0
|
|
3
|
+
"version": "7.1.0",
|
|
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
|
|
105
|
-
"@intlayer/config": "7.1.0
|
|
106
|
-
"@intlayer/dictionaries-entry": "7.1.0
|
|
107
|
-
"@intlayer/types": "7.1.0
|
|
108
|
-
"@intlayer/unmerged-dictionaries-entry": "7.1.0
|
|
104
|
+
"@intlayer/api": "7.1.0",
|
|
105
|
+
"@intlayer/config": "7.1.0",
|
|
106
|
+
"@intlayer/dictionaries-entry": "7.1.0",
|
|
107
|
+
"@intlayer/types": "7.1.0",
|
|
108
|
+
"@intlayer/unmerged-dictionaries-entry": "7.1.0",
|
|
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
|
|
123
|
-
"@intlayer/config": "7.1.0
|
|
124
|
-
"@intlayer/dictionaries-entry": "7.1.0
|
|
125
|
-
"@intlayer/types": "7.1.0
|
|
126
|
-
"@intlayer/unmerged-dictionaries-entry": "7.1.0
|
|
122
|
+
"@intlayer/api": "7.1.0",
|
|
123
|
+
"@intlayer/config": "7.1.0",
|
|
124
|
+
"@intlayer/dictionaries-entry": "7.1.0",
|
|
125
|
+
"@intlayer/types": "7.1.0",
|
|
126
|
+
"@intlayer/unmerged-dictionaries-entry": "7.1.0"
|
|
127
127
|
},
|
|
128
128
|
"engines": {
|
|
129
129
|
"node": ">=14.18"
|