@intlayer/core 7.1.9 → 7.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cjs/_virtual/rolldown_runtime.cjs +10 -6
- package/dist/cjs/localization/localeDetector.cjs +93 -74
- package/dist/cjs/localization/localeDetector.cjs.map +1 -1
- package/dist/esm/localization/localeDetector.mjs +93 -74
- package/dist/esm/localization/localeDetector.mjs.map +1 -1
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +7 -7
- package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +7 -7
- 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/interpreter/getContent/plugins.d.ts.map +1 -1
- package/dist/types/localization/localeDetector.d.ts +4 -3
- package/dist/types/localization/localeDetector.d.ts.map +1 -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 +9 -9
package/README.md
CHANGED
|
@@ -188,6 +188,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
|
|
|
188
188
|
<li><a href="https://intlayer.org/doc/environment/react-native-and-expo" rel=''>React Native</a></li>
|
|
189
189
|
<li><a href="https://intlayer.org/doc/environment/lynx-and-react" rel=''>Lynx + React</a></li>
|
|
190
190
|
<li><a href="https://intlayer.org/doc/environment/vite-and-svelte" rel=''>Vite + Svelte</a></li>
|
|
191
|
+
<li><a href="https://intlayer.org/doc/environment/sveltekit" rel=''>SvelteKit</a></li>
|
|
191
192
|
<li><a href="https://intlayer.org/doc/environment/vite-and-preact" rel=''>Vite + Preact</a></li>
|
|
192
193
|
<li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
|
|
193
194
|
<li><a href="https://intlayer.org/doc/environment/vite-and-nuxt" rel=''>Vite + Nuxt</a></li>
|
|
@@ -6,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
return to;
|
|
17
21
|
};
|
|
@@ -2,110 +2,129 @@ const require_localization_localeResolver = require('./localeResolver.cjs');
|
|
|
2
2
|
|
|
3
3
|
//#region src/localization/localeDetector.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Constants
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
7
|
+
const LANGUAGE_FORMAT_REGULAR_EXPRESSION = /^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;
|
|
8
|
+
const DEFAULT_QUALITY_SCORE = 1;
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
+
* Enumeration for specificity weights.
|
|
11
|
+
* Higher values indicate a more precise match.
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return accepts;
|
|
19
|
-
};
|
|
13
|
+
var SpecificityWeight = /* @__PURE__ */ function(SpecificityWeight$1) {
|
|
14
|
+
SpecificityWeight$1[SpecificityWeight$1["None"] = 0] = "None";
|
|
15
|
+
SpecificityWeight$1[SpecificityWeight$1["Broad"] = 1] = "Broad";
|
|
16
|
+
SpecificityWeight$1[SpecificityWeight$1["Prefix"] = 2] = "Prefix";
|
|
17
|
+
SpecificityWeight$1[SpecificityWeight$1["Exact"] = 4] = "Exact";
|
|
18
|
+
return SpecificityWeight$1;
|
|
19
|
+
}(SpecificityWeight || {});
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Parses a single language tag string from the Accept-Language header.
|
|
22
|
+
* Example input: "en-US;q=0.8"
|
|
22
23
|
*/
|
|
23
|
-
const
|
|
24
|
-
const match =
|
|
24
|
+
const parseLanguageTag = (tagString, index) => {
|
|
25
|
+
const match = LANGUAGE_FORMAT_REGULAR_EXPRESSION.exec(tagString);
|
|
25
26
|
if (!match) return null;
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
32
|
-
const
|
|
33
|
-
for (
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
27
|
+
const languageCode = match[1];
|
|
28
|
+
const regionCode = match[2];
|
|
29
|
+
const parameters = match[3];
|
|
30
|
+
const fullLocale = regionCode ? `${languageCode}-${regionCode}` : languageCode;
|
|
31
|
+
let qualityScore = DEFAULT_QUALITY_SCORE;
|
|
32
|
+
if (parameters) {
|
|
33
|
+
const parameterList = parameters.split(";");
|
|
34
|
+
for (const parameter of parameterList) {
|
|
35
|
+
const [key, value] = parameter.split("=");
|
|
36
|
+
if (key === "q") qualityScore = parseFloat(value);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
return {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
languageCode,
|
|
41
|
+
regionCode,
|
|
42
|
+
qualityScore,
|
|
43
|
+
originalIndex: index,
|
|
44
|
+
fullLocale
|
|
44
45
|
};
|
|
45
46
|
};
|
|
46
47
|
/**
|
|
47
|
-
*
|
|
48
|
+
* Parses the entire Accept-Language header string into a list of preferences.
|
|
48
49
|
*/
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
for (let i = 0; i < accepted.length; i++) {
|
|
57
|
-
const spec = specify(language, accepted[i], index);
|
|
58
|
-
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) priority = spec;
|
|
50
|
+
const parseAcceptLanguageHeader = (headerValue) => {
|
|
51
|
+
const rawTags = headerValue.split(",");
|
|
52
|
+
const preferences = [];
|
|
53
|
+
for (let index = 0; index < rawTags.length; index++) {
|
|
54
|
+
const parsedLanguage = parseLanguageTag(rawTags[index].trim(), index);
|
|
55
|
+
if (parsedLanguage) preferences.push(parsedLanguage);
|
|
59
56
|
}
|
|
60
|
-
return
|
|
57
|
+
return preferences;
|
|
61
58
|
};
|
|
62
59
|
/**
|
|
63
|
-
*
|
|
60
|
+
* Calculates the specificity of a match between a provided language and a requested preference.
|
|
64
61
|
*/
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
if (!
|
|
68
|
-
let
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
const calculateMatchSpecificity = (providedLanguage, preference, providedIndex) => {
|
|
63
|
+
const parsedProvided = parseLanguageTag(providedLanguage, providedIndex);
|
|
64
|
+
if (!parsedProvided) return null;
|
|
65
|
+
let specificityScore = SpecificityWeight.None;
|
|
66
|
+
const preferenceFullLower = preference.fullLocale.toLowerCase();
|
|
67
|
+
const preferencePrefixLower = preference.languageCode.toLowerCase();
|
|
68
|
+
const providedFullLower = parsedProvided.fullLocale.toLowerCase();
|
|
69
|
+
const providedPrefixLower = parsedProvided.languageCode.toLowerCase();
|
|
70
|
+
if (preferenceFullLower === providedFullLower) specificityScore |= SpecificityWeight.Exact;
|
|
71
|
+
else if (preferencePrefixLower === providedFullLower) specificityScore |= SpecificityWeight.Prefix;
|
|
72
|
+
else if (preferenceFullLower === providedPrefixLower) specificityScore |= SpecificityWeight.Broad;
|
|
73
|
+
else if (preference.fullLocale !== "*") return null;
|
|
73
74
|
return {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
providedIndex,
|
|
76
|
+
headerIndex: preference.originalIndex,
|
|
77
|
+
qualityScore: preference.qualityScore,
|
|
78
|
+
specificityScore
|
|
78
79
|
};
|
|
79
80
|
};
|
|
80
81
|
/**
|
|
81
|
-
*
|
|
82
|
+
* Determines the best match for a specific available language against the list of user accepted languages.
|
|
82
83
|
*/
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
const getBestMatchForLanguage = (providedLanguage, acceptedPreferences, providedIndex) => {
|
|
85
|
+
let bestMatch = {
|
|
86
|
+
headerIndex: -1,
|
|
87
|
+
qualityScore: 0,
|
|
88
|
+
specificityScore: 0,
|
|
89
|
+
providedIndex
|
|
90
|
+
};
|
|
91
|
+
for (const preference of acceptedPreferences) {
|
|
92
|
+
const matchSpec = calculateMatchSpecificity(providedLanguage, preference, providedIndex);
|
|
93
|
+
if (matchSpec) {
|
|
94
|
+
if ((bestMatch.specificityScore - matchSpec.specificityScore || bestMatch.qualityScore - matchSpec.qualityScore || bestMatch.headerIndex - matchSpec.headerIndex) < 0) bestMatch = matchSpec;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return bestMatch;
|
|
88
98
|
};
|
|
89
99
|
/**
|
|
90
|
-
*
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*
|
|
100
|
+
* Comparator function to sort language matches.
|
|
101
|
+
* Sorting order:
|
|
102
|
+
* 1. Quality Score (Descending)
|
|
103
|
+
* 2. Specificity Score (Descending)
|
|
104
|
+
* 3. Order in Header (Ascending - lower index is better)
|
|
105
|
+
* 4. Order in Provided List (Ascending)
|
|
95
106
|
*/
|
|
96
|
-
const
|
|
107
|
+
const compareMatchResults = (a, b) => {
|
|
108
|
+
return b.qualityScore - a.qualityScore || b.specificityScore - a.specificityScore || a.headerIndex - b.headerIndex || a.providedIndex - b.providedIndex || 0;
|
|
109
|
+
};
|
|
97
110
|
/**
|
|
98
|
-
*
|
|
111
|
+
* Derives the list of preferred languages based on the Accept-Language header
|
|
112
|
+
* and an optional list of available languages.
|
|
99
113
|
*/
|
|
100
|
-
const
|
|
114
|
+
const getPreferredLanguages = (acceptHeader, availableLanguages) => {
|
|
115
|
+
const acceptedPreferences = parseAcceptLanguageHeader(acceptHeader === void 0 ? "*" : acceptHeader || "");
|
|
116
|
+
if (!availableLanguages) return acceptedPreferences.filter((preference) => preference.qualityScore > 0).sort((a, b) => b.qualityScore - a.qualityScore).map((preference) => preference.fullLocale);
|
|
117
|
+
return availableLanguages.map((language, index) => getBestMatchForLanguage(language, acceptedPreferences, index)).filter((result) => result.qualityScore > 0).sort(compareMatchResults).map((result) => availableLanguages[result.providedIndex]);
|
|
118
|
+
};
|
|
101
119
|
/**
|
|
102
|
-
* Detects the locale from the request headers
|
|
120
|
+
* Detects the locale from the request headers.
|
|
103
121
|
*
|
|
104
|
-
* Headers are provided by the browser and can be used to determine the user's preferred language
|
|
122
|
+
* Headers are provided by the browser/client and can be used to determine the user's preferred language.
|
|
123
|
+
* This function intersects the user's `Accept-Language` header with the application's available locales.
|
|
105
124
|
*/
|
|
106
|
-
const localeDetector = (headers,
|
|
107
|
-
const
|
|
108
|
-
return require_localization_localeResolver.localeResolver(
|
|
125
|
+
const localeDetector = (headers, availableLocales, defaultLocale) => {
|
|
126
|
+
const acceptLanguageHeader = headers["accept-language"];
|
|
127
|
+
return require_localization_localeResolver.localeResolver(getPreferredLanguages(acceptLanguageHeader, availableLocales), availableLocales, defaultLocale);
|
|
109
128
|
};
|
|
110
129
|
|
|
111
130
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeDetector.cjs","names":["
|
|
1
|
+
{"version":3,"file":"localeDetector.cjs","names":["preferences: LanguagePreference[]","bestMatch: MatchResult","localeResolver"],"sources":["../../../src/localization/localeDetector.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types';\nimport { localeResolver } from './localeResolver';\n\n/**\n * Constants\n */\nconst LANGUAGE_FORMAT_REGULAR_EXPRESSION =\n /^\\s*([^\\s\\-;]+)(?:-([^\\s;]+))?\\s*(?:;(.*))?$/;\nconst DEFAULT_QUALITY_SCORE = 1;\n\n/**\n * Enumeration for specificity weights.\n * Higher values indicate a more precise match.\n */\nenum SpecificityWeight {\n None = 0,\n Broad = 1, // Matches prefix (e.g., 'en' matches 'en-US')\n Prefix = 2, // Matches prefix in reverse (e.g., 'en-US' matches 'en')\n Exact = 4, // Matches exact string (e.g., 'en-US' matches 'en-US')\n}\n\n/**\n * Represents a parsed language tag from the header.\n */\ntype LanguagePreference = {\n languageCode: string;\n regionCode?: string;\n fullLocale: string;\n qualityScore: number;\n originalIndex: number;\n};\n\n/**\n * Represents the result of matching a requested language against an available language.\n */\ntype MatchResult = {\n providedIndex: number;\n headerIndex: number;\n qualityScore: number;\n specificityScore: number;\n};\n\n/**\n * Parses a single language tag string from the Accept-Language header.\n * Example input: \"en-US;q=0.8\"\n */\nconst parseLanguageTag = (\n tagString: string,\n index: number\n): LanguagePreference | null => {\n const match = LANGUAGE_FORMAT_REGULAR_EXPRESSION.exec(tagString);\n if (!match) {\n return null;\n }\n\n const languageCode = match[1];\n const regionCode = match[2];\n const parameters = match[3];\n\n // Construct the full locale string (e.g., \"en-US\" or \"en\")\n const fullLocale = regionCode\n ? `${languageCode}-${regionCode}`\n : languageCode;\n\n let qualityScore = DEFAULT_QUALITY_SCORE;\n\n // Parse parameters to find the quality score (\"q\")\n if (parameters) {\n const parameterList = parameters.split(';');\n for (const parameter of parameterList) {\n const [key, value] = parameter.split('=');\n if (key === 'q') {\n qualityScore = parseFloat(value);\n }\n }\n }\n\n return {\n languageCode,\n regionCode,\n qualityScore,\n originalIndex: index,\n fullLocale,\n };\n};\n\n/**\n * Parses the entire Accept-Language header string into a list of preferences.\n */\nconst parseAcceptLanguageHeader = (\n headerValue: string\n): LanguagePreference[] => {\n const rawTags = headerValue.split(',');\n const preferences: LanguagePreference[] = [];\n\n for (let index = 0; index < rawTags.length; index++) {\n const tag = rawTags[index].trim();\n const parsedLanguage = parseLanguageTag(tag, index);\n\n if (parsedLanguage) {\n preferences.push(parsedLanguage);\n }\n }\n\n return preferences;\n};\n\n/**\n * Calculates the specificity of a match between a provided language and a requested preference.\n */\nconst calculateMatchSpecificity = (\n providedLanguage: string,\n preference: LanguagePreference,\n providedIndex: number\n): MatchResult | null => {\n const parsedProvided = parseLanguageTag(providedLanguage, providedIndex);\n if (!parsedProvided) {\n return null;\n }\n\n let specificityScore = SpecificityWeight.None;\n\n const preferenceFullLower = preference.fullLocale.toLowerCase();\n const preferencePrefixLower = preference.languageCode.toLowerCase();\n const providedFullLower = parsedProvided.fullLocale.toLowerCase();\n const providedPrefixLower = parsedProvided.languageCode.toLowerCase();\n\n if (preferenceFullLower === providedFullLower) {\n specificityScore |= SpecificityWeight.Exact;\n } else if (preferencePrefixLower === providedFullLower) {\n specificityScore |= SpecificityWeight.Prefix;\n } else if (preferenceFullLower === providedPrefixLower) {\n specificityScore |= SpecificityWeight.Broad;\n } else if (preference.fullLocale !== '*') {\n return null;\n }\n\n return {\n providedIndex,\n headerIndex: preference.originalIndex,\n qualityScore: preference.qualityScore,\n specificityScore,\n };\n};\n\n/**\n * Determines the best match for a specific available language against the list of user accepted languages.\n */\nconst getBestMatchForLanguage = (\n providedLanguage: string,\n acceptedPreferences: LanguagePreference[],\n providedIndex: number\n): MatchResult => {\n // Initialize with a non-match priority\n let bestMatch: MatchResult = {\n headerIndex: -1,\n qualityScore: 0,\n specificityScore: 0,\n providedIndex,\n };\n\n for (const preference of acceptedPreferences) {\n const matchSpec = calculateMatchSpecificity(\n providedLanguage,\n preference,\n providedIndex\n );\n\n if (matchSpec) {\n // Compare current best match with new match\n const scoreDifference =\n bestMatch.specificityScore - matchSpec.specificityScore ||\n bestMatch.qualityScore - matchSpec.qualityScore ||\n bestMatch.headerIndex - matchSpec.headerIndex;\n\n // If the new match is better (difference < 0), update priority\n if (scoreDifference < 0) {\n bestMatch = matchSpec;\n }\n }\n }\n\n return bestMatch;\n};\n\n/**\n * Comparator function to sort language matches.\n * Sorting order:\n * 1. Quality Score (Descending)\n * 2. Specificity Score (Descending)\n * 3. Order in Header (Ascending - lower index is better)\n * 4. Order in Provided List (Ascending)\n */\nconst compareMatchResults = (a: MatchResult, b: MatchResult): number => {\n return (\n b.qualityScore - a.qualityScore ||\n b.specificityScore - a.specificityScore ||\n a.headerIndex - b.headerIndex ||\n a.providedIndex - b.providedIndex ||\n 0\n );\n};\n\n/**\n * Derives the list of preferred languages based on the Accept-Language header\n * and an optional list of available languages.\n */\nconst getPreferredLanguages = (\n acceptHeader: string | undefined,\n availableLanguages?: string[]\n): string[] => {\n // RFC 2616 sec 14.4: no header implies '*'\n const headerValue = acceptHeader === undefined ? '*' : acceptHeader || '';\n const acceptedPreferences = parseAcceptLanguageHeader(headerValue);\n\n // If no specific languages are provided to filter against, return the header languages sorted by quality\n if (!availableLanguages) {\n return acceptedPreferences\n .filter((preference) => preference.qualityScore > 0)\n .sort((a, b) => b.qualityScore - a.qualityScore) // Simple sort by quality\n .map((preference) => preference.fullLocale);\n }\n\n // Map available languages to their match priority against the header\n const matchResults = availableLanguages.map((language, index) =>\n getBestMatchForLanguage(language, acceptedPreferences, index)\n );\n\n return matchResults\n .filter((result) => result.qualityScore > 0)\n .sort(compareMatchResults)\n .map((result) => availableLanguages[result.providedIndex]);\n};\n\n/**\n * Detects the locale from the request headers.\n *\n * Headers are provided by the browser/client and can be used to determine the user's preferred language.\n * This function intersects the user's `Accept-Language` header with the application's available locales.\n */\nexport const localeDetector = (\n headers: Record<string, string | undefined>,\n availableLocales?: Locale[],\n defaultLocale?: Locale\n): Locale => {\n const acceptLanguageHeader = headers['accept-language'];\n\n const preferredLocaleStrings = getPreferredLanguages(\n acceptLanguageHeader,\n availableLocales as string[]\n );\n\n return localeResolver(\n preferredLocaleStrings as Locale[],\n availableLocales,\n defaultLocale\n );\n};\n"],"mappings":";;;;;;AAMA,MAAM,qCACJ;AACF,MAAM,wBAAwB;;;;;AAM9B,IAAK,kEAAL;AACE;AACA;AACA;AACA;;EAJG;;;;;AAgCL,MAAM,oBACJ,WACA,UAC8B;CAC9B,MAAM,QAAQ,mCAAmC,KAAK,UAAU;AAChE,KAAI,CAAC,MACH,QAAO;CAGT,MAAM,eAAe,MAAM;CAC3B,MAAM,aAAa,MAAM;CACzB,MAAM,aAAa,MAAM;CAGzB,MAAM,aAAa,aACf,GAAG,aAAa,GAAG,eACnB;CAEJ,IAAI,eAAe;AAGnB,KAAI,YAAY;EACd,MAAM,gBAAgB,WAAW,MAAM,IAAI;AAC3C,OAAK,MAAM,aAAa,eAAe;GACrC,MAAM,CAAC,KAAK,SAAS,UAAU,MAAM,IAAI;AACzC,OAAI,QAAQ,IACV,gBAAe,WAAW,MAAM;;;AAKtC,QAAO;EACL;EACA;EACA;EACA,eAAe;EACf;EACD;;;;;AAMH,MAAM,6BACJ,gBACyB;CACzB,MAAM,UAAU,YAAY,MAAM,IAAI;CACtC,MAAMA,cAAoC,EAAE;AAE5C,MAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS;EAEnD,MAAM,iBAAiB,iBADX,QAAQ,OAAO,MAAM,EACY,MAAM;AAEnD,MAAI,eACF,aAAY,KAAK,eAAe;;AAIpC,QAAO;;;;;AAMT,MAAM,6BACJ,kBACA,YACA,kBACuB;CACvB,MAAM,iBAAiB,iBAAiB,kBAAkB,cAAc;AACxE,KAAI,CAAC,eACH,QAAO;CAGT,IAAI,mBAAmB,kBA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AAoB,CACzB,KAAK,WAAW,mBAAmB,OAAO,eAAe;;;;;;;;AAS9D,MAAa,kBACX,SACA,kBACA,kBACW;CACX,MAAM,uBAAuB,QAAQ;AAOrC,QAAOC,mDALwB,sBAC7B,sBACA,iBACD,EAIC,kBACA,cACD"}
|
|
@@ -2,110 +2,129 @@ import { localeResolver } from "./localeResolver.mjs";
|
|
|
2
2
|
|
|
3
3
|
//#region src/localization/localeDetector.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Constants
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
7
|
+
const LANGUAGE_FORMAT_REGULAR_EXPRESSION = /^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;
|
|
8
|
+
const DEFAULT_QUALITY_SCORE = 1;
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
+
* Enumeration for specificity weights.
|
|
11
|
+
* Higher values indicate a more precise match.
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return accepts;
|
|
19
|
-
};
|
|
13
|
+
var SpecificityWeight = /* @__PURE__ */ function(SpecificityWeight$1) {
|
|
14
|
+
SpecificityWeight$1[SpecificityWeight$1["None"] = 0] = "None";
|
|
15
|
+
SpecificityWeight$1[SpecificityWeight$1["Broad"] = 1] = "Broad";
|
|
16
|
+
SpecificityWeight$1[SpecificityWeight$1["Prefix"] = 2] = "Prefix";
|
|
17
|
+
SpecificityWeight$1[SpecificityWeight$1["Exact"] = 4] = "Exact";
|
|
18
|
+
return SpecificityWeight$1;
|
|
19
|
+
}(SpecificityWeight || {});
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Parses a single language tag string from the Accept-Language header.
|
|
22
|
+
* Example input: "en-US;q=0.8"
|
|
22
23
|
*/
|
|
23
|
-
const
|
|
24
|
-
const match =
|
|
24
|
+
const parseLanguageTag = (tagString, index) => {
|
|
25
|
+
const match = LANGUAGE_FORMAT_REGULAR_EXPRESSION.exec(tagString);
|
|
25
26
|
if (!match) return null;
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
32
|
-
const
|
|
33
|
-
for (
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
27
|
+
const languageCode = match[1];
|
|
28
|
+
const regionCode = match[2];
|
|
29
|
+
const parameters = match[3];
|
|
30
|
+
const fullLocale = regionCode ? `${languageCode}-${regionCode}` : languageCode;
|
|
31
|
+
let qualityScore = DEFAULT_QUALITY_SCORE;
|
|
32
|
+
if (parameters) {
|
|
33
|
+
const parameterList = parameters.split(";");
|
|
34
|
+
for (const parameter of parameterList) {
|
|
35
|
+
const [key, value] = parameter.split("=");
|
|
36
|
+
if (key === "q") qualityScore = parseFloat(value);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
return {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
languageCode,
|
|
41
|
+
regionCode,
|
|
42
|
+
qualityScore,
|
|
43
|
+
originalIndex: index,
|
|
44
|
+
fullLocale
|
|
44
45
|
};
|
|
45
46
|
};
|
|
46
47
|
/**
|
|
47
|
-
*
|
|
48
|
+
* Parses the entire Accept-Language header string into a list of preferences.
|
|
48
49
|
*/
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
for (let i = 0; i < accepted.length; i++) {
|
|
57
|
-
const spec = specify(language, accepted[i], index);
|
|
58
|
-
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) priority = spec;
|
|
50
|
+
const parseAcceptLanguageHeader = (headerValue) => {
|
|
51
|
+
const rawTags = headerValue.split(",");
|
|
52
|
+
const preferences = [];
|
|
53
|
+
for (let index = 0; index < rawTags.length; index++) {
|
|
54
|
+
const parsedLanguage = parseLanguageTag(rawTags[index].trim(), index);
|
|
55
|
+
if (parsedLanguage) preferences.push(parsedLanguage);
|
|
59
56
|
}
|
|
60
|
-
return
|
|
57
|
+
return preferences;
|
|
61
58
|
};
|
|
62
59
|
/**
|
|
63
|
-
*
|
|
60
|
+
* Calculates the specificity of a match between a provided language and a requested preference.
|
|
64
61
|
*/
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
if (!
|
|
68
|
-
let
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
const calculateMatchSpecificity = (providedLanguage, preference, providedIndex) => {
|
|
63
|
+
const parsedProvided = parseLanguageTag(providedLanguage, providedIndex);
|
|
64
|
+
if (!parsedProvided) return null;
|
|
65
|
+
let specificityScore = SpecificityWeight.None;
|
|
66
|
+
const preferenceFullLower = preference.fullLocale.toLowerCase();
|
|
67
|
+
const preferencePrefixLower = preference.languageCode.toLowerCase();
|
|
68
|
+
const providedFullLower = parsedProvided.fullLocale.toLowerCase();
|
|
69
|
+
const providedPrefixLower = parsedProvided.languageCode.toLowerCase();
|
|
70
|
+
if (preferenceFullLower === providedFullLower) specificityScore |= SpecificityWeight.Exact;
|
|
71
|
+
else if (preferencePrefixLower === providedFullLower) specificityScore |= SpecificityWeight.Prefix;
|
|
72
|
+
else if (preferenceFullLower === providedPrefixLower) specificityScore |= SpecificityWeight.Broad;
|
|
73
|
+
else if (preference.fullLocale !== "*") return null;
|
|
73
74
|
return {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
providedIndex,
|
|
76
|
+
headerIndex: preference.originalIndex,
|
|
77
|
+
qualityScore: preference.qualityScore,
|
|
78
|
+
specificityScore
|
|
78
79
|
};
|
|
79
80
|
};
|
|
80
81
|
/**
|
|
81
|
-
*
|
|
82
|
+
* Determines the best match for a specific available language against the list of user accepted languages.
|
|
82
83
|
*/
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
const getBestMatchForLanguage = (providedLanguage, acceptedPreferences, providedIndex) => {
|
|
85
|
+
let bestMatch = {
|
|
86
|
+
headerIndex: -1,
|
|
87
|
+
qualityScore: 0,
|
|
88
|
+
specificityScore: 0,
|
|
89
|
+
providedIndex
|
|
90
|
+
};
|
|
91
|
+
for (const preference of acceptedPreferences) {
|
|
92
|
+
const matchSpec = calculateMatchSpecificity(providedLanguage, preference, providedIndex);
|
|
93
|
+
if (matchSpec) {
|
|
94
|
+
if ((bestMatch.specificityScore - matchSpec.specificityScore || bestMatch.qualityScore - matchSpec.qualityScore || bestMatch.headerIndex - matchSpec.headerIndex) < 0) bestMatch = matchSpec;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return bestMatch;
|
|
88
98
|
};
|
|
89
99
|
/**
|
|
90
|
-
*
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*
|
|
100
|
+
* Comparator function to sort language matches.
|
|
101
|
+
* Sorting order:
|
|
102
|
+
* 1. Quality Score (Descending)
|
|
103
|
+
* 2. Specificity Score (Descending)
|
|
104
|
+
* 3. Order in Header (Ascending - lower index is better)
|
|
105
|
+
* 4. Order in Provided List (Ascending)
|
|
95
106
|
*/
|
|
96
|
-
const
|
|
107
|
+
const compareMatchResults = (a, b) => {
|
|
108
|
+
return b.qualityScore - a.qualityScore || b.specificityScore - a.specificityScore || a.headerIndex - b.headerIndex || a.providedIndex - b.providedIndex || 0;
|
|
109
|
+
};
|
|
97
110
|
/**
|
|
98
|
-
*
|
|
111
|
+
* Derives the list of preferred languages based on the Accept-Language header
|
|
112
|
+
* and an optional list of available languages.
|
|
99
113
|
*/
|
|
100
|
-
const
|
|
114
|
+
const getPreferredLanguages = (acceptHeader, availableLanguages) => {
|
|
115
|
+
const acceptedPreferences = parseAcceptLanguageHeader(acceptHeader === void 0 ? "*" : acceptHeader || "");
|
|
116
|
+
if (!availableLanguages) return acceptedPreferences.filter((preference) => preference.qualityScore > 0).sort((a, b) => b.qualityScore - a.qualityScore).map((preference) => preference.fullLocale);
|
|
117
|
+
return availableLanguages.map((language, index) => getBestMatchForLanguage(language, acceptedPreferences, index)).filter((result) => result.qualityScore > 0).sort(compareMatchResults).map((result) => availableLanguages[result.providedIndex]);
|
|
118
|
+
};
|
|
101
119
|
/**
|
|
102
|
-
* Detects the locale from the request headers
|
|
120
|
+
* Detects the locale from the request headers.
|
|
103
121
|
*
|
|
104
|
-
* Headers are provided by the browser and can be used to determine the user's preferred language
|
|
122
|
+
* Headers are provided by the browser/client and can be used to determine the user's preferred language.
|
|
123
|
+
* This function intersects the user's `Accept-Language` header with the application's available locales.
|
|
105
124
|
*/
|
|
106
|
-
const localeDetector = (headers,
|
|
107
|
-
const
|
|
108
|
-
return localeResolver(
|
|
125
|
+
const localeDetector = (headers, availableLocales, defaultLocale) => {
|
|
126
|
+
const acceptLanguageHeader = headers["accept-language"];
|
|
127
|
+
return localeResolver(getPreferredLanguages(acceptLanguageHeader, availableLocales), availableLocales, defaultLocale);
|
|
109
128
|
};
|
|
110
129
|
|
|
111
130
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeDetector.mjs","names":["
|
|
1
|
+
{"version":3,"file":"localeDetector.mjs","names":["preferences: LanguagePreference[]","bestMatch: MatchResult"],"sources":["../../../src/localization/localeDetector.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types';\nimport { localeResolver } from './localeResolver';\n\n/**\n * Constants\n */\nconst LANGUAGE_FORMAT_REGULAR_EXPRESSION =\n /^\\s*([^\\s\\-;]+)(?:-([^\\s;]+))?\\s*(?:;(.*))?$/;\nconst DEFAULT_QUALITY_SCORE = 1;\n\n/**\n * Enumeration for specificity weights.\n * Higher values indicate a more precise match.\n */\nenum SpecificityWeight {\n None = 0,\n Broad = 1, // Matches prefix (e.g., 'en' matches 'en-US')\n Prefix = 2, // Matches prefix in reverse (e.g., 'en-US' matches 'en')\n Exact = 4, // Matches exact string (e.g., 'en-US' matches 'en-US')\n}\n\n/**\n * Represents a parsed language tag from the header.\n */\ntype LanguagePreference = {\n languageCode: string;\n regionCode?: string;\n fullLocale: string;\n qualityScore: number;\n originalIndex: number;\n};\n\n/**\n * Represents the result of matching a requested language against an available language.\n */\ntype MatchResult = {\n providedIndex: number;\n headerIndex: number;\n qualityScore: number;\n specificityScore: number;\n};\n\n/**\n * Parses a single language tag string from the Accept-Language header.\n * Example input: \"en-US;q=0.8\"\n */\nconst parseLanguageTag = (\n tagString: string,\n index: number\n): LanguagePreference | null => {\n const match = LANGUAGE_FORMAT_REGULAR_EXPRESSION.exec(tagString);\n if (!match) {\n return null;\n }\n\n const languageCode = match[1];\n const regionCode = match[2];\n const parameters = match[3];\n\n // Construct the full locale string (e.g., \"en-US\" or \"en\")\n const fullLocale = regionCode\n ? `${languageCode}-${regionCode}`\n : languageCode;\n\n let qualityScore = DEFAULT_QUALITY_SCORE;\n\n // Parse parameters to find the quality score (\"q\")\n if (parameters) {\n const parameterList = parameters.split(';');\n for (const parameter of parameterList) {\n const [key, value] = parameter.split('=');\n if (key === 'q') {\n qualityScore = parseFloat(value);\n }\n }\n }\n\n return {\n languageCode,\n regionCode,\n qualityScore,\n originalIndex: index,\n fullLocale,\n };\n};\n\n/**\n * Parses the entire Accept-Language header string into a list of preferences.\n */\nconst parseAcceptLanguageHeader = (\n headerValue: string\n): LanguagePreference[] => {\n const rawTags = headerValue.split(',');\n const preferences: LanguagePreference[] = [];\n\n for (let index = 0; index < rawTags.length; index++) {\n const tag = rawTags[index].trim();\n const parsedLanguage = parseLanguageTag(tag, index);\n\n if (parsedLanguage) {\n preferences.push(parsedLanguage);\n }\n }\n\n return preferences;\n};\n\n/**\n * Calculates the specificity of a match between a provided language and a requested preference.\n */\nconst calculateMatchSpecificity = (\n providedLanguage: string,\n preference: LanguagePreference,\n providedIndex: number\n): MatchResult | null => {\n const parsedProvided = parseLanguageTag(providedLanguage, providedIndex);\n if (!parsedProvided) {\n return null;\n }\n\n let specificityScore = SpecificityWeight.None;\n\n const preferenceFullLower = preference.fullLocale.toLowerCase();\n const preferencePrefixLower = preference.languageCode.toLowerCase();\n const providedFullLower = parsedProvided.fullLocale.toLowerCase();\n const providedPrefixLower = parsedProvided.languageCode.toLowerCase();\n\n if (preferenceFullLower === providedFullLower) {\n specificityScore |= SpecificityWeight.Exact;\n } else if (preferencePrefixLower === providedFullLower) {\n specificityScore |= SpecificityWeight.Prefix;\n } else if (preferenceFullLower === providedPrefixLower) {\n specificityScore |= SpecificityWeight.Broad;\n } else if (preference.fullLocale !== '*') {\n return null;\n }\n\n return {\n providedIndex,\n headerIndex: preference.originalIndex,\n qualityScore: preference.qualityScore,\n specificityScore,\n };\n};\n\n/**\n * Determines the best match for a specific available language against the list of user accepted languages.\n */\nconst getBestMatchForLanguage = (\n providedLanguage: string,\n acceptedPreferences: LanguagePreference[],\n providedIndex: number\n): MatchResult => {\n // Initialize with a non-match priority\n let bestMatch: MatchResult = {\n headerIndex: -1,\n qualityScore: 0,\n specificityScore: 0,\n providedIndex,\n };\n\n for (const preference of acceptedPreferences) {\n const matchSpec = calculateMatchSpecificity(\n providedLanguage,\n preference,\n providedIndex\n );\n\n if (matchSpec) {\n // Compare current best match with new match\n const scoreDifference =\n bestMatch.specificityScore - matchSpec.specificityScore ||\n bestMatch.qualityScore - matchSpec.qualityScore ||\n bestMatch.headerIndex - matchSpec.headerIndex;\n\n // If the new match is better (difference < 0), update priority\n if (scoreDifference < 0) {\n bestMatch = matchSpec;\n }\n }\n }\n\n return bestMatch;\n};\n\n/**\n * Comparator function to sort language matches.\n * Sorting order:\n * 1. Quality Score (Descending)\n * 2. Specificity Score (Descending)\n * 3. Order in Header (Ascending - lower index is better)\n * 4. Order in Provided List (Ascending)\n */\nconst compareMatchResults = (a: MatchResult, b: MatchResult): number => {\n return (\n b.qualityScore - a.qualityScore ||\n b.specificityScore - a.specificityScore ||\n a.headerIndex - b.headerIndex ||\n a.providedIndex - b.providedIndex ||\n 0\n );\n};\n\n/**\n * Derives the list of preferred languages based on the Accept-Language header\n * and an optional list of available languages.\n */\nconst getPreferredLanguages = (\n acceptHeader: string | undefined,\n availableLanguages?: string[]\n): string[] => {\n // RFC 2616 sec 14.4: no header implies '*'\n const headerValue = acceptHeader === undefined ? '*' : acceptHeader || '';\n const acceptedPreferences = parseAcceptLanguageHeader(headerValue);\n\n // If no specific languages are provided to filter against, return the header languages sorted by quality\n if (!availableLanguages) {\n return acceptedPreferences\n .filter((preference) => preference.qualityScore > 0)\n .sort((a, b) => b.qualityScore - a.qualityScore) // Simple sort by quality\n .map((preference) => preference.fullLocale);\n }\n\n // Map available languages to their match priority against the header\n const matchResults = availableLanguages.map((language, index) =>\n getBestMatchForLanguage(language, acceptedPreferences, index)\n );\n\n return matchResults\n .filter((result) => result.qualityScore > 0)\n .sort(compareMatchResults)\n .map((result) => availableLanguages[result.providedIndex]);\n};\n\n/**\n * Detects the locale from the request headers.\n *\n * Headers are provided by the browser/client and can be used to determine the user's preferred language.\n * This function intersects the user's `Accept-Language` header with the application's available locales.\n */\nexport const localeDetector = (\n headers: Record<string, string | undefined>,\n availableLocales?: Locale[],\n defaultLocale?: Locale\n): Locale => {\n const acceptLanguageHeader = headers['accept-language'];\n\n const preferredLocaleStrings = getPreferredLanguages(\n acceptLanguageHeader,\n availableLocales as string[]\n );\n\n return localeResolver(\n preferredLocaleStrings as Locale[],\n availableLocales,\n defaultLocale\n );\n};\n"],"mappings":";;;;;;AAMA,MAAM,qCACJ;AACF,MAAM,wBAAwB;;;;;AAM9B,IAAK,kEAAL;AACE;AACA;AACA;AACA;;EAJG;;;;;AAgCL,MAAM,oBACJ,WACA,UAC8B;CAC9B,MAAM,QAAQ,mCAAmC,KAAK,UAAU;AAChE,KAAI,CAAC,MACH,QAAO;CAGT,MAAM,eAAe,MAAM;CAC3B,MAAM,aAAa,MAAM;CACzB,MAAM,aAAa,MAAM;CAGzB,MAAM,aAAa,aACf,GA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,cACD;AAED,MAAI,WAQF;QALE,UAAU,mBAAmB,UAAU,oBACvC,UAAU,eAAe,UAAU,gBACnC,UAAU,cAAc,UAAU,eAGd,EACpB,aAAY;;;AAKlB,QAAO;;;;;;;;;;AAWT,MAAM,uBAAuB,GAAgB,MAA2B;AACtE,QACE,EAAE,eAAe,EAAE,gBACnB,EAAE,mBAAmB,EAAE,oBACvB,EAAE,cAAc,EAAE,eAClB,EAAE,gBAAgB,EAAE,iBACpB;;;;;;AAQJ,MAAM,yBACJ,cACA,uBACa;CAGb,MAAM,sBAAsB,0BADR,iBAAiB,SAAY,MAAM,gBAAgB,GACL;AAGlE,KAAI,CAAC,mBACH,QAAO,oBACJ,QAAQ,eAAe,WAAW,eAAe,EAAE,CACnD,MAAM,GAAG,MAAM,EAAE,eAAe,EAAE,aAAa,CAC/C,KAAK,eAAe,WAAW,WAAW;AAQ/C,QAJqB,mBAAmB,KAAK,UAAU,UACrD,wBAAwB,UAAU,qBAAqB,MAAM,CAC9D,CAGE,QAAQ,WAAW,OAAO,eAAe,EAAE,CAC3C,KAAK,oBAAoB,CACzB,KAAK,WAAW,mBAAmB,OAAO,eAAe;;;;;;;;AAS9D,MAAa,kBACX,SACA,kBACA,kBACW;CACX,MAAM,uBAAuB,QAAQ;AAOrC,QAAO,eALwB,sBAC7B,sBACA,iBACD,EAIC,kBACA,cACD"}
|
|
@@ -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_types0 from "@intlayer/types";
|
|
4
4
|
import { ContentNode, DeclaredLocales, Dictionary, LocalesValues } from "@intlayer/types";
|
|
5
5
|
|
|
6
6
|
//#region src/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts
|
|
@@ -24,11 +24,11 @@ declare const getFilterMissingTranslationsContent: <T extends ContentNode, L ext
|
|
|
24
24
|
declare const getFilterMissingTranslationsDictionary: (dictionary: Dictionary, localeToCheck: LocalesValues) => {
|
|
25
25
|
content: any;
|
|
26
26
|
$schema?: string;
|
|
27
|
-
id?:
|
|
27
|
+
id?: _intlayer_types0.DictionaryId;
|
|
28
28
|
projectIds?: string[];
|
|
29
|
-
localId?:
|
|
30
|
-
localIds?:
|
|
31
|
-
key:
|
|
29
|
+
localId?: _intlayer_types0.LocalDictionaryId;
|
|
30
|
+
localIds?: _intlayer_types0.LocalDictionaryId[];
|
|
31
|
+
key: _intlayer_types0.DictionaryKey;
|
|
32
32
|
title?: string;
|
|
33
33
|
description?: string;
|
|
34
34
|
versions?: string[];
|
|
@@ -36,11 +36,11 @@ declare const getFilterMissingTranslationsDictionary: (dictionary: Dictionary, l
|
|
|
36
36
|
filePath?: string;
|
|
37
37
|
tags?: string[];
|
|
38
38
|
locale?: LocalesValues;
|
|
39
|
-
fill?:
|
|
39
|
+
fill?: _intlayer_types0.Fill;
|
|
40
40
|
filled?: true;
|
|
41
41
|
priority?: number;
|
|
42
42
|
live?: boolean;
|
|
43
|
-
location?:
|
|
43
|
+
location?: _intlayer_types0.DictionaryLocation;
|
|
44
44
|
};
|
|
45
45
|
//#endregion
|
|
46
46
|
export { filterMissingTranslationsOnlyPlugin, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DeepTransformContent, NodeProps, Plugins } from "../interpreter/getContent/plugins.js";
|
|
2
2
|
import "../interpreter/index.js";
|
|
3
|
-
import * as
|
|
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,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_types5 from "@intlayer/types";
|
|
4
4
|
import { ContentNode, Dictionary, LocalesValues } from "@intlayer/types";
|
|
5
5
|
|
|
6
6
|
//#region src/deepTransformPlugins/getFilteredLocalesContent.d.ts
|
|
@@ -8,11 +8,11 @@ declare const getFilteredLocalesContent: (node: ContentNode, locales: LocalesVal
|
|
|
8
8
|
declare const getFilteredLocalesDictionary: (dictionary: Dictionary, locale: LocalesValues | LocalesValues[]) => {
|
|
9
9
|
content: any;
|
|
10
10
|
$schema?: string;
|
|
11
|
-
id?:
|
|
11
|
+
id?: _intlayer_types5.DictionaryId;
|
|
12
12
|
projectIds?: string[];
|
|
13
|
-
localId?:
|
|
14
|
-
localIds?:
|
|
15
|
-
key:
|
|
13
|
+
localId?: _intlayer_types5.LocalDictionaryId;
|
|
14
|
+
localIds?: _intlayer_types5.LocalDictionaryId[];
|
|
15
|
+
key: _intlayer_types5.DictionaryKey;
|
|
16
16
|
title?: string;
|
|
17
17
|
description?: string;
|
|
18
18
|
versions?: string[];
|
|
@@ -20,11 +20,11 @@ declare const getFilteredLocalesDictionary: (dictionary: Dictionary, locale: Loc
|
|
|
20
20
|
filePath?: string;
|
|
21
21
|
tags?: string[];
|
|
22
22
|
locale?: LocalesValues;
|
|
23
|
-
fill?:
|
|
23
|
+
fill?: _intlayer_types5.Fill;
|
|
24
24
|
filled?: true;
|
|
25
25
|
priority?: number;
|
|
26
26
|
live?: boolean;
|
|
27
|
-
location?:
|
|
27
|
+
location?: _intlayer_types5.DictionaryLocation;
|
|
28
28
|
};
|
|
29
29
|
//#endregion
|
|
30
30
|
export { getFilteredLocalesContent, getFilteredLocalesDictionary };
|
|
@@ -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"}
|
|
@@ -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,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AA,GAAA,KAAA;;AAOV;AAOE;AAOmC,KAgCzB,oBAhCyB,CAAA,CAAA,EAAA,IAkC/B,uBAlC+B,EAAA,UAmCzB,aAnCyB,GAmCT,eAnCS,CAAA,GAoCjC,KApCiC,CAoC3B,CApC2B,CAAA,SAAA,IAAA,GAqCjC,CArCiC,GAsCjC,gBAtCiC,CAsChB,CAtCgB,EAAA,MAsCP,kBAtCO,CAsCY,CAtCZ,EAsCe,CAtCf,EAsCkB,CAtClB,CAAA,EAsCsB,CAtCtB,CAAA,SAAA,KAAA,GAwC/B,QAxC+B,CAwCtB,CAxCsB,EAwCnB,CAxCmB,EAwChB,CAxCgB,CAAA,GA0C/B,kBA1C+B,CA0CZ,CA1CY,EA0CT,CA1CS,EA0CN,CA1CM,CAAA,CAAA,MA0CG,kBA1CH,CA0CsB,CA1CtB,EA0CyB,CA1CzB,EA0C4B,CA1C5B,CAAA,CAAA"}
|
|
@@ -3,11 +3,12 @@ import { Locale } from "@intlayer/types";
|
|
|
3
3
|
//#region src/localization/localeDetector.d.ts
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Detects the locale from the request headers
|
|
6
|
+
* Detects the locale from the request headers.
|
|
7
7
|
*
|
|
8
|
-
* Headers are provided by the browser and can be used to determine the user's preferred language
|
|
8
|
+
* Headers are provided by the browser/client and can be used to determine the user's preferred language.
|
|
9
|
+
* This function intersects the user's `Accept-Language` header with the application's available locales.
|
|
9
10
|
*/
|
|
10
|
-
declare const localeDetector: (headers: Record<string, string | undefined>,
|
|
11
|
+
declare const localeDetector: (headers: Record<string, string | undefined>, availableLocales?: Locale[], defaultLocale?: Locale) => Locale;
|
|
11
12
|
//#endregion
|
|
12
13
|
export { localeDetector };
|
|
13
14
|
//# sourceMappingURL=localeDetector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeDetector.d.ts","names":[],"sources":["../../../src/localization/localeDetector.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"localeDetector.d.ts","names":[],"sources":["../../../src/localization/localeDetector.ts"],"sourcesContent":[],"mappings":";;;;;;AAgPA;;;;AAIG,cAJU,cAIV,EAAA,CAAA,OAAA,EAHQ,MAGR,CAAA,MAAA,EAAA,MAAA,GAAA,SAAA,CAAA,EAAA,gBAAA,CAAA,EAFkB,MAElB,EAAA,EAAA,aAAA,CAAA,EADe,MACf,EAAA,GAAA,MAAA"}
|
|
@@ -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.1
|
|
3
|
+
"version": "7.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
|
|
6
6
|
"keywords": [
|
|
@@ -101,11 +101,11 @@
|
|
|
101
101
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@intlayer/api": "7.
|
|
105
|
-
"@intlayer/config": "7.
|
|
106
|
-
"@intlayer/dictionaries-entry": "7.
|
|
107
|
-
"@intlayer/types": "7.
|
|
108
|
-
"@intlayer/unmerged-dictionaries-entry": "7.
|
|
104
|
+
"@intlayer/api": "7.2.2",
|
|
105
|
+
"@intlayer/config": "7.2.2",
|
|
106
|
+
"@intlayer/dictionaries-entry": "7.2.2",
|
|
107
|
+
"@intlayer/types": "7.2.2",
|
|
108
|
+
"@intlayer/unmerged-dictionaries-entry": "7.2.2",
|
|
109
109
|
"deepmerge": "4.3.1"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
@@ -113,10 +113,10 @@
|
|
|
113
113
|
"@utils/ts-config": "1.0.4",
|
|
114
114
|
"@utils/ts-config-types": "1.0.4",
|
|
115
115
|
"@utils/tsdown-config": "1.0.4",
|
|
116
|
-
"rimraf": "6.1.
|
|
117
|
-
"tsdown": "0.16.
|
|
116
|
+
"rimraf": "6.1.2",
|
|
117
|
+
"tsdown": "0.16.6",
|
|
118
118
|
"typescript": "5.9.3",
|
|
119
|
-
"vitest": "4.0.
|
|
119
|
+
"vitest": "4.0.12"
|
|
120
120
|
},
|
|
121
121
|
"engines": {
|
|
122
122
|
"node": ">=14.18"
|