@intlayer/core 8.5.2 → 8.6.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/dist/cjs/formatters/compact.cjs +1 -1
- package/dist/cjs/formatters/compact.cjs.map +1 -1
- package/dist/cjs/formatters/currency.cjs +1 -1
- package/dist/cjs/formatters/currency.cjs.map +1 -1
- package/dist/cjs/formatters/date.cjs +1 -1
- package/dist/cjs/formatters/date.cjs.map +1 -1
- package/dist/cjs/formatters/index.cjs +1 -1
- package/dist/cjs/formatters/list.cjs +1 -1
- package/dist/cjs/formatters/list.cjs.map +1 -1
- package/dist/cjs/formatters/number.cjs +1 -1
- package/dist/cjs/formatters/number.cjs.map +1 -1
- package/dist/cjs/formatters/percentage.cjs +2 -2
- package/dist/cjs/formatters/percentage.cjs.map +1 -1
- package/dist/cjs/formatters/relativeTime.cjs +1 -1
- package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
- package/dist/cjs/formatters/units.cjs +1 -1
- package/dist/cjs/formatters/units.cjs.map +1 -1
- package/dist/cjs/index.cjs +17 -9
- package/dist/cjs/interpreter/getContent/getContent.cjs +1 -1
- package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/index.cjs +1 -0
- package/dist/cjs/interpreter/getContent/plugins.cjs +20 -9
- package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
- package/dist/cjs/interpreter/index.cjs +1 -0
- package/dist/cjs/interpreter/splitAndJoinInsertion.cjs +10 -35
- package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
- package/dist/cjs/localization/generateSitemap.cjs +111 -0
- package/dist/cjs/localization/generateSitemap.cjs.map +1 -0
- package/dist/cjs/localization/getBrowserLocale.cjs +1 -1
- package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
- package/dist/cjs/localization/getLocale.cjs +2 -2
- package/dist/cjs/localization/getLocale.cjs.map +1 -1
- package/dist/cjs/localization/getLocalizedUrl.cjs +1 -1
- package/dist/cjs/localization/getPrefix.cjs +1 -1
- package/dist/cjs/localization/index.cjs +8 -7
- package/dist/cjs/localization/localeMapper.cjs +1 -1
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +2 -3
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +9 -3
- package/dist/cjs/utils/intl.cjs +88 -72
- package/dist/cjs/utils/intl.cjs.map +1 -1
- package/dist/cjs/utils/localeStorage.cjs +191 -64
- package/dist/cjs/utils/localeStorage.cjs.map +1 -1
- package/dist/esm/formatters/compact.mjs +2 -2
- package/dist/esm/formatters/compact.mjs.map +1 -1
- package/dist/esm/formatters/currency.mjs +2 -2
- package/dist/esm/formatters/currency.mjs.map +1 -1
- package/dist/esm/formatters/date.mjs +2 -2
- package/dist/esm/formatters/date.mjs.map +1 -1
- package/dist/esm/formatters/index.mjs +2 -2
- package/dist/esm/formatters/list.mjs +2 -2
- package/dist/esm/formatters/list.mjs.map +1 -1
- package/dist/esm/formatters/number.mjs +2 -2
- package/dist/esm/formatters/number.mjs.map +1 -1
- package/dist/esm/formatters/percentage.mjs +3 -3
- package/dist/esm/formatters/percentage.mjs.map +1 -1
- package/dist/esm/formatters/relativeTime.mjs +2 -2
- package/dist/esm/formatters/relativeTime.mjs.map +1 -1
- package/dist/esm/formatters/units.mjs +2 -2
- package/dist/esm/formatters/units.mjs.map +1 -1
- package/dist/esm/index.mjs +11 -11
- package/dist/esm/interpreter/getContent/getContent.mjs +1 -1
- package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/index.mjs +2 -2
- package/dist/esm/interpreter/getContent/plugins.mjs +20 -10
- package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
- package/dist/esm/interpreter/index.mjs +2 -2
- package/dist/esm/interpreter/splitAndJoinInsertion.mjs +10 -35
- package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
- package/dist/esm/localization/generateSitemap.mjs +109 -0
- package/dist/esm/localization/generateSitemap.mjs.map +1 -0
- package/dist/esm/localization/getBrowserLocale.mjs +2 -2
- package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
- package/dist/esm/localization/getLocale.mjs +3 -3
- package/dist/esm/localization/getLocale.mjs.map +1 -1
- package/dist/esm/localization/getLocalizedUrl.mjs +1 -1
- package/dist/esm/localization/getPrefix.mjs +1 -1
- package/dist/esm/localization/index.mjs +7 -7
- package/dist/esm/localization/localeMapper.mjs +1 -1
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +2 -4
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +4 -4
- package/dist/esm/utils/intl.mjs +87 -72
- package/dist/esm/utils/intl.mjs.map +1 -1
- package/dist/esm/utils/localeStorage.mjs +186 -65
- package/dist/esm/utils/localeStorage.mjs.map +1 -1
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +10 -10
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +10 -10
- package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +10 -10
- package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +2 -2
- package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +1 -1
- package/dist/types/formatters/index.d.ts +2 -2
- package/dist/types/formatters/number.d.ts +4 -1
- package/dist/types/formatters/number.d.ts.map +1 -1
- package/dist/types/formatters/percentage.d.ts +4 -1
- package/dist/types/formatters/percentage.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -5
- package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
- package/dist/types/interpreter/getContent/index.d.ts +2 -2
- package/dist/types/interpreter/getContent/plugins.d.ts +7 -1
- package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
- package/dist/types/interpreter/index.d.ts +2 -2
- package/dist/types/interpreter/splitAndJoinInsertion.d.ts +0 -17
- package/dist/types/interpreter/splitAndJoinInsertion.d.ts.map +1 -1
- package/dist/types/localization/generateSitemap.d.ts +93 -0
- package/dist/types/localization/generateSitemap.d.ts.map +1 -0
- package/dist/types/localization/getBrowserLocale.d.ts +2 -2
- package/dist/types/localization/getBrowserLocale.d.ts.map +1 -1
- package/dist/types/localization/index.d.ts +2 -2
- package/dist/types/transpiler/html/getHTMLCustomComponents.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +3 -3
- package/dist/types/utils/intl.d.ts +15 -11
- package/dist/types/utils/intl.d.ts.map +1 -1
- package/dist/types/utils/localeStorage.d.ts +85 -68
- package/dist/types/utils/localeStorage.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/cjs/getStorageAttributes.cjs +0 -135
- package/dist/cjs/getStorageAttributes.cjs.map +0 -1
- package/dist/esm/getStorageAttributes.mjs +0 -133
- package/dist/esm/getStorageAttributes.mjs.map +0 -1
- package/dist/types/getStorageAttributes.d.ts +0 -29
- package/dist/types/getStorageAttributes.d.ts.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getStorageAttributes } from "../getStorageAttributes.mjs";
|
|
2
1
|
import { getCookie } from "./getCookie.mjs";
|
|
3
2
|
import configuration from "@intlayer/config/built";
|
|
4
3
|
|
|
@@ -13,78 +12,210 @@ const buildCookieString = (name, value, attributes) => {
|
|
|
13
12
|
return parts.join("; ");
|
|
14
13
|
};
|
|
15
14
|
/**
|
|
16
|
-
* Retrieves the locale from
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @returns The locale if found in any storage, or undefined if not found
|
|
15
|
+
* Retrieves the locale from browser storage mechanisms
|
|
16
|
+
* (cookies, localStorage, sessionStorage).
|
|
17
|
+
* Does not read from headers — use `getLocaleFromStorageServer` for that.
|
|
20
18
|
*/
|
|
21
|
-
const
|
|
19
|
+
const getLocaleFromStorageClient = (options) => {
|
|
22
20
|
const { routing, internationalization } = configuration;
|
|
23
21
|
const { locales } = internationalization;
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return locales.includes(value);
|
|
30
|
-
};
|
|
31
|
-
const readCookie = (name) => {
|
|
32
|
-
try {
|
|
33
|
-
const fromOption = options?.getCookie?.(name);
|
|
34
|
-
if (fromOption !== null && fromOption !== void 0) return fromOption;
|
|
35
|
-
} catch {}
|
|
36
|
-
return getCookie(name);
|
|
37
|
-
};
|
|
38
|
-
for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
39
|
-
const { name } = storageAttributes.cookies[i];
|
|
40
|
-
const value = readCookie(name);
|
|
22
|
+
const storageAttributes = routing.storage;
|
|
23
|
+
if (options?.isCookieEnabled === false) return void 0;
|
|
24
|
+
const isValidLocale = (value) => !!value && locales.includes(value);
|
|
25
|
+
for (let i = 0; i < storageAttributes.cookies.length; i++) try {
|
|
26
|
+
const value = options?.getCookie?.(storageAttributes.cookies[i].name);
|
|
41
27
|
if (isValidLocale(value)) return value;
|
|
28
|
+
} catch {}
|
|
29
|
+
for (let i = 0; i < storageAttributes.localStorage.length; i++) try {
|
|
30
|
+
const value = options?.getLocaleStorage?.(storageAttributes.localStorage[i].name);
|
|
31
|
+
if (isValidLocale(value)) return value;
|
|
32
|
+
} catch {}
|
|
33
|
+
for (let i = 0; i < storageAttributes.sessionStorage.length; i++) try {
|
|
34
|
+
const value = options?.getSessionStorage?.(storageAttributes.sessionStorage[i].name);
|
|
35
|
+
if (isValidLocale(value)) return value;
|
|
36
|
+
} catch {}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Stores the locale in browser storage mechanisms
|
|
40
|
+
* (cookies, localStorage, sessionStorage).
|
|
41
|
+
* Does not write to headers — use `setLocaleInStorageServer` for that.
|
|
42
|
+
*/
|
|
43
|
+
const setLocaleInStorageClient = (locale, options) => {
|
|
44
|
+
const { routing } = configuration;
|
|
45
|
+
const storageAttributes = routing.storage;
|
|
46
|
+
if (options?.isCookieEnabled === false) return;
|
|
47
|
+
for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
48
|
+
const { name, attributes } = storageAttributes.cookies[i];
|
|
49
|
+
try {
|
|
50
|
+
if (options?.setCookieStore) options.setCookieStore(name, locale, {
|
|
51
|
+
...attributes,
|
|
52
|
+
expires: attributes.expires instanceof Date ? attributes.expires.getTime() : attributes.expires
|
|
53
|
+
});
|
|
54
|
+
} catch {
|
|
55
|
+
try {
|
|
56
|
+
if (options?.setCookieString) options.setCookieString(name, buildCookieString(name, locale, attributes));
|
|
57
|
+
} catch {}
|
|
58
|
+
}
|
|
42
59
|
}
|
|
43
|
-
for (let i = 0; i < storageAttributes.localStorage.length; i++) {
|
|
60
|
+
if (options?.setLocaleStorage) for (let i = 0; i < storageAttributes.localStorage.length; i++) {
|
|
44
61
|
const { name } = storageAttributes.localStorage[i];
|
|
45
62
|
try {
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {
|
|
64
|
+
if (options.getLocaleStorage(name)) continue;
|
|
65
|
+
}
|
|
66
|
+
options.setLocaleStorage(name, locale);
|
|
48
67
|
} catch {}
|
|
49
68
|
}
|
|
50
|
-
for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
|
|
69
|
+
if (options?.setSessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
|
|
51
70
|
const { name } = storageAttributes.sessionStorage[i];
|
|
52
71
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
if (!(options?.overwrite ?? true) && options?.getSessionStorage) {
|
|
73
|
+
if (options.getSessionStorage(name)) continue;
|
|
74
|
+
}
|
|
75
|
+
options.setSessionStorage(name, locale);
|
|
55
76
|
} catch {}
|
|
56
77
|
}
|
|
57
|
-
|
|
58
|
-
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Client-side locale storage utility.
|
|
81
|
+
* Handles cookies (browser), localStorage and sessionStorage.
|
|
82
|
+
* Does not access headers.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const storage = LocaleStorageClient(localeStorageOptions);
|
|
87
|
+
* const locale = storage.getLocale();
|
|
88
|
+
* storage.setLocale('fr');
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
const LocaleStorageClient = (options) => ({
|
|
92
|
+
getLocale: () => getLocaleFromStorageClient(options),
|
|
93
|
+
setLocale: (locale) => setLocaleInStorageClient(locale, options)
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Retrieves the locale from server-side storage mechanisms (cookies, headers).
|
|
97
|
+
* Does not access localStorage or sessionStorage.
|
|
98
|
+
* No browser cookie fallback — the caller must provide `getCookie`.
|
|
99
|
+
*/
|
|
100
|
+
const getLocaleFromStorageServer = (options) => {
|
|
101
|
+
const { routing, internationalization } = configuration;
|
|
102
|
+
const { locales } = internationalization;
|
|
103
|
+
const storageAttributes = routing.storage;
|
|
104
|
+
if (options?.isCookieEnabled === false) return void 0;
|
|
105
|
+
const isValidLocale = (value) => !!value && locales.includes(value);
|
|
106
|
+
for (let i = 0; i < storageAttributes.cookies.length; i++) try {
|
|
107
|
+
const value = options?.getCookie?.(storageAttributes.cookies[i].name);
|
|
108
|
+
if (isValidLocale(value)) return value;
|
|
109
|
+
} catch {}
|
|
110
|
+
for (let i = 0; i < storageAttributes.headers.length; i++) try {
|
|
111
|
+
const value = options?.getHeader?.(storageAttributes.headers[i].name);
|
|
112
|
+
if (isValidLocale(value)) return value;
|
|
113
|
+
} catch {}
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Stores the locale in server-side storage mechanisms (cookies, headers).
|
|
117
|
+
* Does not write to localStorage or sessionStorage.
|
|
118
|
+
*/
|
|
119
|
+
const setLocaleInStorageServer = (locale, options) => {
|
|
120
|
+
const { routing } = configuration;
|
|
121
|
+
const storageAttributes = routing.storage;
|
|
122
|
+
if (options?.isCookieEnabled === false) return;
|
|
123
|
+
for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
124
|
+
const { name, attributes } = storageAttributes.cookies[i];
|
|
59
125
|
try {
|
|
60
|
-
|
|
61
|
-
|
|
126
|
+
if (options?.setCookieStore) options.setCookieStore(name, locale, {
|
|
127
|
+
...attributes,
|
|
128
|
+
expires: attributes.expires instanceof Date ? attributes.expires.getTime() : attributes.expires
|
|
129
|
+
});
|
|
130
|
+
} catch {
|
|
131
|
+
try {
|
|
132
|
+
if (options?.setCookieString) options.setCookieString(name, buildCookieString(name, locale, attributes));
|
|
133
|
+
} catch {}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (options?.setHeader) for (let i = 0; i < storageAttributes.headers.length; i++) try {
|
|
137
|
+
options.setHeader(storageAttributes.headers[i].name, locale);
|
|
138
|
+
} catch {}
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Server-side locale storage utility.
|
|
142
|
+
* Handles cookies (via injected getter/setter) and headers.
|
|
143
|
+
* Does not access localStorage or sessionStorage.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* const storage = LocaleStorageServer({
|
|
148
|
+
* getCookie: (name) => req.cookies[name],
|
|
149
|
+
* setCookieStore: (name, value, attrs) => res.cookie(name, value, attrs),
|
|
150
|
+
* getHeader: (name) => req.headers[name],
|
|
151
|
+
* setHeader: (name, value) => res.setHeader(name, value),
|
|
152
|
+
* });
|
|
153
|
+
* const locale = storage.getLocale();
|
|
154
|
+
* storage.setLocale('fr');
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
const LocaleStorageServer = (options) => ({
|
|
158
|
+
getLocale: () => getLocaleFromStorageServer(options),
|
|
159
|
+
setLocale: (locale) => setLocaleInStorageServer(locale, options)
|
|
160
|
+
});
|
|
161
|
+
/**
|
|
162
|
+
* Retrieves the locale from all storage mechanisms
|
|
163
|
+
* (cookies, localStorage, sessionStorage, headers).
|
|
164
|
+
*
|
|
165
|
+
* @deprecated Use {@link getLocaleFromStorageClient} (browser) or
|
|
166
|
+
* {@link getLocaleFromStorageServer} (server) instead.
|
|
167
|
+
*/
|
|
168
|
+
const getLocaleFromStorage = (options) => {
|
|
169
|
+
const { routing, internationalization } = configuration;
|
|
170
|
+
const { locales } = internationalization;
|
|
171
|
+
const storageAttributes = routing.storage;
|
|
172
|
+
if (options?.isCookieEnabled === false) return void 0;
|
|
173
|
+
const isValidLocale = (value) => !!value && locales.includes(value);
|
|
174
|
+
const readCookie = (name) => {
|
|
175
|
+
try {
|
|
176
|
+
const fromOption = options?.getCookie?.(name);
|
|
177
|
+
if (fromOption !== null && fromOption !== void 0) return fromOption;
|
|
62
178
|
} catch {}
|
|
179
|
+
return getCookie(name);
|
|
180
|
+
};
|
|
181
|
+
for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
182
|
+
const value = readCookie(storageAttributes.cookies[i].name);
|
|
183
|
+
if (isValidLocale(value)) return value;
|
|
63
184
|
}
|
|
185
|
+
for (let i = 0; i < storageAttributes.localStorage.length; i++) try {
|
|
186
|
+
const value = options?.getLocaleStorage?.(storageAttributes.localStorage[i].name);
|
|
187
|
+
if (isValidLocale(value)) return value;
|
|
188
|
+
} catch {}
|
|
189
|
+
for (let i = 0; i < storageAttributes.sessionStorage.length; i++) try {
|
|
190
|
+
const value = options?.getSessionStorage?.(storageAttributes.sessionStorage[i].name);
|
|
191
|
+
if (isValidLocale(value)) return value;
|
|
192
|
+
} catch {}
|
|
193
|
+
for (let i = 0; i < storageAttributes.headers.length; i++) try {
|
|
194
|
+
const value = options?.getHeader?.(storageAttributes.headers[i].name);
|
|
195
|
+
if (isValidLocale(value)) return value;
|
|
196
|
+
} catch {}
|
|
64
197
|
};
|
|
65
198
|
/**
|
|
66
|
-
* Stores the locale in
|
|
67
|
-
*
|
|
68
|
-
* Respects overwrite flags for localStorage and sessionStorage.
|
|
199
|
+
* Stores the locale in all configured storage mechanisms
|
|
200
|
+
* (cookies, localStorage, sessionStorage, headers).
|
|
69
201
|
*
|
|
70
|
-
* @
|
|
202
|
+
* @deprecated Use {@link setLocaleInStorageClient} (browser) or
|
|
203
|
+
* {@link setLocaleInStorageServer} (server) instead.
|
|
71
204
|
*/
|
|
72
205
|
const setLocaleInStorage = (locale, options) => {
|
|
73
|
-
|
|
74
|
-
const storageAttributes =
|
|
206
|
+
const { routing } = configuration;
|
|
207
|
+
const storageAttributes = routing.storage;
|
|
208
|
+
if (options?.isCookieEnabled === false) return;
|
|
75
209
|
for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
76
210
|
const { name, attributes } = storageAttributes.cookies[i];
|
|
77
211
|
try {
|
|
78
|
-
if (options?.setCookieStore) options
|
|
212
|
+
if (options?.setCookieStore) options.setCookieStore(name, locale, {
|
|
79
213
|
...attributes,
|
|
80
214
|
expires: attributes.expires instanceof Date ? attributes.expires.getTime() : attributes.expires
|
|
81
215
|
});
|
|
82
216
|
} catch {
|
|
83
217
|
try {
|
|
84
|
-
if (options?.setCookieString)
|
|
85
|
-
const cookieString = buildCookieString(name, locale, attributes);
|
|
86
|
-
options?.setCookieString?.(name, cookieString);
|
|
87
|
-
}
|
|
218
|
+
if (options?.setCookieString) options.setCookieString(name, buildCookieString(name, locale, attributes));
|
|
88
219
|
} catch {}
|
|
89
220
|
}
|
|
90
221
|
}
|
|
@@ -92,39 +223,29 @@ const setLocaleInStorage = (locale, options) => {
|
|
|
92
223
|
const { name } = storageAttributes.localStorage[i];
|
|
93
224
|
try {
|
|
94
225
|
if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {
|
|
95
|
-
if (options
|
|
226
|
+
if (options.getLocaleStorage(name)) continue;
|
|
96
227
|
}
|
|
97
|
-
options
|
|
228
|
+
options.setLocaleStorage(name, locale);
|
|
98
229
|
} catch {}
|
|
99
230
|
}
|
|
100
231
|
if (options?.setSessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
|
|
101
232
|
const { name } = storageAttributes.sessionStorage[i];
|
|
102
233
|
try {
|
|
103
234
|
if (!(options?.overwrite ?? true) && options?.getSessionStorage) {
|
|
104
|
-
if (options
|
|
235
|
+
if (options.getSessionStorage(name)) continue;
|
|
105
236
|
}
|
|
106
|
-
options
|
|
107
|
-
} catch {}
|
|
108
|
-
}
|
|
109
|
-
if (options?.setHeader) for (let i = 0; i < storageAttributes.headers.length; i++) {
|
|
110
|
-
const { name } = storageAttributes.headers[i];
|
|
111
|
-
try {
|
|
112
|
-
options?.setHeader?.(name, locale);
|
|
237
|
+
options.setSessionStorage(name, locale);
|
|
113
238
|
} catch {}
|
|
114
239
|
}
|
|
240
|
+
if (options?.setHeader) for (let i = 0; i < storageAttributes.headers.length; i++) try {
|
|
241
|
+
options.setHeader(storageAttributes.headers[i].name, locale);
|
|
242
|
+
} catch {}
|
|
115
243
|
};
|
|
116
244
|
/**
|
|
117
|
-
* Utility object to get and set the locale in
|
|
118
|
-
*
|
|
119
|
-
* @property getLocale - Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).
|
|
120
|
-
* Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).
|
|
121
|
-
* The function checks storage locations in order of priority as defined in the configuration.
|
|
122
|
-
*
|
|
123
|
-
* @property setLocale - Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).
|
|
124
|
-
* The function writes to all configured storage locations according to their attributes.
|
|
125
|
-
* Respects overwrite flags for localStorage and sessionStorage.
|
|
245
|
+
* Utility object to get and set the locale in storage based on configuration.
|
|
126
246
|
*
|
|
127
|
-
* @
|
|
247
|
+
* @deprecated Use {@link LocaleStorageClient} (browser) or
|
|
248
|
+
* {@link LocaleStorageServer} (server) instead.
|
|
128
249
|
*/
|
|
129
250
|
const LocaleStorage = (options) => ({
|
|
130
251
|
getLocale: () => getLocaleFromStorage(options),
|
|
@@ -132,5 +253,5 @@ const LocaleStorage = (options) => ({
|
|
|
132
253
|
});
|
|
133
254
|
|
|
134
255
|
//#endregion
|
|
135
|
-
export { LocaleStorage, getLocaleFromStorage, setLocaleInStorage };
|
|
256
|
+
export { LocaleStorage, LocaleStorageClient, LocaleStorageServer, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, setLocaleInStorage, setLocaleInStorageClient, setLocaleInStorageServer };
|
|
136
257
|
//# sourceMappingURL=localeStorage.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeStorage.mjs","names":[],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { CookiesAttributes } from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getStorageAttributes } from '../getStorageAttributes';\nimport { getCookie } from './getCookie';\n\ntype CookieBuildAttributes = {\n /**\n * Cookie domain to store the locale information\n *\n * Default: undefined\n *\n * Define the domain where the cookie is available. Defaults to\n * the domain of the page where the cookie was created.\n */\n domain?: string;\n /**\n * Cookie path to store the locale information\n *\n * Default: undefined\n *\n * Define the path where the cookie is available. Defaults to '/'\n */\n path?: string;\n /**\n * Cookie secure to store the locale information\n *\n * Default: undefined\n *\n * A Boolean indicating if the cookie transmission requires a\n * secure protocol (https). Defaults to false.\n */\n secure?: boolean;\n /**\n * Cookie httpOnly to store the locale information\n *\n * Default: undefined\n *\n * The cookie httpOnly where the locale information is stored.\n */\n httpOnly?: boolean;\n /**\n * Cookie sameSite to store the locale information\n *\n * Default: undefined\n *\n * Asserts that a cookie must not be sent with cross-origin requests,\n * providing some protection against cross-site request forgery\n * attacks (CSRF)\n */\n sameSite?: 'strict' | 'lax' | 'none';\n\n /**\n * Cookie expires to store the locale information\n *\n * Default: undefined\n *\n * Define when the cookie will be removed. Value can be a Number\n * which will be interpreted as days from time of creation or a\n * Date instance. If omitted, the cookie becomes a session cookie.\n */\n expires?: number | undefined;\n};\n\nconst buildCookieString = (\n name: string,\n value: string,\n attributes: Omit<CookiesAttributes, 'name' | 'type'>\n): string => {\n const encodedValue = encodeURIComponent(value);\n const parts: string[] = [`${name}=${encodedValue}`];\n\n if (attributes.path) parts.push(`Path=${attributes.path}`);\n if (attributes.domain) parts.push(`Domain=${attributes.domain}`);\n if (attributes.expires instanceof Date)\n parts.push(`Expires=${attributes.expires.toUTCString()}`);\n\n if (attributes.secure) parts.push('Secure');\n if (attributes.sameSite) parts.push(`SameSite=${attributes.sameSite}`);\n return parts.join('; ');\n};\n\nexport type LocaleStorageOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n setSessionStorage?: (name: string, value: string) => void;\n getSessionStorage?: (name: string) => string | undefined | null;\n setLocaleStorage?: (name: string, value: string) => void;\n getLocaleStorage?: (name: string) => string | undefined | null;\n getHeader?: (name: string) => string | undefined | null;\n setHeader?: (name: string, value: string) => void;\n};\n\n/**\n * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function checks storage locations in order of priority as defined in the configuration.\n *\n * @returns The locale if found in any storage, or undefined if not found\n */\nexport const getLocaleFromStorage = (\n options: Pick<\n LocaleStorageOptions,\n | 'getCookie'\n | 'getSessionStorage'\n | 'getLocaleStorage'\n | 'getHeader'\n | 'isCookieEnabled'\n >\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const { storage } = routing;\n\n // If storage is disabled, return undefined\n if (storage === false || options?.isCookieEnabled === false) return undefined;\n\n const storageAttributes = getStorageAttributes(storage);\n\n const isValidLocale = (value: string | null | undefined): value is Locale => {\n if (!value) return false;\n\n return locales.includes(value as Locale);\n };\n\n const readCookie = (name: string): string | undefined => {\n // Prefer provided getter (server or custom environment)\n try {\n const fromOption = options?.getCookie?.(name);\n\n if (fromOption !== null && fromOption !== undefined) return fromOption;\n } catch {}\n\n // Fallback to browser cookie parsing\n return getCookie(name);\n };\n\n // Check cookies first\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name } = storageAttributes.cookies[i];\n\n const value = readCookie(name);\n\n if (isValidLocale(value)) return value;\n }\n\n // Then check localStorage candidates (browser only)\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n\n try {\n const value = options?.getLocaleStorage?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n // Check sessionStorage candidates (browser only)\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n\n try {\n const value = options?.getSessionStorage?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n // Finally check header candidates (server only)\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n const { name } = storageAttributes.headers[i];\n\n try {\n const value = options?.getHeader?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n};\n\n/**\n * Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function writes to all configured storage locations according to their attributes.\n * Respects overwrite flags for localStorage and sessionStorage.\n *\n * @param locale - The locale to store\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n options?: LocaleStorageOptions\n): void => {\n // If storage is disabled, do nothing\n if (\n configuration.routing.storage === false ||\n options?.isCookieEnabled === false\n )\n return;\n\n const storageAttributes = getStorageAttributes(configuration.routing.storage);\n\n // Write to cookies (server via setCookie, client via cookieStore/document)\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n\n try {\n if (options?.setCookieStore) {\n options?.setCookieStore?.(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n const cookieString = buildCookieString(name, locale, attributes);\n\n options?.setCookieString?.(name, cookieString);\n }\n } catch {}\n }\n }\n\n // Write to localStorage (browser only)\n if (options?.setLocaleStorage) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n\n try {\n const shouldOverwrite = options?.overwrite ?? true;\n\n if (!shouldOverwrite && options?.getLocaleStorage) {\n const existing = options?.getLocaleStorage?.(name);\n\n if (existing) continue;\n }\n options?.setLocaleStorage?.(name, locale);\n } catch {}\n }\n }\n\n // Write to sessionStorage (browser only)\n if (options?.setSessionStorage) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n\n try {\n const shouldOverwrite = options?.overwrite ?? true;\n\n if (!shouldOverwrite && options?.getSessionStorage) {\n const existing = options?.getSessionStorage?.(name);\n if (existing) continue;\n }\n\n options?.setSessionStorage?.(name, locale);\n } catch {}\n }\n }\n\n // Write to headers (server only)\n if (options?.setHeader) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n const { name } = storageAttributes.headers[i];\n\n try {\n options?.setHeader?.(name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Utility object to get and set the locale in the storage by considering the configuration\n *\n * @property getLocale - Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function checks storage locations in order of priority as defined in the configuration.\n *\n * @property setLocale - Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function writes to all configured storage locations according to their attributes.\n * Respects overwrite flags for localStorage and sessionStorage.\n *\n * @returns The locale if found in any storage, or undefined if not found\n */\nexport const LocaleStorage = (options: LocaleStorageOptions) => ({\n getLocale: () => getLocaleFromStorage(options),\n setLocale: (locale: LocalesValues) => setLocaleInStorage(locale, options),\n});\n"],"mappings":";;;;;AAiEA,MAAM,qBACJ,MACA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AAI,GAAG,IAAI,kBAAkB,eAAe,QAAQ,KAAK;EAChE,MAAM,EAAE,SAAS,kBAAkB,eAAe;AAElD,MAAI;AAGF,OAAI,EAFoB,SAAS,aAAa,SAEtB,SAAS,mBAE/B;QADiB,SAAS,oBAAoB,KAAK,CACrC;;AAGhB,YAAS,oBAAoB,MAAM,OAAO;UACpC;;AAKZ,KAAI,SAAS,UACX,MAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,QAAQ,QAAQ,KAAK;EACzD,MAAM,EAAE,SAAS,kBAAkB,QAAQ;AAE3C,MAAI;AACF,YAAS,YAAY,MAAM,OAAO;UAC5B;;;;;;;;;;;;;;;;AAkBd,MAAa,iBAAiB,aAAmC;CAC/D,iBAAiB,qBAAqB,QAAQ;CAC9C,YAAY,WAA0B,mBAAmB,QAAQ,QAAQ;CAC1E"}
|
|
1
|
+
{"version":3,"file":"localeStorage.mjs","names":[],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { CookiesAttributes } from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getCookie } from './getCookie';\n\n// ============================================================================\n// Shared types\n// ============================================================================\n\nexport type CookieBuildAttributes = {\n domain?: string;\n path?: string;\n secure?: boolean;\n httpOnly?: boolean;\n sameSite?: 'strict' | 'lax' | 'none';\n /** Expiry as milliseconds since epoch (Date.getTime()) or number of days */\n expires?: number | undefined;\n};\n\n// ============================================================================\n// Shared helpers\n// ============================================================================\n\nconst buildCookieString = (\n name: string,\n value: string,\n attributes: Omit<CookiesAttributes, 'name' | 'type'>\n): string => {\n const encodedValue = encodeURIComponent(value);\n const parts: string[] = [`${name}=${encodedValue}`];\n\n if (attributes.path) parts.push(`Path=${attributes.path}`);\n if (attributes.domain) parts.push(`Domain=${attributes.domain}`);\n if (attributes.expires instanceof Date)\n parts.push(`Expires=${attributes.expires.toUTCString()}`);\n if (attributes.secure) parts.push('Secure');\n if (attributes.sameSite) parts.push(`SameSite=${attributes.sameSite}`);\n return parts.join('; ');\n};\n\n// ============================================================================\n// Client-specific types and functions\n// (cookies via browser APIs, localStorage, sessionStorage — no headers)\n// ============================================================================\n\nexport type LocaleStorageClientOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n setSessionStorage?: (name: string, value: string) => void;\n getSessionStorage?: (name: string) => string | undefined | null;\n setLocaleStorage?: (name: string, value: string) => void;\n getLocaleStorage?: (name: string) => string | undefined | null;\n};\n\n/**\n * Retrieves the locale from browser storage mechanisms\n * (cookies, localStorage, sessionStorage).\n * Does not read from headers — use `getLocaleFromStorageServer` for that.\n */\nexport const getLocaleFromStorageClient = (\n options: LocaleStorageClientOptions\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n try {\n const value = options?.getCookie?.(storageAttributes.cookies[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n storageAttributes.localStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n storageAttributes.sessionStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n};\n\n/**\n * Stores the locale in browser storage mechanisms\n * (cookies, localStorage, sessionStorage).\n * Does not write to headers — use `setLocaleInStorageServer` for that.\n */\nexport const setLocaleInStorageClient = (\n locale: LocalesValues,\n options?: LocaleStorageClientOptions\n): void => {\n const { routing } = configuration;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n\n if (options?.setLocaleStorage) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {\n if (options.getLocaleStorage(name)) continue;\n }\n options.setLocaleStorage(name, locale);\n } catch {}\n }\n }\n\n if (options?.setSessionStorage) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getSessionStorage) {\n if (options.getSessionStorage(name)) continue;\n }\n options.setSessionStorage(name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Client-side locale storage utility.\n * Handles cookies (browser), localStorage and sessionStorage.\n * Does not access headers.\n *\n * @example\n * ```ts\n * const storage = LocaleStorageClient(localeStorageOptions);\n * const locale = storage.getLocale();\n * storage.setLocale('fr');\n * ```\n */\nexport const LocaleStorageClient = (options: LocaleStorageClientOptions) => ({\n getLocale: () => getLocaleFromStorageClient(options),\n setLocale: (locale: LocalesValues) =>\n setLocaleInStorageClient(locale, options),\n});\n\n// ============================================================================\n// Server-specific types and functions\n// (cookies via injected getter/setter, headers — no localStorage/sessionStorage)\n// ============================================================================\n\nexport type LocaleStorageServerOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n getHeader?: (name: string) => string | undefined | null;\n setHeader?: (name: string, value: string) => void;\n};\n\n/**\n * Retrieves the locale from server-side storage mechanisms (cookies, headers).\n * Does not access localStorage or sessionStorage.\n * No browser cookie fallback — the caller must provide `getCookie`.\n */\nexport const getLocaleFromStorageServer = (\n options: LocaleStorageServerOptions\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n try {\n const value = options?.getCookie?.(storageAttributes.cookies[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n try {\n const value = options?.getHeader?.(storageAttributes.headers[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n};\n\n/**\n * Stores the locale in server-side storage mechanisms (cookies, headers).\n * Does not write to localStorage or sessionStorage.\n */\nexport const setLocaleInStorageServer = (\n locale: LocalesValues,\n options?: LocaleStorageServerOptions\n): void => {\n const { routing } = configuration;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n\n if (options?.setHeader) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n try {\n options.setHeader(storageAttributes.headers[i].name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Server-side locale storage utility.\n * Handles cookies (via injected getter/setter) and headers.\n * Does not access localStorage or sessionStorage.\n *\n * @example\n * ```ts\n * const storage = LocaleStorageServer({\n * getCookie: (name) => req.cookies[name],\n * setCookieStore: (name, value, attrs) => res.cookie(name, value, attrs),\n * getHeader: (name) => req.headers[name],\n * setHeader: (name, value) => res.setHeader(name, value),\n * });\n * const locale = storage.getLocale();\n * storage.setLocale('fr');\n * ```\n */\nexport const LocaleStorageServer = (options: LocaleStorageServerOptions) => ({\n getLocale: () => getLocaleFromStorageServer(options),\n setLocale: (locale: LocalesValues) =>\n setLocaleInStorageServer(locale, options),\n});\n\n// ============================================================================\n// Deprecated: combined LocaleStorage\n// Use LocaleStorageClient or LocaleStorageServer instead\n// ============================================================================\n\n/**\n * @deprecated Use {@link LocaleStorageClientOptions} or {@link LocaleStorageServerOptions} instead.\n */\nexport type LocaleStorageOptions = LocaleStorageClientOptions &\n LocaleStorageServerOptions;\n\n/**\n * Retrieves the locale from all storage mechanisms\n * (cookies, localStorage, sessionStorage, headers).\n *\n * @deprecated Use {@link getLocaleFromStorageClient} (browser) or\n * {@link getLocaleFromStorageServer} (server) instead.\n */\nexport const getLocaleFromStorage = (\n options: Pick<\n LocaleStorageOptions,\n | 'getCookie'\n | 'getSessionStorage'\n | 'getLocaleStorage'\n | 'getHeader'\n | 'isCookieEnabled'\n >\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n const readCookie = (name: string): string | undefined => {\n try {\n const fromOption = options?.getCookie?.(name);\n if (fromOption !== null && fromOption !== undefined) return fromOption;\n } catch {}\n // Browser fallback kept for backward compatibility\n return getCookie(name);\n };\n\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const value = readCookie(storageAttributes.cookies[i].name);\n if (isValidLocale(value)) return value;\n }\n\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n storageAttributes.localStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n storageAttributes.sessionStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n try {\n const value = options?.getHeader?.(storageAttributes.headers[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n};\n\n/**\n * Stores the locale in all configured storage mechanisms\n * (cookies, localStorage, sessionStorage, headers).\n *\n * @deprecated Use {@link setLocaleInStorageClient} (browser) or\n * {@link setLocaleInStorageServer} (server) instead.\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n options?: LocaleStorageOptions\n): void => {\n const { routing } = configuration;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n\n if (options?.setLocaleStorage) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {\n if (options.getLocaleStorage(name)) continue;\n }\n options.setLocaleStorage(name, locale);\n } catch {}\n }\n }\n\n if (options?.setSessionStorage) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getSessionStorage) {\n if (options.getSessionStorage(name)) continue;\n }\n options.setSessionStorage(name, locale);\n } catch {}\n }\n }\n\n if (options?.setHeader) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n try {\n options.setHeader(storageAttributes.headers[i].name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Utility object to get and set the locale in storage based on configuration.\n *\n * @deprecated Use {@link LocaleStorageClient} (browser) or\n * {@link LocaleStorageServer} (server) instead.\n */\nexport const LocaleStorage = (options: LocaleStorageOptions) => ({\n getLocale: () => getLocaleFromStorage(options),\n setLocale: (locale: LocalesValues) => setLocaleInStorage(locale, options),\n});\n"],"mappings":";;;;AAwBA,MAAM,qBACJ,MACA,OACA,eACW;CAEX,MAAM,QAAkB,CAAC,GAAG,KAAK,GADZ,mBAAmB,MAAM,GACK;AAEnD,KAAI,WAAW,KAAM,OAAM,KAAK,QAAQ,WAAW,OAAO;AAC1D,KAAI,WAAW,OAAQ,OAAM,KAAK,UAAU,WAAW,SAAS;AAChE,KAAI,WAAW,mBAAmB,KAChC,OAAM,KAAK,WAAW,WAAW,QAAQ,aAAa,GAAG;AAC3D,KAAI,WAAW,OAAQ,OAAM,KAAK,SAAS;AAC3C,KAAI,WAAW,SAAU,OAAM,KAAK,YAAY,WAAW,WAAW;AACtE,QAAO,MAAM,KAAK,KAAK;;;;;;;AA6BzB,MAAa,8BACX,YACuB;CACvB,MAAM,EAAE,SAAS,yBAAyB;CAC1C,MAAM,EAAE,YAAY;CACpB,MAAM,oBAAoB,QAAQ;AAElC,KAAI,SAAS,oBAAoB,MAAO,QAAO;CAE/C,MAAM,iBAAiB,UACrB,CAAC,CAAC,SAAS,QAAQ,SAAS,MAAgB;AAE9C,MAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,QAAQ,QAAQ,IACpD,KAAI;EACF,MAAM,QAAQ,SAAS,YAAY,kBAAkB,QAAQ,GAAG,KAAK;AACrE,MAAI,cAAc,MAAM,CAAE,QAAO;SAC3B;AAGV,MAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,aAAa,QAAQ,IACzD,KAAI;EACF,MAAM,QAAQ,SAAS,mBAC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,qBAAqB,QAAQ;CAC9C,YAAY,WAA0B,mBAAmB,QAAQ,QAAQ;CAC1E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeProps, Plugins } from "../interpreter/getContent/plugins.js";
|
|
2
|
-
import * as _intlayer_types_dictionary0 from "@intlayer/types/dictionary";
|
|
2
|
+
import * as _$_intlayer_types_dictionary0 from "@intlayer/types/dictionary";
|
|
3
3
|
import { ContentNode, Dictionary } from "@intlayer/types/dictionary";
|
|
4
4
|
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
5
5
|
|
|
@@ -24,12 +24,12 @@ declare const getFilterMissingTranslationsContent: <T extends ContentNode, L ext
|
|
|
24
24
|
declare const getFilterMissingTranslationsDictionary: (dictionary: Dictionary, localeToCheck: LocalesValues) => {
|
|
25
25
|
content: any;
|
|
26
26
|
$schema?: "https://intlayer.org/schema.json";
|
|
27
|
-
id?: _intlayer_types_dictionary0.DictionaryId;
|
|
27
|
+
id?: _$_intlayer_types_dictionary0.DictionaryId;
|
|
28
28
|
projectIds?: string[];
|
|
29
|
-
localId?: _intlayer_types_dictionary0.LocalDictionaryId;
|
|
30
|
-
localIds?: _intlayer_types_dictionary0.LocalDictionaryId[];
|
|
31
|
-
format?: _intlayer_types_dictionary0.DictionaryFormat;
|
|
32
|
-
key: _intlayer_types_dictionary0.DictionaryKey;
|
|
29
|
+
localId?: _$_intlayer_types_dictionary0.LocalDictionaryId;
|
|
30
|
+
localIds?: _$_intlayer_types_dictionary0.LocalDictionaryId[];
|
|
31
|
+
format?: _$_intlayer_types_dictionary0.DictionaryFormat;
|
|
32
|
+
key: _$_intlayer_types_dictionary0.DictionaryKey;
|
|
33
33
|
title?: string;
|
|
34
34
|
description?: string;
|
|
35
35
|
versions?: string[];
|
|
@@ -37,12 +37,12 @@ declare const getFilterMissingTranslationsDictionary: (dictionary: Dictionary, l
|
|
|
37
37
|
filePath?: string;
|
|
38
38
|
tags?: string[];
|
|
39
39
|
locale?: LocalesValues;
|
|
40
|
-
contentAutoTransformation?: _intlayer_types_dictionary0.ContentAutoTransformation;
|
|
41
|
-
fill?: _intlayer_types_dictionary0.Fill;
|
|
40
|
+
contentAutoTransformation?: _$_intlayer_types_dictionary0.ContentAutoTransformation;
|
|
41
|
+
fill?: _$_intlayer_types_dictionary0.Fill;
|
|
42
42
|
filled?: true;
|
|
43
43
|
priority?: number;
|
|
44
|
-
importMode?: _intlayer_types_dictionary0.ImportMode;
|
|
45
|
-
location?: _intlayer_types_dictionary0.DictionaryLocation;
|
|
44
|
+
importMode?: _$_intlayer_types_dictionary0.ImportMode;
|
|
45
|
+
location?: _$_intlayer_types_dictionary0.DictionaryLocation;
|
|
46
46
|
schema: undefined;
|
|
47
47
|
};
|
|
48
48
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFilterMissingTranslationsContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getFilterMissingTranslationsContent.ts"],"mappings":";;;;;;;cAoMa,mCAAA,GACX,aAAA,EAAe,aAAA,KACd,OAAA;;;AAFH;;;;;;;;;AA8LA;;;cAAa,mCAAA,aACD,WAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,IAAA,EAAM,CAAA,EACN,aAAA,EAAe,CAAA,EACf,SAAA,EAAW,SAAA;AAAA,cAoBA,sCAAA,GACX,UAAA,EAAY,UAAA,EACZ,aAAA,EAAe,aAAA;;;OAAa,
|
|
1
|
+
{"version":3,"file":"getFilterMissingTranslationsContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getFilterMissingTranslationsContent.ts"],"mappings":";;;;;;;cAoMa,mCAAA,GACX,aAAA,EAAe,aAAA,KACd,OAAA;;;AAFH;;;;;;;;;AA8LA;;;cAAa,mCAAA,aACD,WAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,IAAA,EAAM,CAAA,EACN,aAAA,EAAe,CAAA,EACf,SAAA,EAAW,SAAA;AAAA,cAoBA,sCAAA,GACX,UAAA,EAAY,UAAA,EACZ,aAAA,EAAe,aAAA;;;OAAa,6BAAA,CAAA,YAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeepTransformContent, NodeProps, Plugins } from "../interpreter/getContent/plugins.js";
|
|
2
|
-
import * as _intlayer_types_dictionary0 from "@intlayer/types/dictionary";
|
|
2
|
+
import * as _$_intlayer_types_dictionary0 from "@intlayer/types/dictionary";
|
|
3
3
|
import { ContentNode, Dictionary } from "@intlayer/types/dictionary";
|
|
4
4
|
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
5
5
|
|
|
@@ -16,12 +16,12 @@ 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?: "https://intlayer.org/schema.json";
|
|
19
|
-
id?: _intlayer_types_dictionary0.DictionaryId;
|
|
19
|
+
id?: _$_intlayer_types_dictionary0.DictionaryId;
|
|
20
20
|
projectIds?: string[];
|
|
21
|
-
localId?: _intlayer_types_dictionary0.LocalDictionaryId;
|
|
22
|
-
localIds?: _intlayer_types_dictionary0.LocalDictionaryId[];
|
|
23
|
-
format?: _intlayer_types_dictionary0.DictionaryFormat;
|
|
24
|
-
key: _intlayer_types_dictionary0.DictionaryKey;
|
|
21
|
+
localId?: _$_intlayer_types_dictionary0.LocalDictionaryId;
|
|
22
|
+
localIds?: _$_intlayer_types_dictionary0.LocalDictionaryId[];
|
|
23
|
+
format?: _$_intlayer_types_dictionary0.DictionaryFormat;
|
|
24
|
+
key: _$_intlayer_types_dictionary0.DictionaryKey;
|
|
25
25
|
title?: string;
|
|
26
26
|
description?: string;
|
|
27
27
|
versions?: string[];
|
|
@@ -29,12 +29,12 @@ declare const getFilterTranslationsOnlyDictionary: (dictionary: Dictionary, loca
|
|
|
29
29
|
filePath?: string;
|
|
30
30
|
tags?: string[];
|
|
31
31
|
locale?: LocalesValues;
|
|
32
|
-
contentAutoTransformation?: _intlayer_types_dictionary0.ContentAutoTransformation;
|
|
33
|
-
fill?: _intlayer_types_dictionary0.Fill;
|
|
32
|
+
contentAutoTransformation?: _$_intlayer_types_dictionary0.ContentAutoTransformation;
|
|
33
|
+
fill?: _$_intlayer_types_dictionary0.Fill;
|
|
34
34
|
filled?: true;
|
|
35
35
|
priority?: number;
|
|
36
|
-
importMode?: _intlayer_types_dictionary0.ImportMode;
|
|
37
|
-
location?: _intlayer_types_dictionary0.DictionaryLocation;
|
|
36
|
+
importMode?: _$_intlayer_types_dictionary0.ImportMode;
|
|
37
|
+
location?: _$_intlayer_types_dictionary0.DictionaryLocation;
|
|
38
38
|
schema: undefined;
|
|
39
39
|
};
|
|
40
40
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFilterTranslationsOnlyContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getFilterTranslationsOnlyContent.ts"],"mappings":";;;;;;;cAqCa,4BAAA,GACX,MAAA,EAAQ,aAAA,EACR,QAAA,GAAW,aAAA,KACV,OAAA;;;AAHH;;;;cAuFa,gCAAA,aACD,WAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,IAAA,EAAM,CAAA,EACN,MAAA,EAAQ,CAAA,EACR,SAAA,EAAW,SAAA,EACX,QAAA,GAAW,aAAA,KAUL,oBAAA,CAAqB,CAAA;AAAA,cAGhB,mCAAA,GACX,UAAA,EAAY,UAAA,EACZ,MAAA,GAAQ,aAAA,EAER,QAAA,GAAW,aAAA;;;OAAa,
|
|
1
|
+
{"version":3,"file":"getFilterTranslationsOnlyContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getFilterTranslationsOnlyContent.ts"],"mappings":";;;;;;;cAqCa,4BAAA,GACX,MAAA,EAAQ,aAAA,EACR,QAAA,GAAW,aAAA,KACV,OAAA;;;AAHH;;;;cAuFa,gCAAA,aACD,WAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,IAAA,EAAM,CAAA,EACN,MAAA,EAAQ,CAAA,EACR,SAAA,EAAW,SAAA,EACX,QAAA,GAAW,aAAA,KAUL,oBAAA,CAAqB,CAAA;AAAA,cAGhB,mCAAA,GACX,UAAA,EAAY,UAAA,EACZ,MAAA,GAAQ,aAAA,EAER,QAAA,GAAW,aAAA;;;OAAa,6BAAA,CAAA,YAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeProps } from "../interpreter/getContent/plugins.js";
|
|
2
|
-
import * as _intlayer_types_dictionary0 from "@intlayer/types/dictionary";
|
|
2
|
+
import * as _$_intlayer_types_dictionary0 from "@intlayer/types/dictionary";
|
|
3
3
|
import { ContentNode, Dictionary } from "@intlayer/types/dictionary";
|
|
4
4
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
5
5
|
|
|
@@ -8,12 +8,12 @@ declare const getFilteredLocalesContent: (node: ContentNode, locales: LocalesVal
|
|
|
8
8
|
declare const getFilteredLocalesDictionary: (dictionary: Dictionary, locale: LocalesValues | LocalesValues[]) => {
|
|
9
9
|
content: any;
|
|
10
10
|
$schema?: "https://intlayer.org/schema.json";
|
|
11
|
-
id?: _intlayer_types_dictionary0.DictionaryId;
|
|
11
|
+
id?: _$_intlayer_types_dictionary0.DictionaryId;
|
|
12
12
|
projectIds?: string[];
|
|
13
|
-
localId?: _intlayer_types_dictionary0.LocalDictionaryId;
|
|
14
|
-
localIds?: _intlayer_types_dictionary0.LocalDictionaryId[];
|
|
15
|
-
format?: _intlayer_types_dictionary0.DictionaryFormat;
|
|
16
|
-
key: _intlayer_types_dictionary0.DictionaryKey;
|
|
13
|
+
localId?: _$_intlayer_types_dictionary0.LocalDictionaryId;
|
|
14
|
+
localIds?: _$_intlayer_types_dictionary0.LocalDictionaryId[];
|
|
15
|
+
format?: _$_intlayer_types_dictionary0.DictionaryFormat;
|
|
16
|
+
key: _$_intlayer_types_dictionary0.DictionaryKey;
|
|
17
17
|
title?: string;
|
|
18
18
|
description?: string;
|
|
19
19
|
versions?: string[];
|
|
@@ -21,12 +21,12 @@ declare const getFilteredLocalesDictionary: (dictionary: Dictionary, locale: Loc
|
|
|
21
21
|
filePath?: string;
|
|
22
22
|
tags?: string[];
|
|
23
23
|
locale?: LocalesValues;
|
|
24
|
-
contentAutoTransformation?: _intlayer_types_dictionary0.ContentAutoTransformation;
|
|
25
|
-
fill?: _intlayer_types_dictionary0.Fill;
|
|
24
|
+
contentAutoTransformation?: _$_intlayer_types_dictionary0.ContentAutoTransformation;
|
|
25
|
+
fill?: _$_intlayer_types_dictionary0.Fill;
|
|
26
26
|
filled?: true;
|
|
27
27
|
priority?: number;
|
|
28
|
-
importMode?: _intlayer_types_dictionary0.ImportMode;
|
|
29
|
-
location?: _intlayer_types_dictionary0.DictionaryLocation;
|
|
28
|
+
importMode?: _$_intlayer_types_dictionary0.ImportMode;
|
|
29
|
+
location?: _$_intlayer_types_dictionary0.DictionaryLocation;
|
|
30
30
|
schema: undefined;
|
|
31
31
|
};
|
|
32
32
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFilteredLocalesContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getFilteredLocalesContent.ts"],"mappings":";;;;;;cAuCa,yBAAA,GACX,IAAA,EAAM,WAAA,EACN,OAAA,EAAS,aAAA,GAAgB,aAAA,IACzB,SAAA,EAAW,SAAA;AAAA,cAwBA,4BAAA,GACX,UAAA,EAAY,UAAA,EACZ,MAAA,EAAQ,aAAA,GAAgB,aAAA;;;OAAa,
|
|
1
|
+
{"version":3,"file":"getFilteredLocalesContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getFilteredLocalesContent.ts"],"mappings":";;;;;;cAuCa,yBAAA,GACX,IAAA,EAAM,WAAA,EACN,OAAA,EAAS,aAAA,GAAgB,aAAA,IACzB,SAAA,EAAW,SAAA;AAAA,cAwBA,4BAAA,GACX,UAAA,EAAY,UAAA,EACZ,MAAA,EAAQ,aAAA,GAAgB,aAAA;;;OAAa,6BAAA,CAAA,YAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
2
|
-
import * as _intlayer_types_config0 from "@intlayer/types/config";
|
|
2
|
+
import * as _$_intlayer_types_config0 from "@intlayer/types/config";
|
|
3
3
|
|
|
4
4
|
//#region src/dictionaryManipulator/orderDictionaries.d.ts
|
|
5
5
|
/**
|
|
@@ -9,7 +9,7 @@ import * as _intlayer_types_config0 from "@intlayer/types/config";
|
|
|
9
9
|
* @param priorityStrategy - The priority strategy ('local_first' or 'distant_first')
|
|
10
10
|
* @returns Ordered array of dictionaries
|
|
11
11
|
*/
|
|
12
|
-
declare const orderDictionaries: (dictionaries: Dictionary[], configuration?: _intlayer_types_config0.IntlayerConfig) => Dictionary[];
|
|
12
|
+
declare const orderDictionaries: (dictionaries: Dictionary[], configuration?: _$_intlayer_types_config0.IntlayerConfig) => Dictionary[];
|
|
13
13
|
//#endregion
|
|
14
14
|
export { orderDictionaries };
|
|
15
15
|
//# sourceMappingURL=orderDictionaries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderDictionaries.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/orderDictionaries.ts"],"mappings":";;;;;;;AAUA;;;;cAAa,iBAAA,GACX,YAAA,EAAc,UAAA,IACd,aAAA,GADwB,
|
|
1
|
+
{"version":3,"file":"orderDictionaries.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/orderDictionaries.ts"],"mappings":";;;;;;;AAUA;;;;cAAa,iBAAA,GACX,YAAA,EAAc,UAAA,IACd,aAAA,GADwB,yBAAA,CACxB,cAAA,KACC,UAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { compact } from "./compact.js";
|
|
2
2
|
import { currency } from "./currency.js";
|
|
3
3
|
import { DateTimePreset, date, presets } from "./date.js";
|
|
4
|
-
import { CachedIntl, WrappedIntl, bindIntl,
|
|
4
|
+
import { CachedIntl, WrappedIntl, bindIntl, getCachedIntl } from "../utils/intl.js";
|
|
5
5
|
import { list } from "./list.js";
|
|
6
6
|
import { number } from "./number.js";
|
|
7
7
|
import { percentage } from "./percentage.js";
|
|
8
8
|
import { relativeTime } from "./relativeTime.js";
|
|
9
9
|
import { units } from "./units.js";
|
|
10
|
-
export { CachedIntl, CachedIntl as Intl, DateTimePreset, WrappedIntl, bindIntl, compact,
|
|
10
|
+
export { CachedIntl, CachedIntl as Intl, DateTimePreset, WrappedIntl, bindIntl, compact, currency, date, getCachedIntl, list, number, percentage, presets, relativeTime, units };
|
|
@@ -10,7 +10,10 @@ import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
|
10
10
|
* @example
|
|
11
11
|
* number("1000000", { locale: Locales.FRENCH }); // "1 000 000"
|
|
12
12
|
*/
|
|
13
|
-
declare const number: (value: string | number,
|
|
13
|
+
declare const number: (value: string | number, {
|
|
14
|
+
locale,
|
|
15
|
+
...options
|
|
16
|
+
}?: Intl.NumberFormatOptions & {
|
|
14
17
|
locale?: LocalesValues;
|
|
15
18
|
}) => string;
|
|
16
19
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","names":[],"sources":["../../../src/formatters/number.ts"],"mappings":";;;;;AAaA;;;;;;;cAAa,MAAA,GACX,KAAA,
|
|
1
|
+
{"version":3,"file":"number.d.ts","names":[],"sources":["../../../src/formatters/number.ts"],"mappings":";;;;;AAaA;;;;;;;cAAa,MAAA,GACX,KAAA;EACA,MAAA;EAAA,GAAA;AAAA,IAGG,IAAA,CAAK,mBAAA;EAAwB,MAAA,GAAS,aAAA;AAAA"}
|
|
@@ -10,7 +10,10 @@ import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
|
10
10
|
* @example
|
|
11
11
|
* percentage(0.25, { minimumFractionDigits: 2 }); // "25.00%"
|
|
12
12
|
*/
|
|
13
|
-
declare const percentage: (value: string | number,
|
|
13
|
+
declare const percentage: (value: string | number, {
|
|
14
|
+
locale,
|
|
15
|
+
...options
|
|
16
|
+
}?: Intl.NumberFormatOptions & {
|
|
14
17
|
locale?: LocalesValues;
|
|
15
18
|
}) => string;
|
|
16
19
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"percentage.d.ts","names":[],"sources":["../../../src/formatters/percentage.ts"],"mappings":";;;;;AAaA;;;;;;;cAAa,UAAA,GACX,KAAA,
|
|
1
|
+
{"version":3,"file":"percentage.d.ts","names":[],"sources":["../../../src/formatters/percentage.ts"],"mappings":";;;;;AAaA;;;;;;;cAAa,UAAA,GACX,KAAA;EACA,MAAA;EAAA,GAAA;AAAA,IAGG,IAAA,CAAK,mBAAA;EAAwB,MAAA,GAAS,aAAA;AAAA"}
|