@inlang/paraglide-js 2.13.1 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler/compile-bundle.js +2 -2
- package/dist/compiler/compile-bundle.test.js +1 -1
- package/dist/compiler/compile-local-variable.d.ts.map +1 -1
- package/dist/compiler/compile-local-variable.js +48 -4
- package/dist/compiler/compile-local-variable.js.map +1 -1
- package/dist/compiler/compile-local-variable.test.js +76 -0
- package/dist/compiler/compile-local-variable.test.js.map +1 -1
- package/dist/compiler/compile-project.test.js +83 -0
- package/dist/compiler/compile-project.test.js.map +1 -1
- package/dist/compiler/compile.test.js +31 -0
- package/dist/compiler/compile.test.js.map +1 -1
- package/dist/compiler/compiler-options.d.ts +8 -6
- package/dist/compiler/compiler-options.d.ts.map +1 -1
- package/dist/compiler/runtime/assert-is-locale.d.ts +2 -2
- package/dist/compiler/runtime/assert-is-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/assert-is-locale.js +1 -1
- package/dist/compiler/runtime/assert-is-locale.test.js +1 -2
- package/dist/compiler/runtime/assert-is-locale.test.js.map +1 -1
- package/dist/compiler/runtime/create-runtime.d.ts.map +1 -1
- package/dist/compiler/runtime/create-runtime.js +8 -122
- package/dist/compiler/runtime/create-runtime.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts +2 -2
- package/dist/compiler/runtime/extract-locale-from-cookie.js +1 -1
- package/dist/compiler/runtime/extract-locale-from-header.d.ts +13 -1
- package/dist/compiler/runtime/extract-locale-from-header.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-header.js +1 -2
- package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-navigator.d.ts +11 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-navigator.js +1 -2
- package/dist/compiler/runtime/extract-locale-from-navigator.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request-async.d.ts +1 -30
- package/dist/compiler/runtime/extract-locale-from-request-async.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request-async.js +2 -1
- package/dist/compiler/runtime/extract-locale-from-request-async.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request.d.ts +1 -19
- package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request.js +2 -1
- package/dist/compiler/runtime/extract-locale-from-request.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-url.js +2 -2
- package/dist/compiler/runtime/generate-static-localized-urls.d.ts.map +1 -1
- package/dist/compiler/runtime/generate-static-localized-urls.js +1 -0
- package/dist/compiler/runtime/generate-static-localized-urls.js.map +1 -1
- package/dist/compiler/runtime/get-locale.d.ts +2 -35
- package/dist/compiler/runtime/get-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/get-locale.js +3 -3
- package/dist/compiler/runtime/get-url-origin.d.ts +1 -9
- package/dist/compiler/runtime/get-url-origin.d.ts.map +1 -1
- package/dist/compiler/runtime/get-url-origin.js +1 -1
- package/dist/compiler/runtime/is-locale.d.ts +3 -2
- package/dist/compiler/runtime/is-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/is-locale.js +2 -1
- package/dist/compiler/runtime/is-locale.js.map +1 -1
- package/dist/compiler/runtime/localize-url.d.ts +7 -0
- package/dist/compiler/runtime/localize-url.d.ts.map +1 -1
- package/dist/compiler/runtime/localize-url.js +2 -1
- package/dist/compiler/runtime/localize-url.js.map +1 -1
- package/dist/compiler/runtime/set-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/set-locale.js +1 -2
- package/dist/compiler/runtime/set-locale.js.map +1 -1
- package/dist/compiler/runtime/should-redirect.d.ts +2 -2
- package/dist/compiler/runtime/should-redirect.d.ts.map +1 -1
- package/dist/compiler/runtime/strategy.d.ts +6 -6
- package/dist/compiler/runtime/strategy.d.ts.map +1 -1
- package/dist/compiler/runtime/strategy.js +3 -3
- package/dist/compiler/runtime/type-definitions.d.ts +97 -0
- package/dist/compiler/runtime/type-definitions.d.ts.map +1 -0
- package/dist/compiler/runtime/type-definitions.js +150 -0
- package/dist/compiler/runtime/type-definitions.js.map +1 -0
- package/dist/compiler/runtime/variables.d.ts +2 -2
- package/dist/compiler/runtime/variables.d.ts.map +1 -1
- package/dist/compiler/runtime/variables.js +2 -2
- package/dist/compiler/runtime/variables.js.map +1 -1
- package/dist/compiler/server/create-server-file.d.ts.map +1 -1
- package/dist/compiler/server/create-server-file.js.map +1 -1
- package/dist/compiler/server/middleware.d.ts +6 -17
- package/dist/compiler/server/middleware.d.ts.map +1 -1
- package/dist/compiler/server/middleware.js +11 -20
- package/dist/compiler/server/middleware.js.map +1 -1
- package/dist/compiler/types.d.ts +1 -77
- package/dist/compiler/types.d.ts.map +1 -1
- package/dist/services/env-variables/create-index-file.js +0 -1
- package/dist/services/env-variables/create-index-file.js.map +1 -1
- package/dist/services/env-variables/index.d.ts +0 -1
- package/dist/services/env-variables/index.d.ts.map +1 -1
- package/dist/services/env-variables/index.js +1 -2
- package/dist/services/env-variables/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/services/telemetry/capture.d.ts +0 -15
- package/dist/services/telemetry/capture.d.ts.map +0 -1
- package/dist/services/telemetry/capture.js +0 -72
- package/dist/services/telemetry/capture.js.map +0 -1
- package/dist/services/telemetry/capture.test.d.ts +0 -2
- package/dist/services/telemetry/capture.test.d.ts.map +0 -1
- package/dist/services/telemetry/capture.test.js +0 -41
- package/dist/services/telemetry/capture.test.js.map +0 -1
- package/dist/services/telemetry/stack-detection.d.ts +0 -40
- package/dist/services/telemetry/stack-detection.d.ts.map +0 -1
- package/dist/services/telemetry/stack-detection.js +0 -78
- package/dist/services/telemetry/stack-detection.js.map +0 -1
- package/dist/services/telemetry/stack-detection.test.d.ts +0 -2
- package/dist/services/telemetry/stack-detection.test.d.ts.map +0 -1
- package/dist/services/telemetry/stack-detection.test.js +0 -37
- package/dist/services/telemetry/stack-detection.test.js.map +0 -1
|
@@ -2,7 +2,7 @@ import { locales } from "./variables.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Asserts that the input is a locale.
|
|
4
4
|
*
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {unknown} input - The input to check.
|
|
6
6
|
* @returns {Locale} The input if it is a locale.
|
|
7
7
|
* @throws {Error} If the input is not a locale.
|
|
8
8
|
*/
|
|
@@ -48,8 +48,7 @@ test("the return value is a Locale", async () => {
|
|
|
48
48
|
}),
|
|
49
49
|
});
|
|
50
50
|
const locale = runtime.assertIsLocale("en");
|
|
51
|
-
// a bit of a wacky test given that locale is `
|
|
52
|
-
// in the ambient type definition
|
|
51
|
+
// a bit of a wacky test given that locale is `string`
|
|
53
52
|
locale;
|
|
54
53
|
});
|
|
55
54
|
test("is case-insensitive", async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-is-locale.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/assert-is-locale.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"assert-is-locale.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/assert-is-locale.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,IAAI,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;IACxD,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,IAAI,EAAE,MAAM,UAAU,CAAC;YACtB,QAAQ,E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AC;CACF,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"create-runtime.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/create-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE;QAChB,QAAQ,EAAE,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;QACnD,eAAe,CAAC,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAC;QACrD,UAAU,EAAE,WAAW,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;QACvD,YAAY,EAAE,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,CAAC;QAC3D,YAAY,EAAE,eAAe,CAAC,cAAc,CAAC,CAAC;QAC9C,WAAW,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;QAC7C,qCAAqC,EAAE,eAAe,CAAC,uCAAuC,CAAC,CAAC;QAChG,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;QACtC,wBAAwB,CAAC,EAAE,eAAe,CAAC,0BAA0B,CAAC,CAAC;QACvE,eAAe,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAC;QACpD,wBAAwB,EAAE,WAAW,CACpC,eAAe,CAAC,0BAA0B,CAAC,CAC3C,CAAC;KACF,CAAC;CACF,GAAG,MAAM,CA6JT"}
|
|
@@ -38,7 +38,7 @@ ${needsUrlPatternPolyfill ? `import "@inlang/paraglide-js/urlpattern-polyfill";`
|
|
|
38
38
|
|
|
39
39
|
${injectCode("./variables.js")
|
|
40
40
|
.replace(`export const baseLocale = "en";`, `export const baseLocale = "${args.baseLocale}";`)
|
|
41
|
-
.replace(`export const locales = /** @type {
|
|
41
|
+
.replace(`export const locales = /** @type {readonly string[]} */ (["en", "de"]);`, `export const locales = /** @type {const} */ (${JSON.stringify(args.locales)});`)
|
|
42
42
|
.replace(`export const strategy = ["globalVariable"];`, `export const strategy = ${JSON.stringify(args.compilerOptions.strategy, null, 2)};`)
|
|
43
43
|
.replace(`<cookie-name>`, `${args.compilerOptions.cookieName}`)
|
|
44
44
|
.replace(`60 * 60 * 24 * 400`, `${args.compilerOptions.cookieMaxAge}`)
|
|
@@ -57,7 +57,10 @@ ${injectCode("./variables.js")
|
|
|
57
57
|
.replace(`export const localStorageKey = "PARAGLIDE_LOCALE";`, `export const localStorageKey = "${args.compilerOptions.localStorageKey}";`)
|
|
58
58
|
.replace(`export const TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;`, `const TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = ${allUsedStrategies.has("localStorage")};`)}
|
|
59
59
|
|
|
60
|
-
globalThis.__paraglide =
|
|
60
|
+
/** @type {any} */ (globalThis).__paraglide =
|
|
61
|
+
/** @type {any} */ (globalThis).__paraglide ?? {};
|
|
62
|
+
/** @type {any} */ (globalThis).__paraglide.ssr =
|
|
63
|
+
/** @type {any} */ (globalThis).__paraglide.ssr ?? {};
|
|
61
64
|
|
|
62
65
|
${injectCode("./get-locale.js")}
|
|
63
66
|
|
|
@@ -95,126 +98,7 @@ ${injectCode("./generate-static-localized-urls.js")}
|
|
|
95
98
|
|
|
96
99
|
${injectCode("./strategy.js")}
|
|
97
100
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* A locale that is available in the project.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* setLocale(request.locale as Locale)
|
|
105
|
-
*
|
|
106
|
-
* @typedef {(typeof locales)[number]} Locale
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* A branded type representing a localized string.
|
|
111
|
-
*
|
|
112
|
-
* Message functions return this type instead of \`string\`, enabling TypeScript
|
|
113
|
-
* to distinguish translated strings from regular strings at compile time.
|
|
114
|
-
* This allows you to enforce that only properly localized content is used
|
|
115
|
-
* in your UI components.
|
|
116
|
-
*
|
|
117
|
-
* Since \`LocalizedString\` is a branded subtype of \`string\`, it remains fully
|
|
118
|
-
* backward compatible—you can pass it anywhere a \`string\` is expected.
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* // Enforce localized strings in your components
|
|
122
|
-
* function PageTitle(props: { title: LocalizedString }) {
|
|
123
|
-
* return <h1>{props.title}</h1>
|
|
124
|
-
* }
|
|
125
|
-
*
|
|
126
|
-
* // ✅ Correct: using a message function
|
|
127
|
-
* <PageTitle title={m.welcome_title()} />
|
|
128
|
-
*
|
|
129
|
-
* // ❌ Type error: raw strings are not LocalizedString
|
|
130
|
-
* <PageTitle title="Welcome" />
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* // LocalizedString is assignable to string (backward compatible)
|
|
134
|
-
* const localized: LocalizedString = m.greeting()
|
|
135
|
-
* const str: string = localized // ✅ works fine
|
|
136
|
-
*
|
|
137
|
-
* // But string is not assignable to LocalizedString
|
|
138
|
-
* const raw: LocalizedString = "Hello" // ❌ Type error
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* // Catches accidental string concatenation
|
|
142
|
-
* function showMessage(msg: LocalizedString) { ... }
|
|
143
|
-
*
|
|
144
|
-
* showMessage(m.hello()) // ✅
|
|
145
|
-
* showMessage("Hello " + userName) // ❌ Type error
|
|
146
|
-
* showMessage(m.hello_user({ name: userName })) // ✅ use params instead
|
|
147
|
-
*
|
|
148
|
-
* @typedef {string & { readonly __brand: 'LocalizedString' }} LocalizedString
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Record of markup options for a tag instance.
|
|
153
|
-
*
|
|
154
|
-
* @typedef {Record<string, unknown>} MessageMarkupOptions
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Record of markup attributes for a tag instance.
|
|
159
|
-
*
|
|
160
|
-
* @typedef {Record<string, string | true>} MessageMarkupAttributes
|
|
161
|
-
*/
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Type-level schema for a single markup tag.
|
|
165
|
-
*
|
|
166
|
-
* @typedef {{
|
|
167
|
-
* options: MessageMarkupOptions;
|
|
168
|
-
* attributes: MessageMarkupAttributes;
|
|
169
|
-
* children: boolean;
|
|
170
|
-
* }} MessageMarkupTag
|
|
171
|
-
*/
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Type-level schema for all markup tags in a message.
|
|
175
|
-
*
|
|
176
|
-
* @typedef {Record<string, MessageMarkupTag>} MessageMarkupSchema
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Type-only metadata attached to compiled message functions.
|
|
181
|
-
*
|
|
182
|
-
* @template Inputs
|
|
183
|
-
* @template Options
|
|
184
|
-
* @template {MessageMarkupSchema} Markup
|
|
185
|
-
* @typedef {{
|
|
186
|
-
* readonly __paraglide?: {
|
|
187
|
-
* inputs: Inputs;
|
|
188
|
-
* options: Options;
|
|
189
|
-
* markup: Markup;
|
|
190
|
-
* };
|
|
191
|
-
* }} MessageMetadata
|
|
192
|
-
*/
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* A compiled, framework-neutral message part.
|
|
196
|
-
*
|
|
197
|
-
* @typedef {{
|
|
198
|
-
* type: "text";
|
|
199
|
-
* value: string;
|
|
200
|
-
* } | {
|
|
201
|
-
* type: "markup-start";
|
|
202
|
-
* name: string;
|
|
203
|
-
* options: MessageMarkupOptions;
|
|
204
|
-
* attributes: MessageMarkupAttributes;
|
|
205
|
-
* } | {
|
|
206
|
-
* type: "markup-end";
|
|
207
|
-
* name: string;
|
|
208
|
-
* options: MessageMarkupOptions;
|
|
209
|
-
* attributes: MessageMarkupAttributes;
|
|
210
|
-
* } | {
|
|
211
|
-
* type: "markup-standalone";
|
|
212
|
-
* name: string;
|
|
213
|
-
* options: MessageMarkupOptions;
|
|
214
|
-
* attributes: MessageMarkupAttributes;
|
|
215
|
-
* }} MessagePart
|
|
216
|
-
*/
|
|
217
|
-
|
|
101
|
+
${injectCode("./type-definitions.js").replace(`@typedef {string} Locale`, `@typedef {typeof locales[number]} Locale`)}
|
|
218
102
|
`;
|
|
219
103
|
return code;
|
|
220
104
|
}
|
|
@@ -230,10 +114,12 @@ ${injectCode("./strategy.js")}
|
|
|
230
114
|
function injectCode(path) {
|
|
231
115
|
const code = fs.readFileSync(new URL(path, import.meta.url), "utf-8");
|
|
232
116
|
// Regex to match single-line and multi-line imports
|
|
117
|
+
const importJsdocRegex = /\/\*\*(?:(?!\*\/)[\s\S])*?@import\b[\s\S]*?\*\//g;
|
|
233
118
|
const importRegex = /import\s+[\s\S]*?from\s+['"][^'"]+['"]\s*;?/g;
|
|
234
119
|
const sourceMapRegex = /\/\/# sourceMappingURL=.*$/gm;
|
|
235
120
|
const blockSourceMapRegex = /\/\*# sourceMappingURL=.*?\*\//g;
|
|
236
121
|
return code
|
|
122
|
+
.replace(importJsdocRegex, "")
|
|
237
123
|
.replace(importRegex, "")
|
|
238
124
|
.replace(sourceMapRegex, "")
|
|
239
125
|
.replace(blockSourceMapRegex, "")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-runtime.js","sourceRoot":"","sources":["../../../src/compiler/runtime/create-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAkBjC;IACA,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,IAAI,EAAE,CAAC;IAC3D,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,eAAe,IAAI,EAAE,CAAC;IAEnE,IAAI,qBAAqB,GAAG,KAAK,CAAC;IAElC,+DAA+D;IAC/D,IAAI,IAAI,CAAC,eAAe,CAAC,WAAW,KAAK,SAAS,EA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,UAAU,CAAC,eAAe,CAAC;;EAE3B,UAAU,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAC5C,0BAA0B,EAC1B,0CAA0C,CAC1C;CACA,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,UAAU,CAAC,IAAY;IAC/B,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;IACtE,oDAAoD;IACpD,MAAM,gBAAgB,GAAG,kDAAkD,CAAC;IAC5E,MAAM,WAAW,GAAG,8CAA8C,CAAC;IACnE,MAAM,cAAc,GAAG,8BAA8B,CAAC;IACtD,MAAM,mBAAmB,GAAG,iCAAiC,CAAC;IAC9D,OAAO,IAAI;SACT,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC;SAC7B,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;SACxB,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;SAChC,IAAI,EAAE,CAAC;AACV,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Will return undefined if the document is not available or if the cookie is not set.
|
|
5
5
|
* The `document` object is not available in server-side rendering, so this function should not be called in that context.
|
|
6
6
|
*
|
|
7
|
-
* @returns {
|
|
7
|
+
* @returns {Locale | undefined}
|
|
8
8
|
*/
|
|
9
|
-
export function extractLocaleFromCookie():
|
|
9
|
+
export function extractLocaleFromCookie(): Locale | undefined;
|
|
10
10
|
//# sourceMappingURL=extract-locale-from-cookie.d.ts.map
|
|
@@ -6,7 +6,7 @@ import { cookieName } from "./variables.js";
|
|
|
6
6
|
* Will return undefined if the document is not available or if the cookie is not set.
|
|
7
7
|
* The `document` object is not available in server-side rendering, so this function should not be called in that context.
|
|
8
8
|
*
|
|
9
|
-
* @returns {
|
|
9
|
+
* @returns {Locale | undefined}
|
|
10
10
|
*/
|
|
11
11
|
export function extractLocaleFromCookie() {
|
|
12
12
|
if (typeof document === "undefined" || !document.cookie) {
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Extracts a locale from the accept-language header.
|
|
3
|
+
*
|
|
4
|
+
* Use the function on the server to extract the locale
|
|
5
|
+
* from the accept-language header that is sent by the client.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const locale = extractLocaleFromHeader(request);
|
|
9
|
+
*
|
|
10
|
+
* @param {Request} request - The request object to extract the locale from.
|
|
11
|
+
* @returns {Locale | undefined} The negotiated preferred language.
|
|
12
|
+
*/
|
|
13
|
+
export function extractLocaleFromHeader(request: Request): Locale | undefined;
|
|
2
14
|
//# sourceMappingURL=extract-locale-from-header.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-locale-from-header.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-header.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extract-locale-from-header.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-header.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,iDAHW,OAAO,GACL,MAAM,GAAG,SAAS,CAgC9B"}
|
|
@@ -8,9 +8,8 @@ import { isLocale } from "./is-locale.js";
|
|
|
8
8
|
* @example
|
|
9
9
|
* const locale = extractLocaleFromHeader(request);
|
|
10
10
|
*
|
|
11
|
-
* @type {(request: Request) => Locale}
|
|
12
11
|
* @param {Request} request - The request object to extract the locale from.
|
|
13
|
-
* @returns {
|
|
12
|
+
* @returns {Locale | undefined} The negotiated preferred language.
|
|
14
13
|
*/
|
|
15
14
|
export function extractLocaleFromHeader(request) {
|
|
16
15
|
const acceptLanguageHeader = request.headers.get("accept-language");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-locale-from-header.js","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-header.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"extract-locale-from-header.js","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-header.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAO;IAC9C,MAAM,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACpE,IAAI,oBAAoB,EAAE,CAAC;QAC1B,yEAAyE;QACzE,MAAM,SAAS,GAAG,oBAAoB;aACpC,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACb,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAChD,+CAA+C;YAC/C,MAAM,OAAO,GAAG,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;YAClD,OAAO;gBACN,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE;gBAC3B,OAAO;gBACP,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;aACZ,CAAC;QACH,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5B,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC9B,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC5B,OAAO,IAAI,CAAC,OAAO,CAAC;YACrB,CAAC;iBAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnC,OAAO,IAAI,CAAC,OAAO,CAAC;YACrB,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC"}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Negotiates a preferred language from navigator.languages.
|
|
3
|
+
*
|
|
4
|
+
* Use the function on the client to extract the locale
|
|
5
|
+
* from the navigator.languages array.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const locale = extractLocaleFromNavigator();
|
|
9
|
+
*
|
|
10
|
+
* @returns {Locale | undefined}
|
|
11
|
+
*/
|
|
1
12
|
export function extractLocaleFromNavigator(): Locale | undefined;
|
|
2
13
|
//# sourceMappingURL=extract-locale-from-navigator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-locale-from-navigator.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-navigator.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extract-locale-from-navigator.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-navigator.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,8CAFa,MAAM,GAAG,SAAS,CAqB9B"}
|
|
@@ -8,8 +8,7 @@ import { isLocale } from "./is-locale.js";
|
|
|
8
8
|
* @example
|
|
9
9
|
* const locale = extractLocaleFromNavigator();
|
|
10
10
|
*
|
|
11
|
-
* @
|
|
12
|
-
* @returns {string | undefined}
|
|
11
|
+
* @returns {Locale | undefined}
|
|
13
12
|
*/
|
|
14
13
|
export function extractLocaleFromNavigator() {
|
|
15
14
|
if (!navigator?.languages?.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-locale-from-navigator.js","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-navigator.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"extract-locale-from-navigator.js","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-navigator.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,0BAA0B;IACzC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;QACnC,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACpD,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE;QAC3B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE;KAC1C,CAAC,CAAC,CAAC;IAEJ,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC9B,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,OAAO,CAAC;QACrB,CAAC;aAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,OAAO,CAAC;QACrB,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC"}
|
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Asynchronously extracts a locale from a request.
|
|
3
|
-
*
|
|
4
|
-
* This function supports async custom server strategies, unlike the synchronous
|
|
5
|
-
* `extractLocaleFromRequest`. Use this function when you have custom server strategies
|
|
6
|
-
* that need to perform asynchronous operations (like database calls) in their getLocale method.
|
|
7
|
-
*
|
|
8
|
-
* The function first processes any custom server strategies asynchronously, then falls back
|
|
9
|
-
* to the synchronous `extractLocaleFromRequest` for all other strategies.
|
|
10
|
-
*
|
|
11
|
-
* @see {@link https://github.com/opral/inlang-paraglide-js/issues/527#issuecomment-2978151022}
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // Basic usage
|
|
15
|
-
* const locale = await extractLocaleFromRequestAsync(request);
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* // With custom async server strategy
|
|
19
|
-
* defineCustomServerStrategy("custom-database", {
|
|
20
|
-
* getLocale: async (request) => {
|
|
21
|
-
* const userId = extractUserIdFromRequest(request);
|
|
22
|
-
* return await getUserLocaleFromDatabase(userId);
|
|
23
|
-
* }
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* const locale = await extractLocaleFromRequestAsync(request);
|
|
27
|
-
*
|
|
28
|
-
* @type {(request: Request) => Promise<Locale>}
|
|
29
|
-
*/
|
|
30
|
-
export const extractLocaleFromRequestAsync: (request: Request) => Promise<Locale>;
|
|
1
|
+
export function extractLocaleFromRequestAsync(request: Request): Promise<Locale>;
|
|
31
2
|
//# sourceMappingURL=extract-locale-from-request-async.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-locale-from-request-async.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-request-async.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extract-locale-from-request-async.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-request-async.js"],"names":[],"mappings":"AAoCO,uDAHI,OAAO,GACL,OAAO,CAAC,MAAM,CAAC,CA0B3B"}
|
|
@@ -30,7 +30,8 @@ import { extractLocaleFromRequestWithStrategies } from "./extract-locale-from-re
|
|
|
30
30
|
*
|
|
31
31
|
* const locale = await extractLocaleFromRequestAsync(request);
|
|
32
32
|
*
|
|
33
|
-
* @
|
|
33
|
+
* @param {Request} request - The request object to extract the locale from.
|
|
34
|
+
* @returns {Promise<Locale>} The extracted locale.
|
|
34
35
|
*/
|
|
35
36
|
export const extractLocaleFromRequestAsync = async (request) => {
|
|
36
37
|
/** @type {string|undefined} */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-locale-from-request-async.js","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-request-async.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,sCAAsC,EAAE,MAAM,kCAAkC,CAAC;AAE1F
|
|
1
|
+
{"version":3,"file":"extract-locale-from-request-async.js","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-request-async.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,sCAAsC,EAAE,MAAM,kCAAkC,CAAC;AAE1F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,KAAK,EAAE,OAAO,EAAE,EAAE;IAC9D,+BAA+B;IAC/B,IAAI,MAAM,CAAC;IACX,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAEhD,4CAA4C;IAC5C,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;QAC9B,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAClE,MAAM,OAAO,GAAG,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAClD,IAAI,OAAO,EAAE,CAAC;gBACb,+BAA+B;gBAC/B,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAC3C,CAAC;YAED,6DAA6D;YAC7D,IAAI,MAAM,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9C,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;YAC/B,CAAC;QACF,CAAC;IACF,CAAC;IAED,2EAA2E;IAC3E,MAAM,GAAG,sCAAsC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACnE,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC"}
|
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Extracts a locale from a request.
|
|
3
|
-
*
|
|
4
|
-
* Use the function on the server to extract the locale
|
|
5
|
-
* from a request.
|
|
6
|
-
*
|
|
7
|
-
* The function goes through the strategies in the order
|
|
8
|
-
* they are defined. If a strategy returns an invalid locale,
|
|
9
|
-
* it will fall back to the next strategy.
|
|
10
|
-
*
|
|
11
|
-
* Note: Custom server strategies are not supported in this synchronous version.
|
|
12
|
-
* Use `extractLocaleFromRequestAsync` if you need custom server strategies with async getLocale methods.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const locale = extractLocaleFromRequest(request);
|
|
16
|
-
*
|
|
17
|
-
* @type {(request: Request) => Locale}
|
|
18
|
-
*/
|
|
19
|
-
export const extractLocaleFromRequest: (request: Request) => Locale;
|
|
1
|
+
export function extractLocaleFromRequest(request: Request): Locale;
|
|
20
2
|
export function extractLocaleFromRequestWithStrategies(request: Request, strategies: typeof strategy): Locale;
|
|
21
3
|
import { strategy } from "./variables.js";
|
|
22
4
|
//# sourceMappingURL=extract-locale-from-request.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-locale-from-request.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-request.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extract-locale-from-request.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-request.js"],"names":[],"mappings":"AAkCO,kDAHI,OAAO,GACL,MAAM,CAOlB;AASM,gEAJI,OAAO,cACP,OAAO,QAAQ,GACb,MAAM,CA0ClB;yBA3EM,gBAAgB"}
|
|
@@ -20,7 +20,8 @@ import { baseLocale, cookieName, getStrategyForUrl, strategy, TREE_SHAKE_COOKIE_
|
|
|
20
20
|
* @example
|
|
21
21
|
* const locale = extractLocaleFromRequest(request);
|
|
22
22
|
*
|
|
23
|
-
* @
|
|
23
|
+
* @param {Request} request
|
|
24
|
+
* @returns {Locale}
|
|
24
25
|
*/
|
|
25
26
|
export const extractLocaleFromRequest = (request) => {
|
|
26
27
|
return extractLocaleFromRequestWithStrategies(request, getStrategyForUrl(request.url));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-locale-from-request.js","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-request.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACN,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,+BAA+B,EAC/B,2CAA2C,EAC3C,4BAA4B,GAC5B,MAAM,gBAAgB,CAAC;AAExB
|
|
1
|
+
{"version":3,"file":"extract-locale-from-request.js","sourceRoot":"","sources":["../../../src/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oBAAoB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5C,CAAC;aAAM,IACN,2CAA2C;YAC3C,KAAK,KAAK,mBAAmB,EAC5B,CAAC;YACF,MAAM,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;aAAM,IAAI,KAAK,KAAK,gBAAgB,EAAE,CAAC;YACvC,MAAM,GAAG,OAAO,CAAC;QAClB,CAAC;aAAM,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;YACnC,OAAO,UAAU,CAAC;QACnB,CAAC;aAAM,IAAI,KAAK,KAAK,cAAc,EAAE,CAAC;YACrC,SAAS;QACV,CAAC;aAAM,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;YACpC,sDAAsD;YACtD,iEAAiE;YACjE,SAAS;QACV,CAAC;QACD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBACvB,MAAM,GAAG,SAAS,CAAC;YACpB,CAAC;iBAAM,CAAC;gBACP,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;YAC/B,CAAC;QACF,CAAC;IACF,CAAC;IACD,MAAM,IAAI,KAAK,CACd,wMAAwM,CACxM,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -52,8 +52,8 @@ export function extractLocaleFromUrl(url) {
|
|
|
52
52
|
/**
|
|
53
53
|
* https://github.com/opral/inlang-paraglide-js/issues/381
|
|
54
54
|
*
|
|
55
|
-
* @param {URL|string} url - The full URL from which to extract the locale.
|
|
56
|
-
* @returns {Locale|undefined} The extracted locale, or undefined if no locale is found.
|
|
55
|
+
* @param {URL | string} url - The full URL from which to extract the locale.
|
|
56
|
+
* @returns {Locale | undefined} The extracted locale, or undefined if no locale is found.
|
|
57
57
|
*/
|
|
58
58
|
function defaultUrlPatternExtractLocale(url) {
|
|
59
59
|
const urlObj = new URL(url, "http://dummy.com");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-static-localized-urls.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/generate-static-localized-urls.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,kDANW,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,GAGd,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"generate-static-localized-urls.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/generate-static-localized-urls.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,kDANW,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,GAGd,GAAG,EAAE,CAmFjB"}
|
|
@@ -44,6 +44,7 @@ import { locales, baseLocale, TREE_SHAKE_DEFAULT_URL_PATTERN_USED, urlPatterns,
|
|
|
44
44
|
* The order follows each input URL with all its locale variants before moving to the next URL.
|
|
45
45
|
*/
|
|
46
46
|
export function generateStaticLocalizedUrls(urls) {
|
|
47
|
+
/** @type {Set<URL>} */
|
|
47
48
|
const localizedUrls = new Set();
|
|
48
49
|
// For default URL pattern, we can optimize the generation
|
|
49
50
|
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-static-localized-urls.js","sourceRoot":"","sources":["../../../src/compiler/runtime/generate-static-localized-urls.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACN,OAAO,EACP,UAAU,EACV,mCAAmC,EACnC,WAAW,GACX,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAI;IAC/C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;IAEhC,0DAA0D;IAC1D,IAAI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AAC,gBAAgB;oBAAE,SAAS;gBAEhC,YAAY,GAAG,IAAI,CAAC;gBAEpB,6EAA6E;gBAC7E,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;gBAE3B,yCAAyC;gBACzC,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;oBAC1C,IAAI,CAAC;wBACJ,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;wBAClD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC;wBAEpC,oDAAoD;wBACpD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;4BAC9B,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;4BACxB,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;wBACjC,CAAC;oBACF,CAAC;oBAAC,MAAM,CAAC;wBACR,6CAA6C;wBAC7C,SAAS;oBACV,CAAC;gBACF,CAAC;gBACD,MAAM;YACP,CAAC;YAAC,MAAM,CAAC;gBACR,iCAAiC;gBACjC,SAAS;YACV,CAAC;QACF,CAAC;QAED,2CAA2C;QAC3C,IAAI,CAAC,YAAY,EAAE,CAAC;YACnB,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AAClC,CAAC"}
|
|
1
|
+
{"version":3,"file":"generate-static-localized-urls.js","sourceRoot":"","sources":["../../../src/compiler/runtime/generate-static-localized-urls.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACN,OAAO,EACP,UAAU,EACV,mCAAmC,EACnC,WAAW,GACX,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH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AI,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CACtE,GAAG,CAAC,IAAI,CACR,CAAC;gBAEF,IAAI,CAAC,gBAAgB;oBAAE,SAAS;gBAEhC,YAAY,GAAG,IAAI,CAAC;gBAEpB,6EAA6E;gBAC7E,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;gBAE3B,yCAAyC;gBACzC,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;oBAC1C,IAAI,CAAC;wBACJ,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;wBAClD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC;wBAEpC,oDAAoD;wBACpD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;4BAC9B,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;4BACxB,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;wBACjC,CAAC;oBACF,CAAC;oBAAC,MAAM,CAAC;wBACR,6CAA6C;wBAC7C,SAAS;oBACV,CAAC;gBACF,CAAC;gBACD,MAAM;YACP,CAAC;YAAC,MAAM,CAAC;gBACR,iCAAiC;gBACjC,SAAS;YACV,CAAC;QACF,CAAC;QAED,2CAA2C;QAC3C,IAAI,CAAC,YAAY,EAAE,CAAC;YACnB,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -5,39 +5,6 @@
|
|
|
5
5
|
* @returns {Locale}
|
|
6
6
|
*/
|
|
7
7
|
export function getLocaleForUrl(url: string | URL): Locale;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
* The locale is resolved using your configured strategies (URL, cookie, localStorage, etc.)
|
|
12
|
-
* in the order they are defined. In SSR contexts, the locale is retrieved from AsyncLocalStorage
|
|
13
|
-
* which is set by the `paraglideMiddleware()`.
|
|
14
|
-
*
|
|
15
|
-
* @see https://inlang.com/m/gerre34r/library-inlang-paraglideJs/strategy - Configure locale detection strategies
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* if (getLocale() === 'de') {
|
|
19
|
-
* console.log('Germany 🇩🇪');
|
|
20
|
-
* } else if (getLocale() === 'nl') {
|
|
21
|
-
* console.log('Netherlands 🇳🇱');
|
|
22
|
-
* }
|
|
23
|
-
*
|
|
24
|
-
* @type {() => Locale}
|
|
25
|
-
*/
|
|
26
|
-
export let getLocale: () => Locale;
|
|
27
|
-
/**
|
|
28
|
-
* Overwrite the `getLocale()` function.
|
|
29
|
-
*
|
|
30
|
-
* Use this function to overwrite how the locale is resolved. This is useful
|
|
31
|
-
* for custom locale resolution or advanced use cases like SSG with concurrent rendering.
|
|
32
|
-
*
|
|
33
|
-
* @see https://inlang.com/m/gerre34r/library-inlang-paraglideJs/strategy
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* overwriteGetLocale(() => {
|
|
37
|
-
* return Cookies.get('locale') ?? baseLocale
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
* @type {(fn: () => Locale) => void}
|
|
41
|
-
*/
|
|
42
|
-
export const overwriteGetLocale: (fn: () => Locale) => void;
|
|
8
|
+
export function getLocale(): Locale;
|
|
9
|
+
export function overwriteGetLocale(fn: () => Locale): void;
|
|
43
10
|
//# sourceMappingURL=get-locale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-locale.js"],"names":[],"mappings":"AA0FA;;;;;GAKG;AACH,qCAHW,MAAM,GAAG,GAAG,GACV,MAAM,CAmBlB;
|
|
1
|
+
{"version":3,"file":"get-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-locale.js"],"names":[],"mappings":"AA0FA;;;;;GAKG;AACH,qCAHW,MAAM,GAAG,GAAG,GACV,MAAM,CAmBlB;AA7DM,6BAFM,MAAM,CAsClB;AAsGM,uCAFI,MAAM,MAAM,QAItB"}
|
|
@@ -12,7 +12,7 @@ import { baseLocale, getStrategyForUrl, isServer, localStorageKey, serverAsyncLo
|
|
|
12
12
|
* The implementation is overwritten
|
|
13
13
|
* by \`overwriteGetLocale()\` and \`defineSetLocale()\`.
|
|
14
14
|
*
|
|
15
|
-
* @type {Locale|undefined}
|
|
15
|
+
* @type {Locale | undefined}
|
|
16
16
|
*/
|
|
17
17
|
let _locale;
|
|
18
18
|
let localeInitiallySet = false;
|
|
@@ -32,7 +32,7 @@ let localeInitiallySet = false;
|
|
|
32
32
|
* console.log('Netherlands 🇳🇱');
|
|
33
33
|
* }
|
|
34
34
|
*
|
|
35
|
-
* @
|
|
35
|
+
* @returns {Locale} The current locale.
|
|
36
36
|
*/
|
|
37
37
|
export let getLocale = () => {
|
|
38
38
|
if (experimentalStaticLocale !== undefined) {
|
|
@@ -146,7 +146,7 @@ function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
|
|
|
146
146
|
* return Cookies.get('locale') ?? baseLocale
|
|
147
147
|
* });
|
|
148
148
|
*
|
|
149
|
-
* @
|
|
149
|
+
* @param {() => Locale} fn - The new implementation for `getLocale()`.
|
|
150
150
|
*/
|
|
151
151
|
export const overwriteGetLocale = (fn) => {
|
|
152
152
|
getLocale = fn;
|
|
@@ -8,13 +8,5 @@
|
|
|
8
8
|
* @type {() => string}
|
|
9
9
|
*/
|
|
10
10
|
export let getUrlOrigin: () => string;
|
|
11
|
-
|
|
12
|
-
* Overwrite the getUrlOrigin function.
|
|
13
|
-
*
|
|
14
|
-
* Use this function in server environments to
|
|
15
|
-
* define how the URL origin is resolved.
|
|
16
|
-
*
|
|
17
|
-
* @type {(fn: () => string) => void}
|
|
18
|
-
*/
|
|
19
|
-
export let overwriteGetUrlOrigin: (fn: () => string) => void;
|
|
11
|
+
export function overwriteGetUrlOrigin(fn: () => string): void;
|
|
20
12
|
//# sourceMappingURL=get-url-origin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-url-origin.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-url-origin.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,yBAFU,MAAM,MAAM,CASpB;
|
|
1
|
+
{"version":3,"file":"get-url-origin.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-url-origin.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,yBAFU,MAAM,MAAM,CASpB;AAUK,0CAFI,MAAM,MAAM,QAItB"}
|
|
@@ -23,7 +23,7 @@ export let getUrlOrigin = () => {
|
|
|
23
23
|
* Use this function in server environments to
|
|
24
24
|
* define how the URL origin is resolved.
|
|
25
25
|
*
|
|
26
|
-
* @
|
|
26
|
+
* @param {() => string} fn - The new implementation for `getUrlOrigin()`.
|
|
27
27
|
*/
|
|
28
28
|
export let overwriteGetUrlOrigin = (fn) => {
|
|
29
29
|
getUrlOrigin = fn;
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* setLocale('en');
|
|
9
9
|
* }
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
|
+
* @param {unknown} locale
|
|
12
13
|
* @returns {locale is Locale}
|
|
13
14
|
*/
|
|
14
|
-
export function isLocale(locale:
|
|
15
|
+
export function isLocale(locale: unknown): locale is Locale;
|
|
15
16
|
//# sourceMappingURL=is-locale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/is-locale.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"is-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/is-locale.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,iCAHW,OAAO,GACL,MAAM,IAAI,MAAM,CAO5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-locale.js","sourceRoot":"","sources":["../../../src/compiler/runtime/is-locale.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC
|
|
1
|
+
{"version":3,"file":"is-locale.js","sourceRoot":"","sources":["../../../src/compiler/runtime/is-locale.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAM;IAC9B,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC7C,OAAO,CAAC,MAAM;QACb,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AACxE,CAAC"}
|