diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index c62ab30a..4f3aff9b 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -34,9 +34,6 @@ jobs:
sudo apt-get update
sudo apt-get install -y ripgrep bubblewrap socat
- - name: Compile translations
- run: bun run i18n:compile
-
- name: Lint
run: bun run lint
diff --git a/.github/workflows/release-npm.yaml b/.github/workflows/release-npm.yaml
index a036ef0b..0cab49c2 100644
--- a/.github/workflows/release-npm.yaml
+++ b/.github/workflows/release-npm.yaml
@@ -53,9 +53,6 @@ jobs:
- name: Install dependencies
run: bun install
- - name: Compile translations
- run: bun run i18n:compile
-
- name: Lint
run: bun run lint
diff --git a/packages/webui/src/paraglide/README.md b/packages/webui/src/paraglide/README.md
index c9706762..9e6ff79e 100644
--- a/packages/webui/src/paraglide/README.md
+++ b/packages/webui/src/paraglide/README.md
@@ -4,7 +4,6 @@
Compiled from: `/Users/yiling/Projects/shumai/packages/webui/project.inlang`
-
## What is this folder?
This folder contains compiled [Paraglide JS](https://github.com/opral/paraglide-js) output. Paraglide JS compiles your translation messages into tree-shakeable JavaScript functions.
@@ -12,15 +11,18 @@ This folder contains compiled [Paraglide JS](https://github.com/opral/paraglide-
## At a glance
Purpose:
+
- This folder stores compiled i18n message functions.
- Source translations live outside this folder in your inlang project.
Safe to import:
+
- `messages.js` — all message functions
- `runtime.js` — locale utilities
- `server.js` — server-side middleware
Do not edit:
+
- All files in this folder are auto-generated.
- Changes will be overwritten on next compilation.
@@ -37,27 +39,27 @@ paraglide/
## Usage
```js
-import * as m from "./paraglide/messages.js";
+import * as m from './paraglide/messages.js'
// Messages are functions that return localized strings
-m.hello_world(); // "Hello, World!" (in current locale)
-m.greeting({ name: "Sam" }); // "Hello, Sam!"
+m.hello_world() // "Hello, World!" (in current locale)
+m.greeting({ name: 'Sam' }) // "Hello, Sam!"
// Override locale per-call
-m.hello_world({}, { locale: "de" }); // "Hallo, Welt!"
-m.greeting({ name: "Sam" }, { locale: "de" }); // "Hallo, Sam!"
+m.hello_world({}, { locale: 'de' }) // "Hallo, Welt!"
+m.greeting({ name: 'Sam' }, { locale: 'de' }) // "Hallo, Sam!"
```
## Runtime API
```js
-import { getLocale, getTextDirection, setLocale, locales, baseLocale } from "./paraglide/runtime.js";
+import { getLocale, getTextDirection, setLocale, locales, baseLocale } from './paraglide/runtime.js'
-getLocale(); // Current locale, e.g., "en"
-getTextDirection(); // "ltr" | "rtl" for current locale
-setLocale("de"); // Set locale
-locales; // Available locales, e.g., ["en", "de", "fr"]
-baseLocale; // Default locale, e.g., "en"
+getLocale() // Current locale, e.g., "en"
+getTextDirection() // "ltr" | "rtl" for current locale
+setLocale('de') // Set locale
+locales // Available locales, e.g., ["en", "de", "fr"]
+baseLocale // Default locale, e.g., "en"
```
## Strategy
@@ -73,10 +75,10 @@ Strategies can be combined. The order defines precedence:
```js
await compile({
- project: "./project.inlang",
- outdir: "./src/paraglide",
- strategy: ["url", "cookie", "baseLocale"],
-});
+ project: './project.inlang',
+ outdir: './src/paraglide',
+ strategy: ['url', 'cookie', 'baseLocale'],
+})
```
See the [strategy documentation](https://paraglidejs.com/strategy) for details.
@@ -86,6 +88,7 @@ See the [strategy documentation](https://paraglidejs.com/strategy) for details.
Messages can contain markup tags for bold, links, and other inline elements. Translators control where tags appear; developers control how they render.
Important:
+
- Tag names are app-defined. There is no built-in list of HTML tags.
- `{#b}...{/b}` does not automatically render as `...`.
- Renderers/snippets are looked up by the same tag name used in the message.
@@ -111,13 +114,13 @@ This is the default inlang message syntax. Paraglide's message format is plugin-
Calling the message function still returns **plain text** (markup stripped):
```js
-m.cta({ relationship: "noopener" }); // "Read the docs"
+m.cta({ relationship: 'noopener' }) // "Read the docs"
```
To render markup, use the framework adapter or the low-level `parts()` API:
```js
-const parts = m.cta.parts({ relationship: "noopener" });
+const parts = m.cta.parts({ relationship: 'noopener' })
// [
// { type: "markup-start", name: "link", options: { to: "/docs", rel: "noopener" }, attributes: { track: true } },
// { type: "text", value: "Read the docs" },
@@ -133,11 +136,11 @@ Framework adapters provide a `` component that accepts markup
- `@inlang/paraglide-js-solid`
```jsx
-import { ParaglideMessage } from "@inlang/paraglide-js-react"; // or -vue, -svelte, -solid
+import { ParaglideMessage } from '@inlang/paraglide-js-react' // or -vue, -svelte, -solid
- {children},
icon: () => ,
diff --git a/packages/webui/src/paraglide/messages.d.ts b/packages/webui/src/paraglide/messages.d.ts
index 59e887e0..c7929117 100644
--- a/packages/webui/src/paraglide/messages.d.ts
+++ b/packages/webui/src/paraglide/messages.d.ts
@@ -1,2 +1,2 @@
-export * from "./messages/_index.js";
-export * as m from "./messages/_index.js";
+export * from './messages/_index.js'
+export * as m from './messages/_index.js'
diff --git a/packages/webui/src/paraglide/messages.js b/packages/webui/src/paraglide/messages.js
index 608d20d4..17f44480 100644
--- a/packages/webui/src/paraglide/messages.js
+++ b/packages/webui/src/paraglide/messages.js
@@ -1,4 +1,4 @@
/* eslint-disable */
export * from './messages/_index.js'
// enabling auto-import by exposing all messages as m
-export * as m from './messages/_index.js'
\ No newline at end of file
+export * as m from './messages/_index.js'
diff --git a/packages/webui/src/paraglide/messages/_index.d.ts b/packages/webui/src/paraglide/messages/_index.d.ts
index e90b6717..04fd606d 100644
--- a/packages/webui/src/paraglide/messages/_index.d.ts
+++ b/packages/webui/src/paraglide/messages/_index.d.ts
@@ -1,20 +1,20 @@
-export * from "./dashboard.js";
-export * from "./notifications.js";
-export * from "./uploads.js";
-export * from "./language.js";
-export * from "./personal_info.js";
-export * from "./language_settings.js";
-export * from "./select_preferred_language.js";
-export * from "./settings.js";
-export * from "./welcome_back.js";
-export * from "./create_account.js";
-export * from "./select_a_team.js";
-export * from "./projects.js";
-export * from "./select_asset_to_view_details.js";
-export * from "./all_collections.js";
-export * from "./file_not_found.js";
-export * from "./recently_deleted_notice.js";
-export * from "./all_share_links.js";
-export * from "./link_visibility.js";
-export * from "./password_protected.js";
-export type LocalizedString = import("../runtime.js").LocalizedString;
+export * from './dashboard.js'
+export * from './notifications.js'
+export * from './uploads.js'
+export * from './language.js'
+export * from './personal_info.js'
+export * from './language_settings.js'
+export * from './select_preferred_language.js'
+export * from './settings.js'
+export * from './welcome_back.js'
+export * from './create_account.js'
+export * from './select_a_team.js'
+export * from './projects.js'
+export * from './select_asset_to_view_details.js'
+export * from './all_collections.js'
+export * from './file_not_found.js'
+export * from './recently_deleted_notice.js'
+export * from './all_share_links.js'
+export * from './link_visibility.js'
+export * from './password_protected.js'
+export type LocalizedString = import('../runtime.js').LocalizedString
diff --git a/packages/webui/src/paraglide/messages/_index.js b/packages/webui/src/paraglide/messages/_index.js
index 14d6f326..180271ed 100644
--- a/packages/webui/src/paraglide/messages/_index.js
+++ b/packages/webui/src/paraglide/messages/_index.js
@@ -18,4 +18,4 @@ export * from './file_not_found.js'
export * from './recently_deleted_notice.js'
export * from './all_share_links.js'
export * from './link_visibility.js'
-export * from './password_protected.js'
\ No newline at end of file
+export * from './password_protected.js'
diff --git a/packages/webui/src/paraglide/messages/all_collections.d.ts b/packages/webui/src/paraglide/messages/all_collections.d.ts
index be2b68d3..86f44db3 100644
--- a/packages/webui/src/paraglide/messages/all_collections.d.ts
+++ b/packages/webui/src/paraglide/messages/all_collections.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "All Collections" |
-*
-* @param {All_CollectionsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const all_collections: ((inputs?: All_CollectionsInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type All_CollectionsInputs = {};
+ * | output |
+ * | --- |
+ * | "All Collections" |
+ *
+ * @param {All_CollectionsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const all_collections: ((
+ inputs?: All_CollectionsInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ All_CollectionsInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type All_CollectionsInputs = {}
diff --git a/packages/webui/src/paraglide/messages/all_collections.js b/packages/webui/src/paraglide/messages/all_collections.js
index df77f554..2cfc5fcc 100644
--- a/packages/webui/src/paraglide/messages/all_collections.js
+++ b/packages/webui/src/paraglide/messages/all_collections.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} All_CollectionsInputs */
const en_all_collections = /** @type {(inputs: All_CollectionsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`All Collections`)
-};
+ return /** @type {LocalizedString} */ (`All Collections`)
+}
const zh_all_collections = /** @type {(inputs: All_CollectionsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`所有收藏`)
-};
+ return /** @type {LocalizedString} */ (`所有收藏`)
+}
/**
-* | output |
-* | --- |
-* | "All Collections" |
-*
-* @param {All_CollectionsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const all_collections = /** @type {((inputs?: All_CollectionsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_all_collections(inputs)
- return zh_all_collections(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "All Collections" |
+ *
+ * @param {All_CollectionsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const all_collections =
+ /** @type {((inputs?: All_CollectionsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_all_collections(inputs)
+ return zh_all_collections(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/all_share_links.d.ts b/packages/webui/src/paraglide/messages/all_share_links.d.ts
index 53c53466..2e6746b9 100644
--- a/packages/webui/src/paraglide/messages/all_share_links.d.ts
+++ b/packages/webui/src/paraglide/messages/all_share_links.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "All Share Links" |
-*
-* @param {All_Share_LinksInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const all_share_links: ((inputs?: All_Share_LinksInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type All_Share_LinksInputs = {};
+ * | output |
+ * | --- |
+ * | "All Share Links" |
+ *
+ * @param {All_Share_LinksInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const all_share_links: ((
+ inputs?: All_Share_LinksInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ All_Share_LinksInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type All_Share_LinksInputs = {}
diff --git a/packages/webui/src/paraglide/messages/all_share_links.js b/packages/webui/src/paraglide/messages/all_share_links.js
index 25a26ea5..d7731c68 100644
--- a/packages/webui/src/paraglide/messages/all_share_links.js
+++ b/packages/webui/src/paraglide/messages/all_share_links.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} All_Share_LinksInputs */
const en_all_share_links = /** @type {(inputs: All_Share_LinksInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`All Share Links`)
-};
+ return /** @type {LocalizedString} */ (`All Share Links`)
+}
const zh_all_share_links = /** @type {(inputs: All_Share_LinksInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`所有分享链接`)
-};
+ return /** @type {LocalizedString} */ (`所有分享链接`)
+}
/**
-* | output |
-* | --- |
-* | "All Share Links" |
-*
-* @param {All_Share_LinksInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const all_share_links = /** @type {((inputs?: All_Share_LinksInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_all_share_links(inputs)
- return zh_all_share_links(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "All Share Links" |
+ *
+ * @param {All_Share_LinksInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const all_share_links =
+ /** @type {((inputs?: All_Share_LinksInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_all_share_links(inputs)
+ return zh_all_share_links(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/create_account.d.ts b/packages/webui/src/paraglide/messages/create_account.d.ts
index 75fc7e07..97c1d814 100644
--- a/packages/webui/src/paraglide/messages/create_account.d.ts
+++ b/packages/webui/src/paraglide/messages/create_account.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Create Account" |
-*
-* @param {Create_AccountInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const create_account: ((inputs?: Create_AccountInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type Create_AccountInputs = {};
+ * | output |
+ * | --- |
+ * | "Create Account" |
+ *
+ * @param {Create_AccountInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const create_account: ((
+ inputs?: Create_AccountInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ Create_AccountInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type Create_AccountInputs = {}
diff --git a/packages/webui/src/paraglide/messages/create_account.js b/packages/webui/src/paraglide/messages/create_account.js
index 755536ee..98ea9636 100644
--- a/packages/webui/src/paraglide/messages/create_account.js
+++ b/packages/webui/src/paraglide/messages/create_account.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Create_AccountInputs */
const en_create_account = /** @type {(inputs: Create_AccountInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Create Account`)
-};
+ return /** @type {LocalizedString} */ (`Create Account`)
+}
const zh_create_account = /** @type {(inputs: Create_AccountInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`创建账户`)
-};
+ return /** @type {LocalizedString} */ (`创建账户`)
+}
/**
-* | output |
-* | --- |
-* | "Create Account" |
-*
-* @param {Create_AccountInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const create_account = /** @type {((inputs?: Create_AccountInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_create_account(inputs)
- return zh_create_account(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Create Account" |
+ *
+ * @param {Create_AccountInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const create_account =
+ /** @type {((inputs?: Create_AccountInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_create_account(inputs)
+ return zh_create_account(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/dashboard.d.ts b/packages/webui/src/paraglide/messages/dashboard.d.ts
index aba907b4..cf685df1 100644
--- a/packages/webui/src/paraglide/messages/dashboard.d.ts
+++ b/packages/webui/src/paraglide/messages/dashboard.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Dashboard" |
-*
-* @param {DashboardInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const dashboard: ((inputs?: DashboardInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type DashboardInputs = {};
+ * | output |
+ * | --- |
+ * | "Dashboard" |
+ *
+ * @param {DashboardInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const dashboard: ((
+ inputs?: DashboardInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ DashboardInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type DashboardInputs = {}
diff --git a/packages/webui/src/paraglide/messages/dashboard.js b/packages/webui/src/paraglide/messages/dashboard.js
index 85ab1d5d..ad85e7ab 100644
--- a/packages/webui/src/paraglide/messages/dashboard.js
+++ b/packages/webui/src/paraglide/messages/dashboard.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} DashboardInputs */
const en_dashboard = /** @type {(inputs: DashboardInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Dashboard`)
-};
+ return /** @type {LocalizedString} */ (`Dashboard`)
+}
const zh_dashboard = /** @type {(inputs: DashboardInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`控制台`)
-};
+ return /** @type {LocalizedString} */ (`控制台`)
+}
/**
-* | output |
-* | --- |
-* | "Dashboard" |
-*
-* @param {DashboardInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const dashboard = /** @type {((inputs?: DashboardInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_dashboard(inputs)
- return zh_dashboard(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Dashboard" |
+ *
+ * @param {DashboardInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const dashboard =
+ /** @type {((inputs?: DashboardInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_dashboard(inputs)
+ return zh_dashboard(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/file_not_found.d.ts b/packages/webui/src/paraglide/messages/file_not_found.d.ts
index 1a1e477c..c0085100 100644
--- a/packages/webui/src/paraglide/messages/file_not_found.d.ts
+++ b/packages/webui/src/paraglide/messages/file_not_found.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "File not found." |
-*
-* @param {File_Not_FoundInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const file_not_found: ((inputs?: File_Not_FoundInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type File_Not_FoundInputs = {};
+ * | output |
+ * | --- |
+ * | "File not found." |
+ *
+ * @param {File_Not_FoundInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const file_not_found: ((
+ inputs?: File_Not_FoundInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ File_Not_FoundInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type File_Not_FoundInputs = {}
diff --git a/packages/webui/src/paraglide/messages/file_not_found.js b/packages/webui/src/paraglide/messages/file_not_found.js
index ab9f5af2..ca0fb676 100644
--- a/packages/webui/src/paraglide/messages/file_not_found.js
+++ b/packages/webui/src/paraglide/messages/file_not_found.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} File_Not_FoundInputs */
const en_file_not_found = /** @type {(inputs: File_Not_FoundInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`File not found.`)
-};
+ return /** @type {LocalizedString} */ (`File not found.`)
+}
const zh_file_not_found = /** @type {(inputs: File_Not_FoundInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`文件未找到。`)
-};
+ return /** @type {LocalizedString} */ (`文件未找到。`)
+}
/**
-* | output |
-* | --- |
-* | "File not found." |
-*
-* @param {File_Not_FoundInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const file_not_found = /** @type {((inputs?: File_Not_FoundInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_file_not_found(inputs)
- return zh_file_not_found(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "File not found." |
+ *
+ * @param {File_Not_FoundInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const file_not_found =
+ /** @type {((inputs?: File_Not_FoundInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_file_not_found(inputs)
+ return zh_file_not_found(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/language.d.ts b/packages/webui/src/paraglide/messages/language.d.ts
index 1dce30b1..71253b3e 100644
--- a/packages/webui/src/paraglide/messages/language.d.ts
+++ b/packages/webui/src/paraglide/messages/language.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Language" |
-*
-* @param {LanguageInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const language: ((inputs?: LanguageInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type LanguageInputs = {};
+ * | output |
+ * | --- |
+ * | "Language" |
+ *
+ * @param {LanguageInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const language: ((
+ inputs?: LanguageInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ LanguageInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type LanguageInputs = {}
diff --git a/packages/webui/src/paraglide/messages/language.js b/packages/webui/src/paraglide/messages/language.js
index a1052f5e..8e59a038 100644
--- a/packages/webui/src/paraglide/messages/language.js
+++ b/packages/webui/src/paraglide/messages/language.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} LanguageInputs */
const en_language = /** @type {(inputs: LanguageInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Language`)
-};
+ return /** @type {LocalizedString} */ (`Language`)
+}
const zh_language = /** @type {(inputs: LanguageInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`语言`)
-};
+ return /** @type {LocalizedString} */ (`语言`)
+}
/**
-* | output |
-* | --- |
-* | "Language" |
-*
-* @param {LanguageInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const language = /** @type {((inputs?: LanguageInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_language(inputs)
- return zh_language(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Language" |
+ *
+ * @param {LanguageInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const language =
+ /** @type {((inputs?: LanguageInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_language(inputs)
+ return zh_language(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/language_settings.d.ts b/packages/webui/src/paraglide/messages/language_settings.d.ts
index c41fe9c8..eb35d308 100644
--- a/packages/webui/src/paraglide/messages/language_settings.d.ts
+++ b/packages/webui/src/paraglide/messages/language_settings.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Language Settings" |
-*
-* @param {Language_SettingsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const language_settings: ((inputs?: Language_SettingsInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type Language_SettingsInputs = {};
+ * | output |
+ * | --- |
+ * | "Language Settings" |
+ *
+ * @param {Language_SettingsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const language_settings: ((
+ inputs?: Language_SettingsInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ Language_SettingsInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type Language_SettingsInputs = {}
diff --git a/packages/webui/src/paraglide/messages/language_settings.js b/packages/webui/src/paraglide/messages/language_settings.js
index fe99a99a..c92c26a6 100644
--- a/packages/webui/src/paraglide/messages/language_settings.js
+++ b/packages/webui/src/paraglide/messages/language_settings.js
@@ -1,29 +1,34 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Language_SettingsInputs */
-const en_language_settings = /** @type {(inputs: Language_SettingsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Language Settings`)
-};
+const en_language_settings =
+ /** @type {(inputs: Language_SettingsInputs) => LocalizedString} */ () => {
+ return /** @type {LocalizedString} */ (`Language Settings`)
+ }
-const zh_language_settings = /** @type {(inputs: Language_SettingsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`语言设置`)
-};
+const zh_language_settings =
+ /** @type {(inputs: Language_SettingsInputs) => LocalizedString} */ () => {
+ return /** @type {LocalizedString} */ (`语言设置`)
+ }
/**
-* | output |
-* | --- |
-* | "Language Settings" |
-*
-* @param {Language_SettingsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const language_settings = /** @type {((inputs?: Language_SettingsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_language_settings(inputs)
- return zh_language_settings(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Language Settings" |
+ *
+ * @param {Language_SettingsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const language_settings =
+ /** @type {((inputs?: Language_SettingsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_language_settings(inputs)
+ return zh_language_settings(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/link_visibility.d.ts b/packages/webui/src/paraglide/messages/link_visibility.d.ts
index 10c5b8e2..53e480f6 100644
--- a/packages/webui/src/paraglide/messages/link_visibility.d.ts
+++ b/packages/webui/src/paraglide/messages/link_visibility.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Link Visibility" |
-*
-* @param {Link_VisibilityInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const link_visibility: ((inputs?: Link_VisibilityInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type Link_VisibilityInputs = {};
+ * | output |
+ * | --- |
+ * | "Link Visibility" |
+ *
+ * @param {Link_VisibilityInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const link_visibility: ((
+ inputs?: Link_VisibilityInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ Link_VisibilityInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type Link_VisibilityInputs = {}
diff --git a/packages/webui/src/paraglide/messages/link_visibility.js b/packages/webui/src/paraglide/messages/link_visibility.js
index e8cef864..bf8ab23c 100644
--- a/packages/webui/src/paraglide/messages/link_visibility.js
+++ b/packages/webui/src/paraglide/messages/link_visibility.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Link_VisibilityInputs */
const en_link_visibility = /** @type {(inputs: Link_VisibilityInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Link Visibility`)
-};
+ return /** @type {LocalizedString} */ (`Link Visibility`)
+}
const zh_link_visibility = /** @type {(inputs: Link_VisibilityInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`链接可见性`)
-};
+ return /** @type {LocalizedString} */ (`链接可见性`)
+}
/**
-* | output |
-* | --- |
-* | "Link Visibility" |
-*
-* @param {Link_VisibilityInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const link_visibility = /** @type {((inputs?: Link_VisibilityInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_link_visibility(inputs)
- return zh_link_visibility(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Link Visibility" |
+ *
+ * @param {Link_VisibilityInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const link_visibility =
+ /** @type {((inputs?: Link_VisibilityInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_link_visibility(inputs)
+ return zh_link_visibility(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/notifications.d.ts b/packages/webui/src/paraglide/messages/notifications.d.ts
index e76b39fb..59c8d327 100644
--- a/packages/webui/src/paraglide/messages/notifications.d.ts
+++ b/packages/webui/src/paraglide/messages/notifications.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Notifications" |
-*
-* @param {NotificationsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const notifications: ((inputs?: NotificationsInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type NotificationsInputs = {};
+ * | output |
+ * | --- |
+ * | "Notifications" |
+ *
+ * @param {NotificationsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const notifications: ((
+ inputs?: NotificationsInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ NotificationsInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type NotificationsInputs = {}
diff --git a/packages/webui/src/paraglide/messages/notifications.js b/packages/webui/src/paraglide/messages/notifications.js
index b5362452..12513f13 100644
--- a/packages/webui/src/paraglide/messages/notifications.js
+++ b/packages/webui/src/paraglide/messages/notifications.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} NotificationsInputs */
const en_notifications = /** @type {(inputs: NotificationsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Notifications`)
-};
+ return /** @type {LocalizedString} */ (`Notifications`)
+}
const zh_notifications = /** @type {(inputs: NotificationsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`通知中心`)
-};
+ return /** @type {LocalizedString} */ (`通知中心`)
+}
/**
-* | output |
-* | --- |
-* | "Notifications" |
-*
-* @param {NotificationsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const notifications = /** @type {((inputs?: NotificationsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_notifications(inputs)
- return zh_notifications(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Notifications" |
+ *
+ * @param {NotificationsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const notifications =
+ /** @type {((inputs?: NotificationsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_notifications(inputs)
+ return zh_notifications(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/package.json b/packages/webui/src/paraglide/messages/package.json
index 330f44b1..7f1fc33d 100644
--- a/packages/webui/src/paraglide/messages/package.json
+++ b/packages/webui/src/paraglide/messages/package.json
@@ -1,4 +1,4 @@
{
- "type": "module",
- "sideEffects": false
+ "type": "module",
+ "sideEffects": false
}
diff --git a/packages/webui/src/paraglide/messages/password_protected.d.ts b/packages/webui/src/paraglide/messages/password_protected.d.ts
index 827072e5..cecad5b9 100644
--- a/packages/webui/src/paraglide/messages/password_protected.d.ts
+++ b/packages/webui/src/paraglide/messages/password_protected.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Password Protected" |
-*
-* @param {Password_ProtectedInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const password_protected: ((inputs?: Password_ProtectedInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type Password_ProtectedInputs = {};
+ * | output |
+ * | --- |
+ * | "Password Protected" |
+ *
+ * @param {Password_ProtectedInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const password_protected: ((
+ inputs?: Password_ProtectedInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ Password_ProtectedInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type Password_ProtectedInputs = {}
diff --git a/packages/webui/src/paraglide/messages/password_protected.js b/packages/webui/src/paraglide/messages/password_protected.js
index a575605f..688d2cd2 100644
--- a/packages/webui/src/paraglide/messages/password_protected.js
+++ b/packages/webui/src/paraglide/messages/password_protected.js
@@ -1,29 +1,34 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Password_ProtectedInputs */
-const en_password_protected = /** @type {(inputs: Password_ProtectedInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Password Protected`)
-};
+const en_password_protected =
+ /** @type {(inputs: Password_ProtectedInputs) => LocalizedString} */ () => {
+ return /** @type {LocalizedString} */ (`Password Protected`)
+ }
-const zh_password_protected = /** @type {(inputs: Password_ProtectedInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`密码保护`)
-};
+const zh_password_protected =
+ /** @type {(inputs: Password_ProtectedInputs) => LocalizedString} */ () => {
+ return /** @type {LocalizedString} */ (`密码保护`)
+ }
/**
-* | output |
-* | --- |
-* | "Password Protected" |
-*
-* @param {Password_ProtectedInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const password_protected = /** @type {((inputs?: Password_ProtectedInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_password_protected(inputs)
- return zh_password_protected(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Password Protected" |
+ *
+ * @param {Password_ProtectedInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const password_protected =
+ /** @type {((inputs?: Password_ProtectedInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_password_protected(inputs)
+ return zh_password_protected(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/personal_info.d.ts b/packages/webui/src/paraglide/messages/personal_info.d.ts
index a2b0afd1..935846e7 100644
--- a/packages/webui/src/paraglide/messages/personal_info.d.ts
+++ b/packages/webui/src/paraglide/messages/personal_info.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Personal Info" |
-*
-* @param {Personal_InfoInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const personal_info: ((inputs?: Personal_InfoInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type Personal_InfoInputs = {};
+ * | output |
+ * | --- |
+ * | "Personal Info" |
+ *
+ * @param {Personal_InfoInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const personal_info: ((
+ inputs?: Personal_InfoInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ Personal_InfoInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type Personal_InfoInputs = {}
diff --git a/packages/webui/src/paraglide/messages/personal_info.js b/packages/webui/src/paraglide/messages/personal_info.js
index 9d8de790..d91ee0e3 100644
--- a/packages/webui/src/paraglide/messages/personal_info.js
+++ b/packages/webui/src/paraglide/messages/personal_info.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Personal_InfoInputs */
const en_personal_info = /** @type {(inputs: Personal_InfoInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Personal Info`)
-};
+ return /** @type {LocalizedString} */ (`Personal Info`)
+}
const zh_personal_info = /** @type {(inputs: Personal_InfoInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`个人信息`)
-};
+ return /** @type {LocalizedString} */ (`个人信息`)
+}
/**
-* | output |
-* | --- |
-* | "Personal Info" |
-*
-* @param {Personal_InfoInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const personal_info = /** @type {((inputs?: Personal_InfoInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_personal_info(inputs)
- return zh_personal_info(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Personal Info" |
+ *
+ * @param {Personal_InfoInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const personal_info =
+ /** @type {((inputs?: Personal_InfoInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_personal_info(inputs)
+ return zh_personal_info(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/projects.d.ts b/packages/webui/src/paraglide/messages/projects.d.ts
index 9335f7bc..48ffe8dd 100644
--- a/packages/webui/src/paraglide/messages/projects.d.ts
+++ b/packages/webui/src/paraglide/messages/projects.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Projects" |
-*
-* @param {ProjectsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const projects: ((inputs?: ProjectsInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type ProjectsInputs = {};
+ * | output |
+ * | --- |
+ * | "Projects" |
+ *
+ * @param {ProjectsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const projects: ((
+ inputs?: ProjectsInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ ProjectsInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type ProjectsInputs = {}
diff --git a/packages/webui/src/paraglide/messages/projects.js b/packages/webui/src/paraglide/messages/projects.js
index b02b2363..86cd7f80 100644
--- a/packages/webui/src/paraglide/messages/projects.js
+++ b/packages/webui/src/paraglide/messages/projects.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} ProjectsInputs */
const en_projects = /** @type {(inputs: ProjectsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Projects`)
-};
+ return /** @type {LocalizedString} */ (`Projects`)
+}
const zh_projects = /** @type {(inputs: ProjectsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`项目`)
-};
+ return /** @type {LocalizedString} */ (`项目`)
+}
/**
-* | output |
-* | --- |
-* | "Projects" |
-*
-* @param {ProjectsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const projects = /** @type {((inputs?: ProjectsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_projects(inputs)
- return zh_projects(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Projects" |
+ *
+ * @param {ProjectsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const projects =
+ /** @type {((inputs?: ProjectsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_projects(inputs)
+ return zh_projects(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/recently_deleted_notice.d.ts b/packages/webui/src/paraglide/messages/recently_deleted_notice.d.ts
index 80ea2628..38fea3de 100644
--- a/packages/webui/src/paraglide/messages/recently_deleted_notice.d.ts
+++ b/packages/webui/src/paraglide/messages/recently_deleted_notice.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Items are automatically deleted after 30 days." |
-*
-* @param {Recently_Deleted_NoticeInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const recently_deleted_notice: ((inputs?: Recently_Deleted_NoticeInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type Recently_Deleted_NoticeInputs = {};
+ * | output |
+ * | --- |
+ * | "Items are automatically deleted after 30 days." |
+ *
+ * @param {Recently_Deleted_NoticeInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const recently_deleted_notice: ((
+ inputs?: Recently_Deleted_NoticeInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ Recently_Deleted_NoticeInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type Recently_Deleted_NoticeInputs = {}
diff --git a/packages/webui/src/paraglide/messages/recently_deleted_notice.js b/packages/webui/src/paraglide/messages/recently_deleted_notice.js
index 1516330c..2698857d 100644
--- a/packages/webui/src/paraglide/messages/recently_deleted_notice.js
+++ b/packages/webui/src/paraglide/messages/recently_deleted_notice.js
@@ -1,29 +1,34 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Recently_Deleted_NoticeInputs */
-const en_recently_deleted_notice = /** @type {(inputs: Recently_Deleted_NoticeInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Items are automatically deleted after 30 days.`)
-};
+const en_recently_deleted_notice =
+ /** @type {(inputs: Recently_Deleted_NoticeInputs) => LocalizedString} */ () => {
+ return /** @type {LocalizedString} */ (`Items are automatically deleted after 30 days.`)
+ }
-const zh_recently_deleted_notice = /** @type {(inputs: Recently_Deleted_NoticeInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`项目将在 30 天后自动删除。`)
-};
+const zh_recently_deleted_notice =
+ /** @type {(inputs: Recently_Deleted_NoticeInputs) => LocalizedString} */ () => {
+ return /** @type {LocalizedString} */ (`项目将在 30 天后自动删除。`)
+ }
/**
-* | output |
-* | --- |
-* | "Items are automatically deleted after 30 days." |
-*
-* @param {Recently_Deleted_NoticeInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const recently_deleted_notice = /** @type {((inputs?: Recently_Deleted_NoticeInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_recently_deleted_notice(inputs)
- return zh_recently_deleted_notice(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Items are automatically deleted after 30 days." |
+ *
+ * @param {Recently_Deleted_NoticeInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const recently_deleted_notice =
+ /** @type {((inputs?: Recently_Deleted_NoticeInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_recently_deleted_notice(inputs)
+ return zh_recently_deleted_notice(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/select_a_team.d.ts b/packages/webui/src/paraglide/messages/select_a_team.d.ts
index 30059d81..72acc074 100644
--- a/packages/webui/src/paraglide/messages/select_a_team.d.ts
+++ b/packages/webui/src/paraglide/messages/select_a_team.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Select a Team" |
-*
-* @param {Select_A_TeamInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const select_a_team: ((inputs?: Select_A_TeamInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type Select_A_TeamInputs = {};
+ * | output |
+ * | --- |
+ * | "Select a Team" |
+ *
+ * @param {Select_A_TeamInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const select_a_team: ((
+ inputs?: Select_A_TeamInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ Select_A_TeamInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type Select_A_TeamInputs = {}
diff --git a/packages/webui/src/paraglide/messages/select_a_team.js b/packages/webui/src/paraglide/messages/select_a_team.js
index 5a07bf8f..9b49e700 100644
--- a/packages/webui/src/paraglide/messages/select_a_team.js
+++ b/packages/webui/src/paraglide/messages/select_a_team.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Select_A_TeamInputs */
const en_select_a_team = /** @type {(inputs: Select_A_TeamInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Select a Team`)
-};
+ return /** @type {LocalizedString} */ (`Select a Team`)
+}
const zh_select_a_team = /** @type {(inputs: Select_A_TeamInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`选择团队`)
-};
+ return /** @type {LocalizedString} */ (`选择团队`)
+}
/**
-* | output |
-* | --- |
-* | "Select a Team" |
-*
-* @param {Select_A_TeamInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const select_a_team = /** @type {((inputs?: Select_A_TeamInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_select_a_team(inputs)
- return zh_select_a_team(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Select a Team" |
+ *
+ * @param {Select_A_TeamInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const select_a_team =
+ /** @type {((inputs?: Select_A_TeamInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_select_a_team(inputs)
+ return zh_select_a_team(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/select_asset_to_view_details.d.ts b/packages/webui/src/paraglide/messages/select_asset_to_view_details.d.ts
index 2193122e..f1b44417 100644
--- a/packages/webui/src/paraglide/messages/select_asset_to_view_details.d.ts
+++ b/packages/webui/src/paraglide/messages/select_asset_to_view_details.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Select an asset to view details" |
-*
-* @param {Select_Asset_To_View_DetailsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const select_asset_to_view_details: ((inputs?: Select_Asset_To_View_DetailsInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type Select_Asset_To_View_DetailsInputs = {};
+ * | output |
+ * | --- |
+ * | "Select an asset to view details" |
+ *
+ * @param {Select_Asset_To_View_DetailsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const select_asset_to_view_details: ((
+ inputs?: Select_Asset_To_View_DetailsInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ Select_Asset_To_View_DetailsInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type Select_Asset_To_View_DetailsInputs = {}
diff --git a/packages/webui/src/paraglide/messages/select_asset_to_view_details.js b/packages/webui/src/paraglide/messages/select_asset_to_view_details.js
index 1e5aa002..b06d1e6d 100644
--- a/packages/webui/src/paraglide/messages/select_asset_to_view_details.js
+++ b/packages/webui/src/paraglide/messages/select_asset_to_view_details.js
@@ -1,29 +1,34 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Select_Asset_To_View_DetailsInputs */
-const en_select_asset_to_view_details = /** @type {(inputs: Select_Asset_To_View_DetailsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Select an asset to view details`)
-};
+const en_select_asset_to_view_details =
+ /** @type {(inputs: Select_Asset_To_View_DetailsInputs) => LocalizedString} */ () => {
+ return /** @type {LocalizedString} */ (`Select an asset to view details`)
+ }
-const zh_select_asset_to_view_details = /** @type {(inputs: Select_Asset_To_View_DetailsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`选择资产查看详情`)
-};
+const zh_select_asset_to_view_details =
+ /** @type {(inputs: Select_Asset_To_View_DetailsInputs) => LocalizedString} */ () => {
+ return /** @type {LocalizedString} */ (`选择资产查看详情`)
+ }
/**
-* | output |
-* | --- |
-* | "Select an asset to view details" |
-*
-* @param {Select_Asset_To_View_DetailsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const select_asset_to_view_details = /** @type {((inputs?: Select_Asset_To_View_DetailsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_select_asset_to_view_details(inputs)
- return zh_select_asset_to_view_details(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Select an asset to view details" |
+ *
+ * @param {Select_Asset_To_View_DetailsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const select_asset_to_view_details =
+ /** @type {((inputs?: Select_Asset_To_View_DetailsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_select_asset_to_view_details(inputs)
+ return zh_select_asset_to_view_details(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/select_preferred_language.d.ts b/packages/webui/src/paraglide/messages/select_preferred_language.d.ts
index 56327cfe..0652530c 100644
--- a/packages/webui/src/paraglide/messages/select_preferred_language.d.ts
+++ b/packages/webui/src/paraglide/messages/select_preferred_language.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Select your preferred display language." |
-*
-* @param {Select_Preferred_LanguageInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const select_preferred_language: ((inputs?: Select_Preferred_LanguageInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type Select_Preferred_LanguageInputs = {};
+ * | output |
+ * | --- |
+ * | "Select your preferred display language." |
+ *
+ * @param {Select_Preferred_LanguageInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const select_preferred_language: ((
+ inputs?: Select_Preferred_LanguageInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ Select_Preferred_LanguageInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type Select_Preferred_LanguageInputs = {}
diff --git a/packages/webui/src/paraglide/messages/select_preferred_language.js b/packages/webui/src/paraglide/messages/select_preferred_language.js
index e77609fa..afe58f26 100644
--- a/packages/webui/src/paraglide/messages/select_preferred_language.js
+++ b/packages/webui/src/paraglide/messages/select_preferred_language.js
@@ -1,29 +1,34 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Select_Preferred_LanguageInputs */
-const en_select_preferred_language = /** @type {(inputs: Select_Preferred_LanguageInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Select your preferred display language.`)
-};
+const en_select_preferred_language =
+ /** @type {(inputs: Select_Preferred_LanguageInputs) => LocalizedString} */ () => {
+ return /** @type {LocalizedString} */ (`Select your preferred display language.`)
+ }
-const zh_select_preferred_language = /** @type {(inputs: Select_Preferred_LanguageInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`选择您首选的显示语言。`)
-};
+const zh_select_preferred_language =
+ /** @type {(inputs: Select_Preferred_LanguageInputs) => LocalizedString} */ () => {
+ return /** @type {LocalizedString} */ (`选择您首选的显示语言。`)
+ }
/**
-* | output |
-* | --- |
-* | "Select your preferred display language." |
-*
-* @param {Select_Preferred_LanguageInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const select_preferred_language = /** @type {((inputs?: Select_Preferred_LanguageInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_select_preferred_language(inputs)
- return zh_select_preferred_language(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Select your preferred display language." |
+ *
+ * @param {Select_Preferred_LanguageInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const select_preferred_language =
+ /** @type {((inputs?: Select_Preferred_LanguageInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_select_preferred_language(inputs)
+ return zh_select_preferred_language(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/settings.d.ts b/packages/webui/src/paraglide/messages/settings.d.ts
index 0742055d..31ac10e9 100644
--- a/packages/webui/src/paraglide/messages/settings.d.ts
+++ b/packages/webui/src/paraglide/messages/settings.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Settings" |
-*
-* @param {SettingsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const settings: ((inputs?: SettingsInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type SettingsInputs = {};
+ * | output |
+ * | --- |
+ * | "Settings" |
+ *
+ * @param {SettingsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const settings: ((
+ inputs?: SettingsInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ SettingsInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type SettingsInputs = {}
diff --git a/packages/webui/src/paraglide/messages/settings.js b/packages/webui/src/paraglide/messages/settings.js
index d678831d..67921ef3 100644
--- a/packages/webui/src/paraglide/messages/settings.js
+++ b/packages/webui/src/paraglide/messages/settings.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} SettingsInputs */
const en_settings = /** @type {(inputs: SettingsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Settings`)
-};
+ return /** @type {LocalizedString} */ (`Settings`)
+}
const zh_settings = /** @type {(inputs: SettingsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`设置`)
-};
+ return /** @type {LocalizedString} */ (`设置`)
+}
/**
-* | output |
-* | --- |
-* | "Settings" |
-*
-* @param {SettingsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const settings = /** @type {((inputs?: SettingsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_settings(inputs)
- return zh_settings(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Settings" |
+ *
+ * @param {SettingsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const settings =
+ /** @type {((inputs?: SettingsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_settings(inputs)
+ return zh_settings(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/uploads.d.ts b/packages/webui/src/paraglide/messages/uploads.d.ts
index fe46dcb3..1a28d63b 100644
--- a/packages/webui/src/paraglide/messages/uploads.d.ts
+++ b/packages/webui/src/paraglide/messages/uploads.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Uploads" |
-*
-* @param {UploadsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const uploads: ((inputs?: UploadsInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type UploadsInputs = {};
+ * | output |
+ * | --- |
+ * | "Uploads" |
+ *
+ * @param {UploadsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const uploads: ((
+ inputs?: UploadsInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ UploadsInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type UploadsInputs = {}
diff --git a/packages/webui/src/paraglide/messages/uploads.js b/packages/webui/src/paraglide/messages/uploads.js
index 56e4fbb4..4c0d2e66 100644
--- a/packages/webui/src/paraglide/messages/uploads.js
+++ b/packages/webui/src/paraglide/messages/uploads.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} UploadsInputs */
const en_uploads = /** @type {(inputs: UploadsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Uploads`)
-};
+ return /** @type {LocalizedString} */ (`Uploads`)
+}
const zh_uploads = /** @type {(inputs: UploadsInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`上传管理`)
-};
+ return /** @type {LocalizedString} */ (`上传管理`)
+}
/**
-* | output |
-* | --- |
-* | "Uploads" |
-*
-* @param {UploadsInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const uploads = /** @type {((inputs?: UploadsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_uploads(inputs)
- return zh_uploads(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Uploads" |
+ *
+ * @param {UploadsInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const uploads =
+ /** @type {((inputs?: UploadsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_uploads(inputs)
+ return zh_uploads(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/messages/welcome_back.d.ts b/packages/webui/src/paraglide/messages/welcome_back.d.ts
index 29788af4..da4930f2 100644
--- a/packages/webui/src/paraglide/messages/welcome_back.d.ts
+++ b/packages/webui/src/paraglide/messages/welcome_back.d.ts
@@ -1,16 +1,24 @@
/**
-* | output |
-* | --- |
-* | "Welcome Back" |
-*
-* @param {Welcome_BackInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const welcome_back: ((inputs?: Welcome_BackInputs, options?: {
- locale?: "en" | "zh";
-}) => LocalizedString) & import("../runtime.js").MessageMetadata;
-export type LocalizedString = import("../runtime.js").LocalizedString;
-export type Welcome_BackInputs = {};
+ * | output |
+ * | --- |
+ * | "Welcome Back" |
+ *
+ * @param {Welcome_BackInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const welcome_back: ((
+ inputs?: Welcome_BackInputs,
+ options?: {
+ locale?: 'en' | 'zh'
+ },
+) => LocalizedString) &
+ import('../runtime.js').MessageMetadata<
+ Welcome_BackInputs,
+ {
+ locale?: 'en' | 'zh'
+ },
+ {}
+ >
+export type LocalizedString = import('../runtime.js').LocalizedString
+export type Welcome_BackInputs = {}
diff --git a/packages/webui/src/paraglide/messages/welcome_back.js b/packages/webui/src/paraglide/messages/welcome_back.js
index f2551dcd..c4c03585 100644
--- a/packages/webui/src/paraglide/messages/welcome_back.js
+++ b/packages/webui/src/paraglide/messages/welcome_back.js
@@ -1,29 +1,32 @@
/* eslint-disable */
-import { getLocale, experimentalStaticLocale } from '../runtime.js';
+import { getLocale, experimentalStaticLocale } from '../runtime.js'
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Welcome_BackInputs */
const en_welcome_back = /** @type {(inputs: Welcome_BackInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`Welcome Back`)
-};
+ return /** @type {LocalizedString} */ (`Welcome Back`)
+}
const zh_welcome_back = /** @type {(inputs: Welcome_BackInputs) => LocalizedString} */ () => {
- return /** @type {LocalizedString} */ (`欢迎回来`)
-};
+ return /** @type {LocalizedString} */ (`欢迎回来`)
+}
/**
-* | output |
-* | --- |
-* | "Welcome Back" |
-*
-* @param {Welcome_BackInputs} inputs
-* @param {{ locale?: "en" | "zh" }} options
-* @returns {LocalizedString}
-*/
-export const welcome_back = /** @type {((inputs?: Welcome_BackInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => {
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
- if (locale === "en") return en_welcome_back(inputs)
- return zh_welcome_back(inputs)
-});
\ No newline at end of file
+ * | output |
+ * | --- |
+ * | "Welcome Back" |
+ *
+ * @param {Welcome_BackInputs} inputs
+ * @param {{ locale?: "en" | "zh" }} options
+ * @returns {LocalizedString}
+ */
+export const welcome_back =
+ /** @type {((inputs?: Welcome_BackInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ (
+ (inputs = {}, options = {}) => {
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
+ if (locale === 'en') return en_welcome_back(inputs)
+ return zh_welcome_back(inputs)
+ }
+ )
diff --git a/packages/webui/src/paraglide/registry.d.ts b/packages/webui/src/paraglide/registry.d.ts
index b9438f07..c0e44062 100644
--- a/packages/webui/src/paraglide/registry.d.ts
+++ b/packages/webui/src/paraglide/registry.d.ts
@@ -7,28 +7,60 @@
* @param {Intl.PluralRulesOptions} [options]
* @returns {string}
*/
-export function plural(locale: import("./runtime.js").Locale, input: unknown, options?: Intl.PluralRulesOptions): string;
+export function plural(
+ locale: import('./runtime.js').Locale,
+ input: unknown,
+ options?: Intl.PluralRulesOptions,
+): string
/**
* @param {import("./runtime.js").Locale} locale
* @param {unknown} input
* @param {Intl.NumberFormatOptions} [options]
* @returns {string}
*/
-export function number(locale: import("./runtime.js").Locale, input: unknown, options?: Intl.NumberFormatOptions): string;
+export function number(
+ locale: import('./runtime.js').Locale,
+ input: unknown,
+ options?: Intl.NumberFormatOptions,
+): string
/**
* @param {import("./runtime.js").Locale} locale
* @param {unknown} input
* @param {Intl.DateTimeFormatOptions} [options]
* @returns {string}
*/
-export function datetime(locale: import("./runtime.js").Locale, input: unknown, options?: Intl.DateTimeFormatOptions): string;
+export function datetime(
+ locale: import('./runtime.js').Locale,
+ input: unknown,
+ options?: Intl.DateTimeFormatOptions,
+): string
/**
* @param {import("./runtime.js").Locale} locale
* @param {unknown} input
* @param {Intl.RelativeTimeFormatOptions & { unit: RelativeTimeFormatUnit }} options
* @returns {string}
*/
-export function relativetime(locale: import("./runtime.js").Locale, input: unknown, options: Intl.RelativeTimeFormatOptions & {
- unit: RelativeTimeFormatUnit;
-}): string;
-export type RelativeTimeFormatUnit = "year" | "years" | "quarter" | "quarters" | "month" | "months" | "week" | "weeks" | "day" | "days" | "hour" | "hours" | "minute" | "minutes" | "second" | "seconds";
+export function relativetime(
+ locale: import('./runtime.js').Locale,
+ input: unknown,
+ options: Intl.RelativeTimeFormatOptions & {
+ unit: RelativeTimeFormatUnit
+ },
+): string
+export type RelativeTimeFormatUnit =
+ | 'year'
+ | 'years'
+ | 'quarter'
+ | 'quarters'
+ | 'month'
+ | 'months'
+ | 'week'
+ | 'weeks'
+ | 'day'
+ | 'days'
+ | 'hour'
+ | 'hours'
+ | 'minute'
+ | 'minutes'
+ | 'second'
+ | 'seconds'
diff --git a/packages/webui/src/paraglide/registry.js b/packages/webui/src/paraglide/registry.js
index 46b5d428..2f44bc82 100644
--- a/packages/webui/src/paraglide/registry.js
+++ b/packages/webui/src/paraglide/registry.js
@@ -10,9 +10,9 @@
* @param {Intl.PluralRulesOptions} [options]
* @returns {string}
*/
-export function plural(locale, input, options) {
- return new Intl.PluralRules(locale, options).select(Number(input))
-};
+export function plural(locale, input, options) {
+ return new Intl.PluralRules(locale, options).select(Number(input))
+}
/**
* @param {import("./runtime.js").Locale} locale
@@ -21,8 +21,8 @@ export function plural(locale, input, options) {
* @returns {string}
*/
export function number(locale, input, options) {
- return new Intl.NumberFormat(locale, options).format(Number(input))
-};
+ return new Intl.NumberFormat(locale, options).format(Number(input))
+}
/**
* @param {import("./runtime.js").Locale} locale
@@ -31,8 +31,8 @@ export function number(locale, input, options) {
* @returns {string}
*/
export function datetime(locale, input, options) {
- return new Intl.DateTimeFormat(locale, options).format(new Date(/** @type {string} */ (input)))
-};
+ return new Intl.DateTimeFormat(locale, options).format(new Date(/** @type {string} */ (input)))
+}
/**
* @param {import("./runtime.js").Locale} locale
@@ -41,6 +41,6 @@ export function datetime(locale, input, options) {
* @returns {string}
*/
export function relativetime(locale, input, options) {
- const { unit, ...intlOptions } = options;
- return new Intl.RelativeTimeFormat(locale, intlOptions).format(Number(input), unit);
-};
\ No newline at end of file
+ const { unit, ...intlOptions } = options
+ return new Intl.RelativeTimeFormat(locale, intlOptions).format(Number(input), unit)
+}
diff --git a/packages/webui/src/paraglide/runtime.d.ts b/packages/webui/src/paraglide/runtime.d.ts
index 7ebba567..f0a61028 100644
--- a/packages/webui/src/paraglide/runtime.d.ts
+++ b/packages/webui/src/paraglide/runtime.d.ts
@@ -7,14 +7,14 @@
* @param {string | URL} url
* @returns {typeof strategy}
*/
-export function getStrategyForUrl(url: string | URL): typeof strategy;
+export function getStrategyForUrl(url: string | URL): typeof strategy
/**
* Returns whether the given URL is excluded from middleware i18n processing.
*
* @param {string | URL} url
* @returns {boolean}
*/
-export function isExcludedByRouteStrategy(url: string | URL): boolean;
+export function isExcludedByRouteStrategy(url: string | URL): boolean
/**
* Sets the server side async local storage.
*
@@ -25,14 +25,16 @@ export function isExcludedByRouteStrategy(url: string | URL): boolean;
*
* @param {ParaglideAsyncLocalStorage | undefined} value
*/
-export function overwriteServerAsyncLocalStorage(value: ParaglideAsyncLocalStorage | undefined): void;
+export function overwriteServerAsyncLocalStorage(
+ value: ParaglideAsyncLocalStorage | undefined,
+): void
/**
* Resolve locale for a given URL using route-aware strategies.
*
* @param {string | URL} url
* @returns {Locale}
*/
-export function getLocaleForUrl(url: string | URL): Locale;
+export function getLocaleForUrl(url: string | URL): Locale
/**
* Get writing direction for a locale.
*
@@ -47,14 +49,14 @@ export function getLocaleForUrl(url: string | URL): Locale;
* @param {string} [locale] - Target locale. If not provided, uses `getLocale()`
* @returns {"ltr" | "rtl"}
*/
-export function getTextDirection(locale?: string): "ltr" | "rtl";
+export function getTextDirection(locale?: string): 'ltr' | 'rtl'
/**
* Coerces a locale-like string to the canonical locale value used by the runtime.
*
* @param {unknown} value
* @returns {Locale | undefined}
*/
-export function toLocale(value: unknown): Locale | undefined;
+export function toLocale(value: unknown): Locale | undefined
/**
* Check if something is an available locale with the canonical project casing.
*
@@ -70,7 +72,7 @@ export function toLocale(value: unknown): Locale | undefined;
* @param {unknown} locale
* @returns {locale is Locale}
*/
-export function isLocale(locale: unknown): locale is Locale;
+export function isLocale(locale: unknown): locale is Locale
/**
* Asserts that the input can be normalized to a locale.
*
@@ -78,7 +80,7 @@ export function isLocale(locale: unknown): locale is Locale;
* @returns {Locale} The input normalized to a Locale.
* @throws {Error} If the input is not a locale.
*/
-export function assertIsLocale(input: unknown): Locale;
+export function assertIsLocale(input: unknown): Locale
/**
* Extracts a cookie from the document.
*
@@ -87,7 +89,7 @@ export function assertIsLocale(input: unknown): Locale;
*
* @returns {Locale | undefined}
*/
-export function extractLocaleFromCookie(): Locale | undefined;
+export function extractLocaleFromCookie(): Locale | undefined
/**
* Extracts a locale from the accept-language header.
*
@@ -100,7 +102,7 @@ export function extractLocaleFromCookie(): Locale | undefined;
* @param {Request} request - The request object to extract the locale from.
* @returns {Locale | undefined} The negotiated preferred language.
*/
-export function extractLocaleFromHeader(request: Request): Locale | undefined;
+export function extractLocaleFromHeader(request: Request): Locale | undefined
/**
* Negotiates a preferred language from navigator.languages.
*
@@ -112,7 +114,7 @@ export function extractLocaleFromHeader(request: Request): Locale | undefined;
*
* @returns {Locale | undefined}
*/
-export function extractLocaleFromNavigator(): Locale | undefined;
+export function extractLocaleFromNavigator(): Locale | undefined
/**
* Extracts the locale from a given URL using native URLPattern.
*
@@ -123,7 +125,7 @@ export function extractLocaleFromNavigator(): Locale | undefined;
* @param {URL|string} url - The full URL from which to extract the locale.
* @returns {Locale|undefined} The extracted locale, or undefined if no locale is found.
*/
-export function extractLocaleFromUrl(url: URL | string): Locale | undefined;
+export function extractLocaleFromUrl(url: URL | string): Locale | undefined
/**
* Lower-level URL localization function, primarily used in server contexts.
*
@@ -168,9 +170,12 @@ export function extractLocaleFromUrl(url: URL | string): Locale | undefined;
* @param {Locale} [options.locale] - Target locale. If not provided, uses getLocale()
* @returns {URL} The localized URL, always absolute
*/
-export function localizeUrl(url: string | URL, options?: {
- locale?: Locale;
-}): URL;
+export function localizeUrl(
+ url: string | URL,
+ options?: {
+ locale?: Locale
+ },
+): URL
/**
* Low-level URL de-localization function, primarily used in server contexts.
*
@@ -210,7 +215,7 @@ export function localizeUrl(url: string | URL, options?: {
* @param {string | URL} url - The URL to de-localize. If string, must be absolute.
* @returns {URL} The de-localized URL, always absolute
*/
-export function deLocalizeUrl(url: string | URL): URL;
+export function deLocalizeUrl(url: string | URL): URL
/**
* Aggregates named groups from various parts of the URLPattern match result.
*
@@ -218,7 +223,7 @@ export function deLocalizeUrl(url: string | URL): URL;
* @param {any} match - The URLPattern match result object.
* @returns {Record} An object containing all named groups from the match.
*/
-export function aggregateGroups(match: any): Record;
+export function aggregateGroups(match: any): Record
/**
* @typedef {object} ShouldRedirectServerInput
* @property {Request} request
@@ -290,7 +295,7 @@ export function aggregateGroups(match: any): Record}
*/
-export function shouldRedirect(input?: ShouldRedirectInput): Promise;
+export function shouldRedirect(input?: ShouldRedirectInput): Promise
/**
* High-level URL localization function optimized for client-side UI usage.
*
@@ -331,9 +336,12 @@ export function shouldRedirect(input?: ShouldRedirectInput): Promise}
*/
-export const strategy: Array<"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage" | `custom-${string}`>;
+export const strategy: Array<
+ | 'cookie'
+ | 'baseLocale'
+ | 'globalVariable'
+ | 'url'
+ | 'preferredLanguage'
+ | 'localStorage'
+ | `custom-${string}`
+>
/**
* Route-level strategy overrides.
*
@@ -496,19 +518,27 @@ export const strategy: Array<"cookie" | "baseLocale" | "globalVariable" | "url"
* }>}
*/
export const routeStrategies: Array<{
- match: string;
- strategy?: Array<"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage" | `custom-${string}`>;
- exclude?: boolean;
-}>;
+ match: string
+ strategy?: Array<
+ | 'cookie'
+ | 'baseLocale'
+ | 'globalVariable'
+ | 'url'
+ | 'preferredLanguage'
+ | 'localStorage'
+ | `custom-${string}`
+ >
+ exclude?: boolean
+}>
/**
* The used URL patterns.
*
* @type {Array<{ pattern: string, localized: Array<[Locale, string]> }>}
*/
export const urlPatterns: Array<{
- pattern: string;
- localized: Array<[Locale, string]>;
-}>;
+ pattern: string
+ localized: Array<[Locale, string]>
+}>
/**
* @typedef {{
* getStore(): {
@@ -528,14 +558,14 @@ export const urlPatterns: Array<{
*
* @type {ParaglideAsyncLocalStorage | undefined}
*/
-export let serverAsyncLocalStorage: ParaglideAsyncLocalStorage | undefined;
-export const disableAsyncLocalStorage: false;
-export const experimentalMiddlewareLocaleSplitting: false;
-export const isServer: boolean;
+export let serverAsyncLocalStorage: ParaglideAsyncLocalStorage | undefined
+export const disableAsyncLocalStorage: false
+export const experimentalMiddlewareLocaleSplitting: false
+export const isServer: boolean
/** @type {Locale | undefined} */
-export const experimentalStaticLocale: Locale | undefined;
-export function getLocale(): Locale;
-export function overwriteGetLocale(fn: () => Locale): void;
+export const experimentalStaticLocale: Locale | undefined
+export function getLocale(): Locale
+export function overwriteGetLocale(fn: () => Locale): void
/**
* @typedef {(newLocale: Locale, options?: { reload?: boolean }) => void | Promise} SetLocaleFn
*/
@@ -560,8 +590,8 @@ export function overwriteGetLocale(fn: () => Locale): void;
*
* @type {SetLocaleFn}
*/
-export let setLocale: SetLocaleFn;
-export function overwriteSetLocale(fn: SetLocaleFn): void;
+export let setLocale: SetLocaleFn
+export function overwriteSetLocale(fn: SetLocaleFn): void
/**
* The origin of the current URL.
*
@@ -571,13 +601,23 @@ export function overwriteSetLocale(fn: SetLocaleFn): void;
*
* @type {() => string}
*/
-export let getUrlOrigin: () => string;
-export function overwriteGetUrlOrigin(fn: () => string): void;
-export function extractLocaleFromRequest(request: Request, options?: ExtractLocaleFromRequestOptions): Locale;
-export function extractLocaleFromRequestWithStrategies(request: Request, strategies: typeof strategy, url?: string | URL): Locale;
-export function extractLocaleFromRequestAsync(request: Request, options?: {
- effectiveRequestUrl?: string | URL;
-}): Promise;
+export let getUrlOrigin: () => string
+export function overwriteGetUrlOrigin(fn: () => string): void
+export function extractLocaleFromRequest(
+ request: Request,
+ options?: ExtractLocaleFromRequestOptions,
+): Locale
+export function extractLocaleFromRequestWithStrategies(
+ request: Request,
+ strategies: typeof strategy,
+ url?: string | URL,
+): Locale
+export function extractLocaleFromRequestAsync(
+ request: Request,
+ options?: {
+ effectiveRequestUrl?: string | URL
+ },
+): Promise
/**
* @typedef {"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage"} BuiltInStrategy
*/
@@ -597,73 +637,87 @@ export function extractLocaleFromRequestAsync(request: Request, options?: {
* @typedef {{ getLocale: () => Promise | (string | undefined), setLocale: (locale: string) => Promise | void }} CustomClientStrategyHandler
*/
/** @type {Map} */
-export const customServerStrategies: Map;
+export const customServerStrategies: Map
/** @type {Map} */
-export const customClientStrategies: Map;
+export const customClientStrategies: Map
export type ShouldRedirectServerInput = {
- request: Request;
- /**
- * - Effective request URL to use for route matching, locale detection with the URL strategy, and redirect targets.
- */
- effectiveRequestUrl?: string | URL;
- locale?: Locale;
-};
+ request: Request
+ /**
+ * - Effective request URL to use for route matching, locale detection with the URL strategy, and redirect targets.
+ */
+ effectiveRequestUrl?: string | URL
+ locale?: Locale
+}
export type ShouldRedirectClientInput = {
- request?: undefined;
- url?: string | URL;
- locale?: Locale;
-};
-export type ShouldRedirectInput = ShouldRedirectServerInput | ShouldRedirectClientInput;
+ request?: undefined
+ url?: string | URL
+ locale?: Locale
+}
+export type ShouldRedirectInput = ShouldRedirectServerInput | ShouldRedirectClientInput
export type ShouldRedirectResult = {
- /**
- * - Indicates whether the consumer should perform a redirect.
- */
- shouldRedirect: boolean;
- /**
- * - Locale resolved using the configured strategies.
- */
- locale: Locale;
- /**
- * - Destination URL when a redirect is required.
- */
- redirectUrl: URL | undefined;
-};
+ /**
+ * - Indicates whether the consumer should perform a redirect.
+ */
+ shouldRedirect: boolean
+ /**
+ * - Locale resolved using the configured strategies.
+ */
+ locale: Locale
+ /**
+ * - Destination URL when a redirect is required.
+ */
+ redirectUrl: URL | undefined
+}
export type ParaglideAsyncLocalStorage = {
- getStore(): {
- locale?: Locale;
- origin?: string;
- messageCalls?: Set;
- } | undefined;
- run: (store: {
- locale?: Locale;
- origin?: string;
- messageCalls?: Set;
- }, cb: any) => any;
-};
-export type SetLocaleFn = (newLocale: Locale, options?: {
- reload?: boolean;
-}) => void | Promise;
+ getStore():
+ | {
+ locale?: Locale
+ origin?: string
+ messageCalls?: Set
+ }
+ | undefined
+ run: (
+ store: {
+ locale?: Locale
+ origin?: string
+ messageCalls?: Set
+ },
+ cb: any,
+ ) => any
+}
+export type SetLocaleFn = (
+ newLocale: Locale,
+ options?: {
+ reload?: boolean
+ },
+) => void | Promise
export type ExtractLocaleFromRequestOptions = {
- /**
- * - Effective request URL to use for route matching and locale detection with the URL strategy.
- */
- effectiveRequestUrl?: string | URL;
-};
-export type BuiltInStrategy = "cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage";
-export type CustomStrategy = `custom_${string}`;
-export type Strategy = BuiltInStrategy | CustomStrategy;
-export type Strategies = Array;
+ /**
+ * - Effective request URL to use for route matching and locale detection with the URL strategy.
+ */
+ effectiveRequestUrl?: string | URL
+}
+export type BuiltInStrategy =
+ | 'cookie'
+ | 'baseLocale'
+ | 'globalVariable'
+ | 'url'
+ | 'preferredLanguage'
+ | 'localStorage'
+export type CustomStrategy = `custom_${string}`
+export type Strategy = BuiltInStrategy | CustomStrategy
+export type Strategies = Array
export type CustomServerStrategyHandler = {
- getLocale: (request?: Request) => Promise | (string | undefined);
-};
+ getLocale: (request?: Request) => Promise | (string | undefined)
+}
export type CustomClientStrategyHandler = {
- getLocale: () => Promise | (string | undefined);
- setLocale: (locale: string) => Promise | void;
-};
+ getLocale: () => Promise | (string | undefined)
+ setLocale: (locale: string) => Promise | void
+}
/**
* A locale that is available in the project.
*/
-export type Locale = (typeof locales)[number];
+export type Locale = (typeof locales)[number]
/**
* A branded type representing a localized string.
*
@@ -676,83 +730,94 @@ export type Locale = (typeof locales)[number];
* backward compatible—you can pass it anywhere a \`string\` is expected.
*/
export type LocalizedString = string & {
- readonly __brand: "LocalizedString";
-};
+ readonly __brand: 'LocalizedString'
+}
/**
* A single markup option passed to a tag instance.
*/
export type MessageMarkupOption = {
- name: string;
- value: unknown;
-};
+ name: string
+ value: unknown
+}
/**
* A single static markup attribute attached to a tag instance.
*/
export type MessageMarkupAttribute = {
- name: string;
- value: string | true;
-};
+ name: string
+ value: string | true
+}
/**
* Record of markup options for a tag instance.
*/
-export type MessageMarkupOptions = Record;
+export type MessageMarkupOptions = Record
/**
* Record of markup attributes for a tag instance.
*/
-export type MessageMarkupAttributes = Record;
+export type MessageMarkupAttributes = Record
/**
* Type-level schema for a single markup tag.
*/
export type MessageMarkupTag = {
- options: MessageMarkupOptions;
- attributes: MessageMarkupAttributes;
- children: boolean;
-};
+ options: MessageMarkupOptions
+ attributes: MessageMarkupAttributes
+ children: boolean
+}
/**
* Type-level schema for all markup tags in a message.
*/
-export type MessageMarkupSchema = Record;
+export type MessageMarkupSchema = Record
/**
* Type-only metadata attached to compiled message functions.
*/
-export type MessageMetadata> = {
- readonly __paraglide?: {
- inputs: Inputs;
- options: Options;
- markup: Markup;
- };
-};
+export type MessageMetadata<
+ Inputs,
+ Options,
+ Markup extends MessageMarkupSchema = Record,
+> = {
+ readonly __paraglide?: {
+ inputs: Inputs
+ options: Options
+ markup: Markup
+ }
+}
/**
* A compiled, framework-neutral message part.
*/
-export type MessagePart = {
- type: "text";
- value: string;
-} | {
- type: "markup-start";
- name: string;
- options: MessageMarkupOptions;
- attributes: MessageMarkupAttributes;
-} | {
- type: "markup-end";
- name: string;
- options: MessageMarkupOptions;
- attributes: MessageMarkupAttributes;
-} | {
- type: "markup-standalone";
- name: string;
- options: MessageMarkupOptions;
- attributes: MessageMarkupAttributes;
-};
+export type MessagePart =
+ | {
+ type: 'text'
+ value: string
+ }
+ | {
+ type: 'markup-start'
+ name: string
+ options: MessageMarkupOptions
+ attributes: MessageMarkupAttributes
+ }
+ | {
+ type: 'markup-end'
+ name: string
+ options: MessageMarkupOptions
+ attributes: MessageMarkupAttributes
+ }
+ | {
+ type: 'markup-standalone'
+ name: string
+ options: MessageMarkupOptions
+ attributes: MessageMarkupAttributes
+ }
/**
* A message function is a message for a specific locale.
*/
-export type MessageFunction = (inputs?: Record) => LocalizedString;
+export type MessageFunction = (inputs?: Record) => LocalizedString
/**
* A message bundle function that selects the message to be returned.
*
* Uses `getLocale()` under the hood to determine the locale with an option.
*/
-export type MessageBundleFunction = (params: Record, options: {
- locale: T;
-}) => LocalizedString;
+export type MessageBundleFunction = (
+ params: Record,
+ options: {
+ locale: T
+ },
+) => LocalizedString
diff --git a/packages/webui/src/paraglide/runtime.js b/packages/webui/src/paraglide/runtime.js
index 99279263..1ddb6136 100644
--- a/packages/webui/src/paraglide/runtime.js
+++ b/packages/webui/src/paraglide/runtime.js
@@ -11,7 +11,7 @@ const URLPattern = {}
* // do something
* }
*/
-export const baseLocale = "en";
+export const baseLocale = 'en'
/**
* The project's locales that have been specified in the settings.
*
@@ -20,23 +20,19 @@ export const baseLocale = "en";
* throw new Error('Locale is not available');
* }
*/
-export const locales = /** @type {const} */ (["en","zh"]);
+export const locales = /** @type {const} */ (['en', 'zh'])
/** @type {string} */
-export const cookieName = "PARAGLIDE_LOCALE";
+export const cookieName = 'PARAGLIDE_LOCALE'
/** @type {number} */
-export const cookieMaxAge = 34560000;
+export const cookieMaxAge = 34560000
/** @type {string} */
-export const cookieDomain = "";
+export const cookieDomain = ''
/** @type {string} */
-export const localStorageKey = "PARAGLIDE_LOCALE";
+export const localStorageKey = 'PARAGLIDE_LOCALE'
/**
* @type {Array<"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage" | `custom-${string}`>}
*/
-export const strategy = [
- "cookie",
- "globalVariable",
- "baseLocale"
-];
+export const strategy = ['cookie', 'globalVariable', 'baseLocale']
/**
* Route-level strategy overrides.
*
@@ -48,7 +44,7 @@ export const strategy = [
* exclude?: boolean;
* }>}
*/
-export const routeStrategies = [];
+export const routeStrategies = []
/**
* The used URL patterns.
*
@@ -56,47 +52,41 @@ export const routeStrategies = [];
*/
export const urlPatterns = [
{
- "pattern": ":protocol://:domain(.*)::port?/:path(.*)?",
- "localized": [
- [
- "zh",
- ":protocol://:domain(.*)::port?/zh/:path(.*)?"
- ],
- [
- "en",
- ":protocol://:domain(.*)::port?/:path(.*)?"
- ]
- ]
- }
-];
+ pattern: ':protocol://:domain(.*)::port?/:path(.*)?',
+ localized: [
+ ['zh', ':protocol://:domain(.*)::port?/zh/:path(.*)?'],
+ ['en', ':protocol://:domain(.*)::port?/:path(.*)?'],
+ ],
+ },
+]
/** @type {string | undefined} */
-let cachedRouteStrategyUrl;
+let cachedRouteStrategyUrl
/** @type {{ match: string; strategy?: typeof strategy; exclude?: boolean } | undefined} */
-let cachedRouteStrategy;
+let cachedRouteStrategy
/**
* @param {string | URL} url
* @returns {{ match: string; strategy?: typeof strategy; exclude?: boolean } | undefined}
*/
function findMatchingRouteStrategy(url) {
- if (routeStrategies.length === 0) {
- return undefined;
+ if (routeStrategies.length === 0) {
+ return undefined
+ }
+ const urlString = typeof url === 'string' ? url : url.href
+ if (cachedRouteStrategyUrl === urlString) {
+ return cachedRouteStrategy
+ }
+ const urlObject = new URL(urlString, 'http://dummy.com')
+ let match
+ for (const routeStrategy of routeStrategies) {
+ const pattern = new URLPattern(routeStrategy.match, urlObject.href)
+ if (pattern.exec(urlObject.href)) {
+ match = routeStrategy
+ break
}
- const urlString = typeof url === "string" ? url : url.href;
- if (cachedRouteStrategyUrl === urlString) {
- return cachedRouteStrategy;
- }
- const urlObject = new URL(urlString, "http://dummy.com");
- let match;
- for (const routeStrategy of routeStrategies) {
- const pattern = new URLPattern(routeStrategy.match, urlObject.href);
- if (pattern.exec(urlObject.href)) {
- match = routeStrategy;
- break;
- }
- }
- cachedRouteStrategyUrl = urlString;
- cachedRouteStrategy = match;
- return match;
+ }
+ cachedRouteStrategyUrl = urlString
+ cachedRouteStrategy = match
+ return match
}
/**
* Returns the strategy to use for a specific URL.
@@ -108,13 +98,11 @@ function findMatchingRouteStrategy(url) {
* @returns {typeof strategy}
*/
export function getStrategyForUrl(url) {
- const routeStrategy = findMatchingRouteStrategy(url);
- if (routeStrategy &&
- routeStrategy.exclude !== true &&
- Array.isArray(routeStrategy.strategy)) {
- return routeStrategy.strategy;
- }
- return strategy;
+ const routeStrategy = findMatchingRouteStrategy(url)
+ if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
+ return routeStrategy.strategy
+ }
+ return strategy
}
/**
* Returns whether the given URL is excluded from middleware i18n processing.
@@ -123,7 +111,7 @@ export function getStrategyForUrl(url) {
* @returns {boolean}
*/
export function isExcludedByRouteStrategy(url) {
- return findMatchingRouteStrategy(url)?.exclude === true;
+ return findMatchingRouteStrategy(url)?.exclude === true
}
/**
* @typedef {{
@@ -144,12 +132,12 @@ export function isExcludedByRouteStrategy(url) {
*
* @type {ParaglideAsyncLocalStorage | undefined}
*/
-export let serverAsyncLocalStorage = undefined;
-export const disableAsyncLocalStorage = false;
-export const experimentalMiddlewareLocaleSplitting = false;
-export const isServer = typeof window === 'undefined';
+export let serverAsyncLocalStorage = undefined
+export const disableAsyncLocalStorage = false
+export const experimentalMiddlewareLocaleSplitting = false
+export const isServer = typeof window === 'undefined'
/** @type {Locale | undefined} */
-export const experimentalStaticLocale = undefined;
+export const experimentalStaticLocale = undefined
/**
* Sets the server side async local storage.
*
@@ -161,19 +149,18 @@ export const experimentalStaticLocale = undefined;
* @param {ParaglideAsyncLocalStorage | undefined} value
*/
export function overwriteServerAsyncLocalStorage(value) {
- serverAsyncLocalStorage = value;
+ serverAsyncLocalStorage = value
}
-const TREE_SHAKE_COOKIE_STRATEGY_USED = true;
-const TREE_SHAKE_URL_STRATEGY_USED = false;
-const TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = true;
-const TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = false;
-const TREE_SHAKE_DEFAULT_URL_PATTERN_USED = true;
-const TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
+const TREE_SHAKE_COOKIE_STRATEGY_USED = true
+const TREE_SHAKE_URL_STRATEGY_USED = false
+const TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = true
+const TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = false
+const TREE_SHAKE_DEFAULT_URL_PATTERN_USED = true
+const TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false
-/** @type {any} */ (globalThis).__paraglide =
- /** @type {any} */ (globalThis).__paraglide ?? {};
-/** @type {any} */ (globalThis).__paraglide.ssr =
- /** @type {any} */ (globalThis).__paraglide.ssr ?? {};
+/** @type {any} */ ;(globalThis).__paraglide = /** @type {any} */ (globalThis).__paraglide ?? {}
+/** @type {any} */ ;(globalThis).__paraglide.ssr =
+ /** @type {any} */ (globalThis).__paraglide.ssr ?? {}
/**
* This is a fallback to get started with a custom
@@ -184,8 +171,8 @@ const TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
*
* @type {Locale | undefined}
*/
-let _locale;
-let localeInitiallySet = false;
+let _locale
+let localeInitiallySet = false
/**
* Get the current locale.
*
@@ -205,33 +192,36 @@ let localeInitiallySet = false;
* @returns {Locale} The current locale.
*/
export let getLocale = () => {
- if (experimentalStaticLocale !== undefined) {
- return experimentalStaticLocale;
+ if (experimentalStaticLocale !== undefined) {
+ return experimentalStaticLocale
+ }
+ // if running in a server-side rendering context
+ // retrieve the locale from the async local storage
+ if (serverAsyncLocalStorage) {
+ const locale = serverAsyncLocalStorage?.getStore()?.locale
+ if (locale) {
+ return locale
}
- // if running in a server-side rendering context
- // retrieve the locale from the async local storage
- if (serverAsyncLocalStorage) {
- const locale = serverAsyncLocalStorage?.getStore()?.locale;
- if (locale) {
- return locale;
- }
+ }
+ let strategyToUse = strategy
+ if (!isServer && typeof window !== 'undefined' && window.location?.href) {
+ strategyToUse = getStrategyForUrl(window.location.href)
+ }
+ const resolved = resolveLocaleWithStrategies(
+ strategyToUse,
+ typeof window !== 'undefined' ? window.location?.href : undefined,
+ )
+ if (resolved) {
+ if (!localeInitiallySet) {
+ _locale = resolved
+ // https://github.com/opral/inlang-paraglide-js/issues/455
+ localeInitiallySet = true
+ setLocale(resolved, { reload: false })
}
- let strategyToUse = strategy;
- if (!isServer && typeof window !== "undefined" && window.location?.href) {
- strategyToUse = getStrategyForUrl(window.location.href);
- }
- const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
- if (resolved) {
- if (!localeInitiallySet) {
- _locale = resolved;
- // https://github.com/opral/inlang-paraglide-js/issues/455
- localeInitiallySet = true;
- setLocale(resolved, { reload: false });
- }
- return resolved;
- }
- throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
-};
+ return resolved
+ }
+ throw new Error('No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found')
+}
/**
* Resolve locale for a given URL using route-aware strategies.
*
@@ -239,15 +229,18 @@ export let getLocale = () => {
* @returns {Locale}
*/
export function getLocaleForUrl(url) {
- if (experimentalStaticLocale !== undefined) {
- return experimentalStaticLocale;
- }
- const strategyToUse = getStrategyForUrl(url);
- const resolved = resolveLocaleWithStrategies(strategyToUse, typeof url === "string" ? url : url.href);
- if (resolved) {
- return resolved;
- }
- throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
+ if (experimentalStaticLocale !== undefined) {
+ return experimentalStaticLocale
+ }
+ const strategyToUse = getStrategyForUrl(url)
+ const resolved = resolveLocaleWithStrategies(
+ strategyToUse,
+ typeof url === 'string' ? url : url.href,
+ )
+ if (resolved) {
+ return resolved
+ }
+ throw new Error('No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found')
}
/**
* @param {typeof strategy} strategyToUse
@@ -255,56 +248,54 @@ export function getLocaleForUrl(url) {
* @returns {Locale | undefined}
*/
function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
- /** @type {string | undefined} */
- let locale;
- for (const strat of strategyToUse) {
- if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
- locale = extractLocaleFromCookie();
+ /** @type {string | undefined} */
+ let locale
+ for (const strat of strategyToUse) {
+ if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === 'cookie') {
+ locale = extractLocaleFromCookie()
+ } else if (strat === 'baseLocale') {
+ locale = baseLocale
+ } else if (
+ TREE_SHAKE_URL_STRATEGY_USED &&
+ strat === 'url' &&
+ !isServer &&
+ typeof urlForUrlStrategy === 'string'
+ ) {
+ locale = extractLocaleFromUrl(urlForUrlStrategy)
+ } else if (
+ TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED &&
+ strat === 'globalVariable' &&
+ _locale !== undefined
+ ) {
+ locale = _locale
+ } else if (
+ TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED &&
+ strat === 'preferredLanguage' &&
+ !isServer
+ ) {
+ locale = extractLocaleFromNavigator()
+ } else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === 'localStorage' && !isServer) {
+ locale = localStorage.getItem(localStorageKey) ?? undefined
+ } else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
+ const handler = customClientStrategies.get(strat)
+ if (handler) {
+ const result = handler.getLocale()
+ // Handle both sync and async results - skip async in sync getLocale
+ if (result instanceof Promise) {
+ // Can't await in sync function, skip async strategies
+ continue
}
- else if (strat === "baseLocale") {
- locale = baseLocale;
- }
- else if (TREE_SHAKE_URL_STRATEGY_USED &&
- strat === "url" &&
- !isServer &&
- typeof urlForUrlStrategy === "string") {
- locale = extractLocaleFromUrl(urlForUrlStrategy);
- }
- else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED &&
- strat === "globalVariable" &&
- _locale !== undefined) {
- locale = _locale;
- }
- else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED &&
- strat === "preferredLanguage" &&
- !isServer) {
- locale = extractLocaleFromNavigator();
- }
- else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED &&
- strat === "localStorage" &&
- !isServer) {
- locale = localStorage.getItem(localStorageKey) ?? undefined;
- }
- else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
- const handler = customClientStrategies.get(strat);
- if (handler) {
- const result = handler.getLocale();
- // Handle both sync and async results - skip async in sync getLocale
- if (result instanceof Promise) {
- // Can't await in sync function, skip async strategies
- continue;
- }
- if (result !== undefined) {
- return assertIsLocale(result);
- }
- }
- }
- const matchedLocale = toLocale(locale);
- if (matchedLocale) {
- return matchedLocale;
+ if (result !== undefined) {
+ return assertIsLocale(result)
}
+ }
}
- return undefined;
+ const matchedLocale = toLocale(locale)
+ if (matchedLocale) {
+ return matchedLocale
+ }
+ }
+ return undefined
}
/**
* Overwrite the `getLocale()` function.
@@ -322,22 +313,10 @@ function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
* @param {() => Locale} fn - The new implementation for `getLocale()`.
*/
export const overwriteGetLocale = (fn) => {
- getLocale = fn;
-};
+ getLocale = fn
+}
-const rtlLanguages = new Set([
- "ar",
- "dv",
- "fa",
- "he",
- "ks",
- "ku",
- "ps",
- "sd",
- "ug",
- "ur",
- "yi",
-]);
+const rtlLanguages = new Set(['ar', 'dv', 'fa', 'he', 'ks', 'ku', 'ps', 'sd', 'ug', 'ur', 'yi'])
/**
* Get writing direction for a locale.
*
@@ -353,21 +332,20 @@ const rtlLanguages = new Set([
* @returns {"ltr" | "rtl"}
*/
export function getTextDirection(locale = getLocale()) {
- try {
- const intlLocale = /** @type {Intl.Locale & {
+ try {
+ const intlLocale = /** @type {Intl.Locale & {
getTextInfo?: () => { direction?: string };
textInfo?: { direction?: string };
- }} */ (new Intl.Locale(locale));
- const direction = intlLocale.getTextInfo?.().direction ?? intlLocale.textInfo?.direction;
- if (direction === "ltr" || direction === "rtl") {
- return direction;
- }
+ }} */ (new Intl.Locale(locale))
+ const direction = intlLocale.getTextInfo?.().direction ?? intlLocale.textInfo?.direction
+ if (direction === 'ltr' || direction === 'rtl') {
+ return direction
}
- catch {
- // Ignore Intl.Locale parsing/runtime errors and use fallback below.
- }
- const language = locale.split("-")[0]?.toLowerCase();
- return rtlLanguages.has(language ?? "") ? "rtl" : "ltr";
+ } catch {
+ // Ignore Intl.Locale parsing/runtime errors and use fallback below.
+ }
+ const language = locale.split('-')[0]?.toLowerCase()
+ return rtlLanguages.has(language ?? '') ? 'rtl' : 'ltr'
}
/**
@@ -376,15 +354,14 @@ export function getTextDirection(locale = getLocale()) {
* @param {string} [newLocation] The new location
*/
const navigateOrReload = (newLocation) => {
- if (newLocation) {
- // reload the page by navigating to the new url
- window.location.href = newLocation;
- }
- else {
- // reload the page to reflect the new locale
- window.location.reload();
- }
-};
+ if (newLocation) {
+ // reload the page by navigating to the new url
+ window.location.href = newLocation
+ } else {
+ // reload the page to reflect the new locale
+ window.location.reload()
+ }
+}
/**
* @typedef {(newLocale: Locale, options?: { reload?: boolean }) => void | Promise} SetLocaleFn
*/
@@ -410,104 +387,90 @@ const navigateOrReload = (newLocation) => {
* @type {SetLocaleFn}
*/
export let setLocale = (newLocale, options) => {
- const optionsWithDefaults = {
- reload: true,
- ...options,
- };
- // locale is already set
- // https://github.com/opral/inlang-paraglide-js/issues/430
- /** @type {Locale | undefined} */
- let currentLocale;
- try {
- currentLocale = getLocale();
+ const optionsWithDefaults = {
+ reload: true,
+ ...options,
+ }
+ // locale is already set
+ // https://github.com/opral/inlang-paraglide-js/issues/430
+ /** @type {Locale | undefined} */
+ let currentLocale
+ try {
+ currentLocale = getLocale()
+ } catch {
+ // do nothing, no locale has been set yet.
+ }
+ /** @type {Array>} */
+ const customSetLocalePromises = []
+ /** @type {string | undefined} */
+ let newLocation = undefined
+ let strategyToUse = strategy
+ if (!isServer && typeof window !== 'undefined' && window.location?.href) {
+ strategyToUse = getStrategyForUrl(window.location.href)
+ }
+ for (const strat of strategyToUse) {
+ if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === 'globalVariable') {
+ // a default for a custom strategy to get started quickly
+ // is likely overwritten by `defineSetLocale()`
+ _locale = newLocale
+ } else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === 'cookie') {
+ if (isServer || typeof document === 'undefined' || typeof window === 'undefined') {
+ continue
+ }
+ // set the cookie
+ const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`
+ document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString
+ } else if (strat === 'baseLocale') {
+ // nothing to be set here. baseLocale is only a fallback
+ continue
+ } else if (TREE_SHAKE_URL_STRATEGY_USED && strat === 'url' && typeof window !== 'undefined') {
+ // route to the new url
+ //
+ // this triggers a page reload but a user rarely
+ // switches locales, so this should be fine.
+ //
+ // if the behavior is not desired, the implementation
+ // can be overwritten by `defineSetLocale()` to avoid
+ // a full page reload.
+ newLocation = localizeUrl(window.location.href, {
+ locale: newLocale,
+ }).href
+ } else if (
+ TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED &&
+ strat === 'localStorage' &&
+ typeof window !== 'undefined'
+ ) {
+ // set the localStorage
+ localStorage.setItem(localStorageKey, newLocale)
+ } else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
+ const handler = customClientStrategies.get(strat)
+ if (handler) {
+ let result = handler.setLocale(newLocale)
+ // Handle async setLocale
+ if (result instanceof Promise) {
+ result = result.catch((error) => {
+ throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
+ cause: error,
+ })
+ })
+ customSetLocalePromises.push(result)
+ }
+ }
}
- catch {
- // do nothing, no locale has been set yet.
+ }
+ const runReload = () => {
+ if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
+ navigateOrReload(newLocation)
}
- /** @type {Array>} */
- const customSetLocalePromises = [];
- /** @type {string | undefined} */
- let newLocation = undefined;
- let strategyToUse = strategy;
- if (!isServer && typeof window !== "undefined" && window.location?.href) {
- strategyToUse = getStrategyForUrl(window.location.href);
- }
- for (const strat of strategyToUse) {
- if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED &&
- strat === "globalVariable") {
- // a default for a custom strategy to get started quickly
- // is likely overwritten by `defineSetLocale()`
- _locale = newLocale;
- }
- else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
- if (isServer ||
- typeof document === "undefined" ||
- typeof window === "undefined") {
- continue;
- }
- // set the cookie
- const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
- document.cookie = cookieDomain
- ? `${cookieString}; domain=${cookieDomain}`
- : cookieString;
- }
- else if (strat === "baseLocale") {
- // nothing to be set here. baseLocale is only a fallback
- continue;
- }
- else if (TREE_SHAKE_URL_STRATEGY_USED &&
- strat === "url" &&
- typeof window !== "undefined") {
- // route to the new url
- //
- // this triggers a page reload but a user rarely
- // switches locales, so this should be fine.
- //
- // if the behavior is not desired, the implementation
- // can be overwritten by `defineSetLocale()` to avoid
- // a full page reload.
- newLocation = localizeUrl(window.location.href, {
- locale: newLocale,
- }).href;
- }
- else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED &&
- strat === "localStorage" &&
- typeof window !== "undefined") {
- // set the localStorage
- localStorage.setItem(localStorageKey, newLocale);
- }
- else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
- const handler = customClientStrategies.get(strat);
- if (handler) {
- let result = handler.setLocale(newLocale);
- // Handle async setLocale
- if (result instanceof Promise) {
- result = result.catch((error) => {
- throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
- cause: error,
- });
- });
- customSetLocalePromises.push(result);
- }
- }
- }
- }
- const runReload = () => {
- if (!isServer &&
- optionsWithDefaults.reload &&
- window.location &&
- newLocale !== currentLocale) {
- navigateOrReload(newLocation);
- }
- };
- if (customSetLocalePromises.length) {
- return Promise.all(customSetLocalePromises).then(() => {
- runReload();
- });
- }
- runReload();
- return;
-};
+ }
+ if (customSetLocalePromises.length) {
+ return Promise.all(customSetLocalePromises).then(() => {
+ runReload()
+ })
+ }
+ runReload()
+ return
+}
/**
* Overwrite the `setLocale()` function.
*
@@ -523,8 +486,8 @@ export let setLocale = (newLocale, options) => {
* @param {SetLocaleFn} fn
*/
export const overwriteSetLocale = (fn) => {
- setLocale = fn;
-};
+ setLocale = fn
+}
/**
* The origin of the current URL.
@@ -536,14 +499,13 @@ export const overwriteSetLocale = (fn) => {
* @type {() => string}
*/
export let getUrlOrigin = () => {
- if (serverAsyncLocalStorage) {
- return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
- }
- else if (typeof window !== "undefined") {
- return window.location.origin;
- }
- return "http://fallback.com";
-};
+ if (serverAsyncLocalStorage) {
+ return serverAsyncLocalStorage.getStore()?.origin ?? 'http://fallback.com'
+ } else if (typeof window !== 'undefined') {
+ return window.location.origin
+ }
+ return 'http://fallback.com'
+}
/**
* Overwrite the getUrlOrigin function.
*
@@ -553,8 +515,8 @@ export let getUrlOrigin = () => {
* @param {() => string} fn - The new implementation for `getUrlOrigin()`.
*/
export let overwriteGetUrlOrigin = (fn) => {
- getUrlOrigin = fn;
-};
+ getUrlOrigin = fn
+}
/**
* Coerces a locale-like string to the canonical locale value used by the runtime.
@@ -563,16 +525,16 @@ export let overwriteGetUrlOrigin = (fn) => {
* @returns {Locale | undefined}
*/
export function toLocale(value) {
- if (typeof value !== "string") {
- return undefined;
+ if (typeof value !== 'string') {
+ return undefined
+ }
+ const lowerValue = value.toLowerCase()
+ for (const locale of locales) {
+ if (locale.toLowerCase() === lowerValue) {
+ return locale
}
- const lowerValue = value.toLowerCase();
- for (const locale of locales) {
- if (locale.toLowerCase() === lowerValue) {
- return locale;
- }
- }
- return undefined;
+ }
+ return undefined
}
/**
* Check if something is an available locale with the canonical project casing.
@@ -590,7 +552,7 @@ export function toLocale(value) {
* @returns {locale is Locale}
*/
export function isLocale(locale) {
- return !!locale && locales.some((item) => item === locale);
+ return !!locale && locales.some((item) => item === locale)
}
/**
* Asserts that the input can be normalized to a locale.
@@ -600,10 +562,9 @@ export function isLocale(locale) {
* @throws {Error} If the input is not a locale.
*/
export function assertIsLocale(input) {
- const locale = toLocale(input);
- if (locale)
- return locale;
- throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
+ const locale = toLocale(input)
+ if (locale) return locale
+ throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(', ')}`)
}
/**
@@ -631,9 +592,13 @@ export function assertIsLocale(input) {
* @returns {Locale}
*/
export const extractLocaleFromRequest = (request, options = {}) => {
- const effectiveRequestUrl = resolveEffectiveRequestUrl(request, options.effectiveRequestUrl);
- return extractLocaleFromRequestWithStrategies(request, getStrategyForUrl(effectiveRequestUrl), effectiveRequestUrl);
-};
+ const effectiveRequestUrl = resolveEffectiveRequestUrl(request, options.effectiveRequestUrl)
+ return extractLocaleFromRequestWithStrategies(
+ request,
+ getStrategyForUrl(effectiveRequestUrl),
+ effectiveRequestUrl,
+ )
+}
/**
* Extracts a locale from a request using the provided strategy order.
*
@@ -643,55 +608,50 @@ export const extractLocaleFromRequest = (request, options = {}) => {
* @returns {Locale}
*/
export const extractLocaleFromRequestWithStrategies = (request, strategies, url = request.url) => {
- const effectiveRequestUrl = resolveEffectiveRequestUrl(request, url);
- /** @type {string|undefined} */
- let locale;
- for (const strat of strategies) {
- if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
- locale = request.headers
- .get("cookie")
- ?.split("; ")
- .find((c) => c.startsWith(cookieName + "="))
- ?.split("=")[1];
- }
- else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url") {
- locale = extractLocaleFromUrl(effectiveRequestUrl);
- }
- else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED &&
- strat === "preferredLanguage") {
- locale = extractLocaleFromHeader(request);
- }
- else if (strat === "globalVariable") {
- locale = _locale;
- }
- else if (strat === "baseLocale") {
- return baseLocale;
- }
- else if (strat === "localStorage") {
- continue;
- }
- else if (isCustomStrategy(strat)) {
- // Custom strategies are not supported in sync version
- // Use extractLocaleFromRequestAsync for custom server strategies
- continue;
- }
- const matchedLocale = toLocale(locale);
- if (matchedLocale) {
- return matchedLocale;
- }
+ const effectiveRequestUrl = resolveEffectiveRequestUrl(request, url)
+ /** @type {string|undefined} */
+ let locale
+ for (const strat of strategies) {
+ if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === 'cookie') {
+ locale = request.headers
+ .get('cookie')
+ ?.split('; ')
+ .find((c) => c.startsWith(cookieName + '='))
+ ?.split('=')[1]
+ } else if (TREE_SHAKE_URL_STRATEGY_USED && strat === 'url') {
+ locale = extractLocaleFromUrl(effectiveRequestUrl)
+ } else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === 'preferredLanguage') {
+ locale = extractLocaleFromHeader(request)
+ } else if (strat === 'globalVariable') {
+ locale = _locale
+ } else if (strat === 'baseLocale') {
+ return baseLocale
+ } else if (strat === 'localStorage') {
+ continue
+ } else if (isCustomStrategy(strat)) {
+ // Custom strategies are not supported in sync version
+ // Use extractLocaleFromRequestAsync for custom server strategies
+ continue
}
- throw new Error("No locale found. There is an error in your strategy. Try adding 'baseLocale' as the very last strategy. Read more here https://paraglidejs.com/errors#no-locale-found");
-};
+ const matchedLocale = toLocale(locale)
+ if (matchedLocale) {
+ return matchedLocale
+ }
+ }
+ throw new Error(
+ "No locale found. There is an error in your strategy. Try adding 'baseLocale' as the very last strategy. Read more here https://paraglidejs.com/errors#no-locale-found",
+ )
+}
/**
* @param {Request} request
* @param {string | URL | undefined} effectiveRequestUrl
* @returns {URL}
*/
function resolveEffectiveRequestUrl(request, effectiveRequestUrl = request.url) {
- if (effectiveRequestUrl instanceof URL) {
- return new URL(effectiveRequestUrl.href);
- }
- return new URL(effectiveRequestUrl, request.url);
+ if (effectiveRequestUrl instanceof URL) {
+ return new URL(effectiveRequestUrl.href)
+ }
+ return new URL(effectiveRequestUrl, request.url)
}
/**
@@ -726,38 +686,41 @@ function resolveEffectiveRequestUrl(request, effectiveRequestUrl = request.url)
* @returns {Promise} The extracted locale.
*/
export const extractLocaleFromRequestAsync = async (request, options = {}) => {
- /** @type {string|undefined} */
- let locale;
- const effectiveRequestUrl = resolveEffectiveRequestUrlFromRequestAsync(request, options.effectiveRequestUrl);
- const strategy = getStrategyForUrl(effectiveRequestUrl);
- // Process custom strategies first, in order
- for (const strat of strategy) {
- if (isCustomStrategy(strat) && customServerStrategies.has(strat)) {
- const handler = customServerStrategies.get(strat);
- if (handler) {
- /** @type {string|undefined} */
- locale = await handler.getLocale(request);
- }
- // If we got a valid locale from this custom strategy, use it
- const matchedLocale = toLocale(locale);
- if (matchedLocale) {
- return matchedLocale;
- }
- }
+ /** @type {string|undefined} */
+ let locale
+ const effectiveRequestUrl = resolveEffectiveRequestUrlFromRequestAsync(
+ request,
+ options.effectiveRequestUrl,
+ )
+ const strategy = getStrategyForUrl(effectiveRequestUrl)
+ // Process custom strategies first, in order
+ for (const strat of strategy) {
+ if (isCustomStrategy(strat) && customServerStrategies.has(strat)) {
+ const handler = customServerStrategies.get(strat)
+ if (handler) {
+ /** @type {string|undefined} */
+ locale = await handler.getLocale(request)
+ }
+ // If we got a valid locale from this custom strategy, use it
+ const matchedLocale = toLocale(locale)
+ if (matchedLocale) {
+ return matchedLocale
+ }
}
- // If no custom strategy provided a valid locale, fall back to sync version
- return extractLocaleFromRequestWithStrategies(request, strategy, effectiveRequestUrl);
-};
+ }
+ // If no custom strategy provided a valid locale, fall back to sync version
+ return extractLocaleFromRequestWithStrategies(request, strategy, effectiveRequestUrl)
+}
/**
* @param {Request} request
* @param {string | URL | undefined} effectiveRequestUrl
* @returns {URL}
*/
function resolveEffectiveRequestUrlFromRequestAsync(request, effectiveRequestUrl = request.url) {
- if (effectiveRequestUrl instanceof URL) {
- return new URL(effectiveRequestUrl.href);
- }
- return new URL(effectiveRequestUrl, request.url);
+ if (effectiveRequestUrl instanceof URL) {
+ return new URL(effectiveRequestUrl.href)
+ }
+ return new URL(effectiveRequestUrl, request.url)
}
/**
@@ -769,12 +732,12 @@ function resolveEffectiveRequestUrlFromRequestAsync(request, effectiveRequestUrl
* @returns {Locale | undefined}
*/
export function extractLocaleFromCookie() {
- if (typeof document === "undefined" || !document.cookie) {
- return;
- }
- const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
- const locale = match?.[2];
- return toLocale(locale);
+ if (typeof document === 'undefined' || !document.cookie) {
+ return
+ }
+ const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`))
+ const locale = match?.[2]
+ return toLocale(locale)
}
/**
@@ -790,35 +753,35 @@ export function extractLocaleFromCookie() {
* @returns {Locale | undefined} The negotiated preferred language.
*/
export function extractLocaleFromHeader(request) {
- const acceptLanguageHeader = request.headers.get("accept-language");
- if (acceptLanguageHeader) {
- // Parse language preferences with their q-values and base language codes
- const languages = acceptLanguageHeader
- .split(",")
- .map((lang) => {
- const [tag, q = "1"] = lang.trim().split(";q=");
- // Get both the full tag and base language code
- const baseTag = tag?.split("-")[0];
- return {
- fullTag: tag,
- baseTag,
- q: Number(q),
- };
- })
- .sort((a, b) => b.q - a.q);
- for (const lang of languages) {
- const fullLocale = toLocale(lang.fullTag);
- if (fullLocale) {
- return fullLocale;
- }
- const baseLocale = toLocale(lang.baseTag);
- if (baseLocale) {
- return baseLocale;
- }
+ const acceptLanguageHeader = request.headers.get('accept-language')
+ if (acceptLanguageHeader) {
+ // Parse language preferences with their q-values and base language codes
+ const languages = acceptLanguageHeader
+ .split(',')
+ .map((lang) => {
+ const [tag, q = '1'] = lang.trim().split(';q=')
+ // Get both the full tag and base language code
+ const baseTag = tag?.split('-')[0]
+ return {
+ fullTag: tag,
+ baseTag,
+ q: Number(q),
}
- return undefined;
+ })
+ .sort((a, b) => b.q - a.q)
+ for (const lang of languages) {
+ const fullLocale = toLocale(lang.fullTag)
+ if (fullLocale) {
+ return fullLocale
+ }
+ const baseLocale = toLocale(lang.baseTag)
+ if (baseLocale) {
+ return baseLocale
+ }
}
- return undefined;
+ return undefined
+ }
+ return undefined
}
/**
@@ -833,24 +796,24 @@ export function extractLocaleFromHeader(request) {
* @returns {Locale | undefined}
*/
export function extractLocaleFromNavigator() {
- if (!navigator?.languages?.length) {
- return undefined;
+ if (!navigator?.languages?.length) {
+ return undefined
+ }
+ const languages = navigator.languages.map((lang) => ({
+ fullTag: lang,
+ baseTag: lang.split('-')[0],
+ }))
+ for (const lang of languages) {
+ const fullLocale = toLocale(lang.fullTag)
+ if (fullLocale) {
+ return fullLocale
}
- const languages = navigator.languages.map((lang) => ({
- fullTag: lang,
- baseTag: lang.split("-")[0],
- }));
- for (const lang of languages) {
- const fullLocale = toLocale(lang.fullTag);
- if (fullLocale) {
- return fullLocale;
- }
- const baseLocale = toLocale(lang.baseTag);
- if (baseLocale) {
- return baseLocale;
- }
+ const baseLocale = toLocale(lang.baseTag)
+ if (baseLocale) {
+ return baseLocale
}
- return undefined;
+ }
+ return undefined
}
/**
@@ -860,9 +823,9 @@ export function extractLocaleFromNavigator() {
* https://github.com/opral/monorepo/pull/3575#discussion_r2066731243
*/
/** @type {string|undefined} */
-let cachedUrl;
+let cachedUrl
/** @type {Locale|undefined} */
-let cachedLocale;
+let cachedLocale
/**
* Extracts the locale from a given URL using native URLPattern.
*
@@ -874,33 +837,31 @@ let cachedLocale;
* @returns {Locale|undefined} The extracted locale, or undefined if no locale is found.
*/
export function extractLocaleFromUrl(url) {
- const urlString = typeof url === "string" ? url : url.href;
- if (cachedUrl === urlString) {
- return cachedLocale;
- }
- /** @type {Locale | undefined} */
- let result;
- if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
- result = defaultUrlPatternExtractLocale(url);
- }
- else {
- const urlObj = typeof url === "string" ? new URL(url) : url;
- // Iterate over URL patterns
- for (const element of urlPatterns) {
- for (const [locale, localizedPattern] of element.localized) {
- const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
- if (match) {
- result = locale;
- break;
- }
- }
- if (result)
- break;
+ const urlString = typeof url === 'string' ? url : url.href
+ if (cachedUrl === urlString) {
+ return cachedLocale
+ }
+ /** @type {Locale | undefined} */
+ let result
+ if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
+ result = defaultUrlPatternExtractLocale(url)
+ } else {
+ const urlObj = typeof url === 'string' ? new URL(url) : url
+ // Iterate over URL patterns
+ for (const element of urlPatterns) {
+ for (const [locale, localizedPattern] of element.localized) {
+ const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href)
+ if (match) {
+ result = locale
+ break
}
+ }
+ if (result) break
}
- cachedUrl = urlString;
- cachedLocale = result;
- return result;
+ }
+ cachedUrl = urlString
+ cachedLocale = result
+ return result
}
/**
* https://github.com/opral/inlang-paraglide-js/issues/381
@@ -909,9 +870,9 @@ export function extractLocaleFromUrl(url) {
* @returns {Locale | undefined} The extracted locale, or undefined if no locale is found.
*/
function defaultUrlPatternExtractLocale(url) {
- const urlObj = new URL(url, "http://dummy.com");
- const pathSegments = urlObj.pathname.split("/").filter(Boolean);
- return toLocale(pathSegments[0]) || baseLocale;
+ const urlObj = new URL(url, 'http://dummy.com')
+ const pathSegments = urlObj.pathname.split('/').filter(Boolean)
+ return toLocale(pathSegments[0]) || baseLocale
}
/**
@@ -959,39 +920,41 @@ function defaultUrlPatternExtractLocale(url) {
* @returns {URL} The localized URL, always absolute
*/
export function localizeUrl(url, options) {
- const targetLocale = options?.locale
- ? assertIsLocale(options?.locale)
- : getLocale();
- if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
- return localizeUrlDefaultPattern(url, targetLocale);
+ const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale()
+ if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
+ return localizeUrlDefaultPattern(url, targetLocale)
+ }
+ const urlObj = typeof url === 'string' ? new URL(url) : url
+ // Iterate over URL patterns
+ for (const element of urlPatterns) {
+ // match localized patterns
+ for (const [, localizedPattern] of element.localized) {
+ const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href)
+ if (!match) {
+ continue
+ }
+ const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1]
+ if (!targetPattern) {
+ continue
+ }
+ const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin)
+ return fillMissingUrlParts(localizedUrl, match)
}
- const urlObj = typeof url === "string" ? new URL(url) : url;
- // Iterate over URL patterns
- for (const element of urlPatterns) {
- // match localized patterns
- for (const [, localizedPattern] of element.localized) {
- const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
- if (!match) {
- continue;
- }
- const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
- if (!targetPattern) {
- continue;
- }
- const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
- return fillMissingUrlParts(localizedUrl, match);
- }
- const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
- if (unlocalizedMatch) {
- const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
- if (targetPattern) {
- const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
- return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
- }
- }
+ const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href)
+ if (unlocalizedMatch) {
+ const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1]
+ if (targetPattern) {
+ const localizedUrl = fillPattern(
+ targetPattern,
+ aggregateGroups(unlocalizedMatch),
+ urlObj.origin,
+ )
+ return fillMissingUrlParts(localizedUrl, unlocalizedMatch)
+ }
}
- // If no match found, return the original URL
- return urlObj;
+ }
+ // If no match found, return the original URL
+ return urlObj
}
/**
* https://github.com/opral/inlang-paraglide-js/issues/381
@@ -1001,26 +964,25 @@ export function localizeUrl(url, options) {
* @returns {URL}
*/
function localizeUrlDefaultPattern(url, locale) {
- const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
- const currentLocale = extractLocaleFromUrl(urlObj);
- // If current locale matches target locale, no change needed
- if (currentLocale === locale) {
- return urlObj;
- }
- const pathSegments = urlObj.pathname.split("/").filter(Boolean);
- // If current path starts with a locale, remove it
- if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
- pathSegments.shift();
- }
- // For base locale, don't add prefix
- if (locale === baseLocale) {
- urlObj.pathname = "/" + pathSegments.join("/");
- }
- else {
- // For other locales, add prefix
- urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
- }
- return urlObj;
+ const urlObj = typeof url === 'string' ? new URL(url, getUrlOrigin()) : new URL(url)
+ const currentLocale = extractLocaleFromUrl(urlObj)
+ // If current locale matches target locale, no change needed
+ if (currentLocale === locale) {
+ return urlObj
+ }
+ const pathSegments = urlObj.pathname.split('/').filter(Boolean)
+ // If current path starts with a locale, remove it
+ if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
+ pathSegments.shift()
+ }
+ // For base locale, don't add prefix
+ if (locale === baseLocale) {
+ urlObj.pathname = '/' + pathSegments.join('/')
+ } else {
+ // For other locales, add prefix
+ urlObj.pathname = '/' + locale + '/' + pathSegments.join('/')
+ }
+ return urlObj
}
/**
* Low-level URL de-localization function, primarily used in server contexts.
@@ -1062,31 +1024,31 @@ function localizeUrlDefaultPattern(url, locale) {
* @returns {URL} The de-localized URL, always absolute
*/
export function deLocalizeUrl(url) {
- if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
- return deLocalizeUrlDefaultPattern(url);
+ if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
+ return deLocalizeUrlDefaultPattern(url)
+ }
+ const urlObj = typeof url === 'string' ? new URL(url) : url
+ // Iterate over URL patterns
+ for (const element of urlPatterns) {
+ // Iterate over localized versions
+ for (const [, localizedPattern] of element.localized) {
+ const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href)
+ if (match) {
+ // Convert localized URL back to the base pattern
+ const groups = aggregateGroups(match)
+ const baseUrl = fillPattern(element.pattern, groups, urlObj.origin)
+ return fillMissingUrlParts(baseUrl, match)
+ }
}
- const urlObj = typeof url === "string" ? new URL(url) : url;
- // Iterate over URL patterns
- for (const element of urlPatterns) {
- // Iterate over localized versions
- for (const [, localizedPattern] of element.localized) {
- const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
- if (match) {
- // Convert localized URL back to the base pattern
- const groups = aggregateGroups(match);
- const baseUrl = fillPattern(element.pattern, groups, urlObj.origin);
- return fillMissingUrlParts(baseUrl, match);
- }
- }
- // match unlocalized pattern
- const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
- if (unlocalizedMatch) {
- const baseUrl = fillPattern(element.pattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
- return fillMissingUrlParts(baseUrl, unlocalizedMatch);
- }
+ // match unlocalized pattern
+ const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href)
+ if (unlocalizedMatch) {
+ const baseUrl = fillPattern(element.pattern, aggregateGroups(unlocalizedMatch), urlObj.origin)
+ return fillMissingUrlParts(baseUrl, unlocalizedMatch)
}
- // no match found return the original url
- return urlObj;
+ }
+ // no match found return the original url
+ return urlObj
}
/**
* De-localizes a URL using the default pattern (/:locale/*)
@@ -1094,13 +1056,13 @@ export function deLocalizeUrl(url) {
* @returns {URL}
*/
function deLocalizeUrlDefaultPattern(url) {
- const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
- const pathSegments = urlObj.pathname.split("/").filter(Boolean);
- // If first segment is a locale, remove it
- if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
- urlObj.pathname = "/" + pathSegments.slice(1).join("/");
- }
- return urlObj;
+ const urlObj = typeof url === 'string' ? new URL(url, getUrlOrigin()) : new URL(url)
+ const pathSegments = urlObj.pathname.split('/').filter(Boolean)
+ // If first segment is a locale, remove it
+ if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
+ urlObj.pathname = '/' + pathSegments.slice(1).join('/')
+ }
+ return urlObj
}
/**
* Takes matches of implicit wildcards in the UrlPattern (when a part is missing
@@ -1113,31 +1075,31 @@ function deLocalizeUrlDefaultPattern(url) {
* @returns {URL}
*/
function fillMissingUrlParts(url, match) {
- if (match.protocol.groups["0"]) {
- url.protocol = match.protocol.groups["0"] ?? "";
- }
- if (match.hostname.groups["0"]) {
- url.hostname = match.hostname.groups["0"] ?? "";
- }
- if (match.username.groups["0"]) {
- url.username = match.username.groups["0"] ?? "";
- }
- if (match.password.groups["0"]) {
- url.password = match.password.groups["0"] ?? "";
- }
- if (match.port.groups["0"]) {
- url.port = match.port.groups["0"] ?? "";
- }
- if (match.pathname.groups["0"]) {
- url.pathname = match.pathname.groups["0"] ?? "";
- }
- if (match.search.groups["0"]) {
- url.search = match.search.groups["0"] ?? "";
- }
- if (match.hash.groups["0"]) {
- url.hash = match.hash.groups["0"] ?? "";
- }
- return url;
+ if (match.protocol.groups['0']) {
+ url.protocol = match.protocol.groups['0'] ?? ''
+ }
+ if (match.hostname.groups['0']) {
+ url.hostname = match.hostname.groups['0'] ?? ''
+ }
+ if (match.username.groups['0']) {
+ url.username = match.username.groups['0'] ?? ''
+ }
+ if (match.password.groups['0']) {
+ url.password = match.password.groups['0'] ?? ''
+ }
+ if (match.port.groups['0']) {
+ url.port = match.port.groups['0'] ?? ''
+ }
+ if (match.pathname.groups['0']) {
+ url.pathname = match.pathname.groups['0'] ?? ''
+ }
+ if (match.search.groups['0']) {
+ url.search = match.search.groups['0'] ?? ''
+ }
+ if (match.hash.groups['0']) {
+ url.hash = match.hash.groups['0'] ?? ''
+ }
+ return url
}
/**
* Fills a URL pattern with values for named groups, supporting all URLPattern-style modifiers.
@@ -1161,50 +1123,59 @@ function fillMissingUrlParts(url, match) {
* @returns {URL} - The constructed URL with named groups filled.
*/
function fillPattern(pattern, values, origin) {
- // Pre-process the pattern to handle explicit port numbers
- // This detects patterns like "http://localhost:5173" and protects the port number
- // from being interpreted as a parameter
- let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
- // Replace ":5173" with "#PORT-5173#" to protect it from parameter replacement
- return `${protocol}#PORT-${port}#${slash}`;
- });
- // First, handle group delimiters with curly braces
- let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
- // For optional group delimiters
- if (modifier === "?") {
- // For optional groups, we'll include the content
- return content;
+ // Pre-process the pattern to handle explicit port numbers
+ // This detects patterns like "http://localhost:5173" and protects the port number
+ // from being interpreted as a parameter
+ let processedPattern = pattern.replace(
+ /(https?:\/\/[^:/]+):(\d+)(\/|$)/g,
+ (_, protocol, port, slash) => {
+ // Replace ":5173" with "#PORT-5173#" to protect it from parameter replacement
+ return `${protocol}#PORT-${port}#${slash}`
+ },
+ )
+ // First, handle group delimiters with curly braces
+ let processedGroupDelimiters = processedPattern.replace(
+ /\{([^{}]*)\}([?+*]?)/g,
+ (_, content, modifier) => {
+ // For optional group delimiters
+ if (modifier === '?') {
+ // For optional groups, we'll include the content
+ return content
+ }
+ // For non-optional group delimiters, always include the content
+ return content
+ },
+ )
+ // Then handle named groups
+ let filled = processedGroupDelimiters.replace(
+ /(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g,
+ (_, slash, name, __, modifier) => {
+ const value = values[name]
+ if (value === null) {
+ // If value is null, remove the entire segment including the preceding slash
+ return ''
+ }
+ if (modifier === '?') {
+ // Optional segment
+ return value !== undefined ? `${slash}${value}` : ''
+ }
+ if (modifier === '+' || modifier === '*') {
+ // Repeatable segments
+ if (value === undefined && modifier === '+') {
+ throw new Error(`Missing value for "${name}" (one or more required)`)
}
- // For non-optional group delimiters, always include the content
- return content;
- });
- // Then handle named groups
- let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
- const value = values[name];
- if (value === null) {
- // If value is null, remove the entire segment including the preceding slash
- return "";
- }
- if (modifier === "?") {
- // Optional segment
- return value !== undefined ? `${slash}${value}` : "";
- }
- if (modifier === "+" || modifier === "*") {
- // Repeatable segments
- if (value === undefined && modifier === "+") {
- throw new Error(`Missing value for "${name}" (one or more required)`);
- }
- return value ? `${slash}${value}` : "";
- }
- // Simple named group (no modifier)
- if (value === undefined) {
- throw new Error(`Missing value for "${name}"`);
- }
- return `${slash}${value}`;
- });
- // Restore port numbers
- filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
- return new URL(filled, origin);
+ return value ? `${slash}${value}` : ''
+ }
+ // Simple named group (no modifier)
+ if (value === undefined) {
+ throw new Error(`Missing value for "${name}"`)
+ }
+ return `${slash}${value}`
+ },
+ )
+ // Restore port numbers
+ filled = filled.replace(/#PORT-(\d+)#/g, ':$1')
+ return new URL(filled, origin)
}
/**
* Aggregates named groups from various parts of the URLPattern match result.
@@ -1214,16 +1185,16 @@ function fillPattern(pattern, values, origin) {
* @returns {Record} An object containing all named groups from the match.
*/
export function aggregateGroups(match) {
- return {
- ...match.hash.groups,
- ...match.hostname.groups,
- ...match.password.groups,
- ...match.pathname.groups,
- ...match.port.groups,
- ...match.protocol.groups,
- ...match.search.groups,
- ...match.username.groups,
- };
+ return {
+ ...match.hash.groups,
+ ...match.hostname.groups,
+ ...match.password.groups,
+ ...match.pathname.groups,
+ ...match.port.groups,
+ ...match.protocol.groups,
+ ...match.search.groups,
+ ...match.username.groups,
+ }
}
/**
@@ -1298,19 +1269,20 @@ export function aggregateGroups(match) {
* @returns {Promise}
*/
export async function shouldRedirect(input = {}) {
- const currentUrl = resolveUrl(input);
- const locale = await resolveLocale(input, currentUrl);
- const strategy = getStrategyForUrl(currentUrl.href);
- if (isExcludedByRouteStrategy(currentUrl.href) || !strategy.includes("url")) {
- return { shouldRedirect: false, locale, redirectUrl: undefined };
- }
- const localizedUrl = localizeUrl(currentUrl.href, { locale });
- const shouldRedirectToLocalizedUrl = normalizeUrl(localizedUrl.href) !== normalizeUrl(currentUrl.href);
- return {
- shouldRedirect: shouldRedirectToLocalizedUrl,
- locale,
- redirectUrl: shouldRedirectToLocalizedUrl ? localizedUrl : undefined,
- };
+ const currentUrl = resolveUrl(input)
+ const locale = await resolveLocale(input, currentUrl)
+ const strategy = getStrategyForUrl(currentUrl.href)
+ if (isExcludedByRouteStrategy(currentUrl.href) || !strategy.includes('url')) {
+ return { shouldRedirect: false, locale, redirectUrl: undefined }
+ }
+ const localizedUrl = localizeUrl(currentUrl.href, { locale })
+ const shouldRedirectToLocalizedUrl =
+ normalizeUrl(localizedUrl.href) !== normalizeUrl(currentUrl.href)
+ return {
+ shouldRedirect: shouldRedirectToLocalizedUrl,
+ locale,
+ redirectUrl: shouldRedirectToLocalizedUrl ? localizedUrl : undefined,
+ }
}
/**
* Resolves the locale either from the provided input or by using the configured strategies.
@@ -1320,19 +1292,19 @@ export async function shouldRedirect(input = {}) {
* @returns {Promise}
*/
async function resolveLocale(input, currentUrl) {
- const locale = toLocale(input.locale);
- if (locale) {
- return locale;
- }
- if (input.request) {
- return extractLocaleFromRequestAsync(input.request, {
- effectiveRequestUrl: currentUrl,
- });
- }
- if ("url" in input && typeof input.url !== "undefined") {
- return getLocaleForUrl(currentUrl.href);
- }
- return getLocale();
+ const locale = toLocale(input.locale)
+ if (locale) {
+ return locale
+ }
+ if (input.request) {
+ return extractLocaleFromRequestAsync(input.request, {
+ effectiveRequestUrl: currentUrl,
+ })
+ }
+ if ('url' in input && typeof input.url !== 'undefined') {
+ return getLocaleForUrl(currentUrl.href)
+ }
+ return getLocale()
}
/**
* Resolves the current URL from the provided input or runtime context.
@@ -1341,25 +1313,27 @@ async function resolveLocale(input, currentUrl) {
* @returns {URL}
*/
function resolveUrl(input) {
- if ("effectiveRequestUrl" in input && input.effectiveRequestUrl instanceof URL) {
- return new URL(input.effectiveRequestUrl.href);
- }
- if ("effectiveRequestUrl" in input && typeof input.effectiveRequestUrl === "string") {
- return new URL(input.effectiveRequestUrl, input.request ? input.request.url : getUrlOrigin());
- }
- if (input.request) {
- return new URL(input.request.url);
- }
- if ("url" in input && input.url instanceof URL) {
- return new URL(input.url.href);
- }
- if ("url" in input && typeof input.url === "string") {
- return new URL(input.url, getUrlOrigin());
- }
- if (typeof window !== "undefined" && window?.location?.href) {
- return new URL(window.location.href);
- }
- throw new Error("shouldRedirect() requires either a request, an absolute URL, or must run in a browser environment.");
+ if ('effectiveRequestUrl' in input && input.effectiveRequestUrl instanceof URL) {
+ return new URL(input.effectiveRequestUrl.href)
+ }
+ if ('effectiveRequestUrl' in input && typeof input.effectiveRequestUrl === 'string') {
+ return new URL(input.effectiveRequestUrl, input.request ? input.request.url : getUrlOrigin())
+ }
+ if (input.request) {
+ return new URL(input.request.url)
+ }
+ if ('url' in input && input.url instanceof URL) {
+ return new URL(input.url.href)
+ }
+ if ('url' in input && typeof input.url === 'string') {
+ return new URL(input.url, getUrlOrigin())
+ }
+ if (typeof window !== 'undefined' && window?.location?.href) {
+ return new URL(window.location.href)
+ }
+ throw new Error(
+ 'shouldRedirect() requires either a request, an absolute URL, or must run in a browser environment.',
+ )
}
/**
* Normalize url for comparison by stripping the trailing slash.
@@ -1368,9 +1342,9 @@ function resolveUrl(input) {
* @returns {string}
*/
function normalizeUrl(url) {
- const urlObj = new URL(url);
- urlObj.pathname = urlObj.pathname.replace(/\/$/, "");
- return urlObj.href;
+ const urlObj = new URL(url)
+ urlObj.pathname = urlObj.pathname.replace(/\/$/, '')
+ return urlObj.href
}
/**
@@ -1414,25 +1388,25 @@ function normalizeUrl(url) {
* @returns {string} The localized href, relative if input was relative
*/
export function localizeHref(href, options) {
- const currentLocale = getLocale();
- const locale = options?.locale ?? currentLocale;
- const url = new URL(href, getUrlOrigin());
- const localized = localizeUrl(url, { locale });
- // if the origin is identical and the href is relative,
- // return the relative path
- if (href.startsWith("/") && url.origin === localized.origin) {
- // check for cross origin localization in which case an absolute URL must be returned.
- if (locale !== currentLocale) {
- const localizedCurrentLocale = localizeUrl(url, {
- locale: currentLocale,
- });
- if (localizedCurrentLocale.origin !== localized.origin) {
- return localized.href;
- }
- }
- return localized.pathname + localized.search + localized.hash;
+ const currentLocale = getLocale()
+ const locale = options?.locale ?? currentLocale
+ const url = new URL(href, getUrlOrigin())
+ const localized = localizeUrl(url, { locale })
+ // if the origin is identical and the href is relative,
+ // return the relative path
+ if (href.startsWith('/') && url.origin === localized.origin) {
+ // check for cross origin localization in which case an absolute URL must be returned.
+ if (locale !== currentLocale) {
+ const localizedCurrentLocale = localizeUrl(url, {
+ locale: currentLocale,
+ })
+ if (localizedCurrentLocale.origin !== localized.origin) {
+ return localized.href
+ }
}
- return localized.href;
+ return localized.pathname + localized.search + localized.hash
+ }
+ return localized.href
}
/**
* High-level URL de-localization function optimized for client-side UI usage.
@@ -1475,14 +1449,14 @@ export function localizeHref(href, options) {
* @returns {string} The de-localized href, relative if input was relative
*/
export function deLocalizeHref(href) {
- const url = new URL(href, getUrlOrigin());
- const deLocalized = deLocalizeUrl(url);
- // If the origin is identical and the href is relative,
- // return the relative path instead of the full URL.
- if (href.startsWith("/") && url.origin === deLocalized.origin) {
- return deLocalized.pathname + deLocalized.search + deLocalized.hash;
- }
- return deLocalized.href;
+ const url = new URL(href, getUrlOrigin())
+ const deLocalized = deLocalizeUrl(url)
+ // If the origin is identical and the href is relative,
+ // return the relative path instead of the full URL.
+ if (href.startsWith('/') && url.origin === deLocalized.origin) {
+ return deLocalized.pathname + deLocalized.search + deLocalized.hash
+ }
+ return deLocalized.href
}
/**
@@ -1490,12 +1464,11 @@ export function deLocalizeHref(href) {
* @param {Locale} locale
*/
export function trackMessageCall(safeModuleId, locale) {
- if (isServer === false)
- return;
- const store = serverAsyncLocalStorage?.getStore();
- if (store) {
- store.messageCalls?.add(`${safeModuleId}:${locale}`);
- }
+ if (isServer === false) return
+ const store = serverAsyncLocalStorage?.getStore()
+ if (store) {
+ store.messageCalls?.add(`${safeModuleId}:${locale}`)
+ }
}
/**
@@ -1542,72 +1515,65 @@ export function trackMessageCall(safeModuleId, locale) {
* The order follows each input URL with all its locale variants before moving to the next URL.
*/
export function generateStaticLocalizedUrls(urls) {
- /** @type {Set} */
- const localizedUrls = new Set();
- // For default URL pattern, we can optimize the generation
- if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
- for (const urlInput of urls) {
- const url = urlInput instanceof URL
- ? urlInput
- : new URL(urlInput, "http://localhost");
- // Base locale doesn't get a prefix
- localizedUrls.add(url);
- // Other locales get their code as prefix
- for (const locale of locales) {
- if (locale !== baseLocale) {
- const localizedPath = `/${locale}${url.pathname}${url.search}${url.hash}`;
- const localizedUrl = new URL(localizedPath, url.origin);
- localizedUrls.add(localizedUrl);
- }
- }
- }
- return Array.from(localizedUrls);
- }
- // For custom URL patterns, we need to use localizeUrl for each URL and locale
+ /** @type {Set} */
+ const localizedUrls = new Set()
+ // For default URL pattern, we can optimize the generation
+ if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
for (const urlInput of urls) {
- const url = urlInput instanceof URL
- ? urlInput
- : new URL(urlInput, "http://localhost");
- // Try each URL pattern to find one that matches
- let patternFound = false;
- for (const pattern of urlPatterns) {
- try {
- // Try to match the unlocalized pattern
- const unlocalizedMatch = new URLPattern(pattern.pattern, url.href).exec(url.href);
- if (!unlocalizedMatch)
- continue;
- patternFound = true;
- // Track unique localized URLs to avoid duplicates when patterns are the same
- const seenUrls = new Set();
- // Generate localized URL for each locale
- for (const [locale] of pattern.localized) {
- try {
- const localizedUrl = localizeUrl(url, { locale });
- const urlString = localizedUrl.href;
- // Only add if we haven't seen this exact URL before
- if (!seenUrls.has(urlString)) {
- seenUrls.add(urlString);
- localizedUrls.add(localizedUrl);
- }
- }
- catch {
- // Skip if localization fails for this locale
- continue;
- }
- }
- break;
- }
- catch {
- // Skip if pattern matching fails
- continue;
- }
- }
- // If no pattern matched, use the URL as is
- if (!patternFound) {
- localizedUrls.add(url);
+ const url = urlInput instanceof URL ? urlInput : new URL(urlInput, 'http://localhost')
+ // Base locale doesn't get a prefix
+ localizedUrls.add(url)
+ // Other locales get their code as prefix
+ for (const locale of locales) {
+ if (locale !== baseLocale) {
+ const localizedPath = `/${locale}${url.pathname}${url.search}${url.hash}`
+ const localizedUrl = new URL(localizedPath, url.origin)
+ localizedUrls.add(localizedUrl)
}
+ }
}
- return Array.from(localizedUrls);
+ return Array.from(localizedUrls)
+ }
+ // For custom URL patterns, we need to use localizeUrl for each URL and locale
+ for (const urlInput of urls) {
+ const url = urlInput instanceof URL ? urlInput : new URL(urlInput, 'http://localhost')
+ // Try each URL pattern to find one that matches
+ let patternFound = false
+ for (const pattern of urlPatterns) {
+ try {
+ // Try to match the unlocalized pattern
+ const unlocalizedMatch = new URLPattern(pattern.pattern, url.href).exec(url.href)
+ if (!unlocalizedMatch) continue
+ patternFound = true
+ // Track unique localized URLs to avoid duplicates when patterns are the same
+ const seenUrls = new Set()
+ // Generate localized URL for each locale
+ for (const [locale] of pattern.localized) {
+ try {
+ const localizedUrl = localizeUrl(url, { locale })
+ const urlString = localizedUrl.href
+ // Only add if we haven't seen this exact URL before
+ if (!seenUrls.has(urlString)) {
+ seenUrls.add(urlString)
+ localizedUrls.add(localizedUrl)
+ }
+ } catch {
+ // Skip if localization fails for this locale
+ continue
+ }
+ }
+ break
+ } catch {
+ // Skip if pattern matching fails
+ continue
+ }
+ }
+ // If no pattern matched, use the URL as is
+ if (!patternFound) {
+ localizedUrls.add(url)
+ }
+ }
+ return Array.from(localizedUrls)
}
/**
@@ -1629,9 +1595,9 @@ export function generateStaticLocalizedUrls(urls) {
* @typedef {{ getLocale: () => Promise | (string | undefined), setLocale: (locale: string) => Promise | void }} CustomClientStrategyHandler
*/
/** @type {Map} */
-export const customServerStrategies = new Map();
+export const customServerStrategies = new Map()
/** @type {Map} */
-export const customClientStrategies = new Map();
+export const customClientStrategies = new Map()
/**
* Checks if the given strategy is a custom strategy.
*
@@ -1640,7 +1606,7 @@ export const customClientStrategies = new Map();
* @returns {boolean} Returns true if it is a custom strategy, false otherwise.
*/
export function isCustomStrategy(strategy) {
- return (typeof strategy === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy));
+ return typeof strategy === 'string' && /^custom-[A-Za-z0-9_-]+$/.test(strategy)
}
/**
* Defines a custom strategy that is executed on the server.
@@ -1653,10 +1619,12 @@ export function isCustomStrategy(strategy) {
* @returns {void}
*/
export function defineCustomServerStrategy(strategy, handler) {
- if (!isCustomStrategy(strategy)) {
- throw new Error(`Invalid custom strategy: "${strategy}". Must be a custom strategy following the pattern custom-name.`);
- }
- customServerStrategies.set(strategy, handler);
+ if (!isCustomStrategy(strategy)) {
+ throw new Error(
+ `Invalid custom strategy: "${strategy}". Must be a custom strategy following the pattern custom-name.`,
+ )
+ }
+ customServerStrategies.set(strategy, handler)
}
/**
* Defines a custom strategy that is executed on the client.
@@ -1669,14 +1637,16 @@ export function defineCustomServerStrategy(strategy, handler) {
* @returns {void}
*/
export function defineCustomClientStrategy(strategy, handler) {
- if (!isCustomStrategy(strategy)) {
- throw new Error(`Invalid custom strategy: "${strategy}". Must be a custom strategy following the pattern custom-name.`);
- }
- customClientStrategies.set(strategy, handler);
+ if (!isCustomStrategy(strategy)) {
+ throw new Error(
+ `Invalid custom strategy: "${strategy}". Must be a custom strategy following the pattern custom-name.`,
+ )
+ }
+ customClientStrategies.set(strategy, handler)
}
// ------ TYPES ------
-export {};
+export {}
/**
* A locale that is available in the project.
*
diff --git a/packages/webui/src/paraglide/server.d.ts b/packages/webui/src/paraglide/server.d.ts
index a30dec15..9ebcc22c 100644
--- a/packages/webui/src/paraglide/server.d.ts
+++ b/packages/webui/src/paraglide/server.d.ts
@@ -87,10 +87,11 @@
* }
* ```
*/
-export function paraglideMiddleware(request: Request, resolve: (args: {
- request: Request;
- locale: import("./runtime.js").Locale;
-}) => T | Promise, options?: {
- effectiveRequestUrl?: string | URL | ((request: Request) => string | URL);
- onRedirect?: (response: Response) => void;
-}): Promise;
+export function paraglideMiddleware(
+ request: Request,
+ resolve: (args: { request: Request; locale: import('./runtime.js').Locale }) => T | Promise,
+ options?: {
+ effectiveRequestUrl?: string | URL | ((request: Request) => string | URL)
+ onRedirect?: (response: Response) => void
+ },
+): Promise
diff --git a/packages/webui/src/paraglide/server.js b/packages/webui/src/paraglide/server.js
index b068b6cd..beffe981 100644
--- a/packages/webui/src/paraglide/server.js
+++ b/packages/webui/src/paraglide/server.js
@@ -1,6 +1,6 @@
/* eslint-disable */
-import * as runtime from "./runtime.js";
+import * as runtime from './runtime.js'
/**
* Server middleware that handles locale-based routing and request processing.
@@ -92,97 +92,104 @@ import * as runtime from "./runtime.js";
* ```
*/
export async function paraglideMiddleware(request, resolve, options) {
- if (!runtime.disableAsyncLocalStorage && !runtime.serverAsyncLocalStorage) {
- const { AsyncLocalStorage } = await import("async_hooks");
- runtime.overwriteServerAsyncLocalStorage(new AsyncLocalStorage());
- } else if (!runtime.serverAsyncLocalStorage) {
- runtime.overwriteServerAsyncLocalStorage(createMockAsyncLocalStorage());
- }
- const url = resolveMiddlewareUrl(request, options?.effectiveRequestUrl);
- const origin = url.origin;
- if (runtime.isExcludedByRouteStrategy(url.href)) {
- const locale = runtime.baseLocale;
- const newRequest = cloneRequestWithFallback(request, url);
- /** @type {Set} */
- const messageCalls = new Set();
- return /** @type {Response} */ (await runtime.serverAsyncLocalStorage?.run({ locale, origin, messageCalls }, () => resolve({ locale, request: newRequest })));
- }
- const strategy = runtime.getStrategyForUrl(url.href);
- const decision = await runtime.shouldRedirect({ request, effectiveRequestUrl: url });
- const locale = decision.locale;
- // if the client makes a request to a URL that doesn't match
- // the localizedUrl, redirect the client to the localized URL
- if (request.headers.get("Sec-Fetch-Dest") === "document" &&
- decision.shouldRedirect &&
- decision.redirectUrl) {
- // Create headers object with Vary header if preferredLanguage strategy is used
- /** @type {Record} */
- const headers = {};
- if (strategy.includes("preferredLanguage")) {
- headers["Vary"] = "Accept-Language";
- }
- const response = new Response(null, {
- status: 307,
- headers: {
- Location: decision.redirectUrl.href,
- ...headers,
- },
- });
- options?.onRedirect?.(response);
- return response;
- }
- // If the strategy includes "url", we need to de-localize the URL
- // before passing it to the server middleware.
- //
- // The middleware is responsible for mapping a localized URL to the
- // de-localized URL e.g. `/en/about` to `/about`. Otherwise,
- // the server can't render the correct page.
- let newRequest;
- if (strategy.includes("url")) {
- newRequest = cloneRequestWithFallback(request, runtime.deLocalizeUrl(url));
- }
- else {
- newRequest = cloneRequestWithFallback(request, url);
- }
- // the message functions that have been called in this request
+ if (!runtime.disableAsyncLocalStorage && !runtime.serverAsyncLocalStorage) {
+ const { AsyncLocalStorage } = await import('async_hooks')
+ runtime.overwriteServerAsyncLocalStorage(new AsyncLocalStorage())
+ } else if (!runtime.serverAsyncLocalStorage) {
+ runtime.overwriteServerAsyncLocalStorage(createMockAsyncLocalStorage())
+ }
+ const url = resolveMiddlewareUrl(request, options?.effectiveRequestUrl)
+ const origin = url.origin
+ if (runtime.isExcludedByRouteStrategy(url.href)) {
+ const locale = runtime.baseLocale
+ const newRequest = cloneRequestWithFallback(request, url)
/** @type {Set} */
- const messageCalls = new Set();
- const response = await runtime.serverAsyncLocalStorage?.run({ locale, origin, messageCalls }, () => resolve({ locale, request: newRequest }));
- // Only modify HTML responses
- if (runtime.experimentalMiddlewareLocaleSplitting &&
- response.headers.get("Content-Type")?.includes("html")) {
- const body = await response.text();
- const messages = [];
- // using .values() to avoid polyfilling in older projects. else the following error is thrown
- // Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
- for (const messageCall of Array.from(messageCalls)) {
- const [id, locale] =
- /** @type {[string, import("./runtime.js").Locale]} */ (messageCall.split(":"));
- messages.push(`${id}: ${compiledBundles[id]?.[locale]}`);
- }
- // Prevent translated content from terminating the inline script tag.
- const escapedMessages = messages
- .join(",")
- .replace(/<\/(script)/gi, "<\\/$1");
- // Reuse the request's CSP nonce (if any) so the injected script is allowed under a strict CSP
- const nonce = response.headers
- .get("Content-Security-Policy")
- ?.match(/'nonce-([\w+/=-]+)'/)?.[1];
- const nonceAttr = nonce ? `nonce="${nonce}"` : "";
- const script = ``;
- // Insert the script before the closing head tag
- const newBody = body.replace("", `${script}`);
- // Create a new response with the modified body
- // Clone all headers except Content-Length which will be set automatically
- const newHeaders = new Headers(response.headers);
- newHeaders.delete("Content-Length"); // Let the browser calculate the correct length
- return new Response(newBody, {
- status: response.status,
- statusText: response.statusText,
- headers: newHeaders,
- });
+ const messageCalls = new Set()
+ return /** @type {Response} */ (
+ await runtime.serverAsyncLocalStorage?.run({ locale, origin, messageCalls }, () =>
+ resolve({ locale, request: newRequest }),
+ )
+ )
+ }
+ const strategy = runtime.getStrategyForUrl(url.href)
+ const decision = await runtime.shouldRedirect({ request, effectiveRequestUrl: url })
+ const locale = decision.locale
+ // if the client makes a request to a URL that doesn't match
+ // the localizedUrl, redirect the client to the localized URL
+ if (
+ request.headers.get('Sec-Fetch-Dest') === 'document' &&
+ decision.shouldRedirect &&
+ decision.redirectUrl
+ ) {
+ // Create headers object with Vary header if preferredLanguage strategy is used
+ /** @type {Record} */
+ const headers = {}
+ if (strategy.includes('preferredLanguage')) {
+ headers['Vary'] = 'Accept-Language'
}
- return response;
+ const response = new Response(null, {
+ status: 307,
+ headers: {
+ Location: decision.redirectUrl.href,
+ ...headers,
+ },
+ })
+ options?.onRedirect?.(response)
+ return response
+ }
+ // If the strategy includes "url", we need to de-localize the URL
+ // before passing it to the server middleware.
+ //
+ // The middleware is responsible for mapping a localized URL to the
+ // de-localized URL e.g. `/en/about` to `/about`. Otherwise,
+ // the server can't render the correct page.
+ let newRequest
+ if (strategy.includes('url')) {
+ newRequest = cloneRequestWithFallback(request, runtime.deLocalizeUrl(url))
+ } else {
+ newRequest = cloneRequestWithFallback(request, url)
+ }
+ // the message functions that have been called in this request
+ /** @type {Set} */
+ const messageCalls = new Set()
+ const response = await runtime.serverAsyncLocalStorage?.run(
+ { locale, origin, messageCalls },
+ () => resolve({ locale, request: newRequest }),
+ )
+ // Only modify HTML responses
+ if (
+ runtime.experimentalMiddlewareLocaleSplitting &&
+ response.headers.get('Content-Type')?.includes('html')
+ ) {
+ const body = await response.text()
+ const messages = []
+ // using .values() to avoid polyfilling in older projects. else the following error is thrown
+ // Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
+ for (const messageCall of Array.from(messageCalls)) {
+ const [id, locale] = /** @type {[string, import("./runtime.js").Locale]} */ (
+ messageCall.split(':')
+ )
+ messages.push(`${id}: ${compiledBundles[id]?.[locale]}`)
+ }
+ // Prevent translated content from terminating the inline script tag.
+ const escapedMessages = messages.join(',').replace(/<\/(script)/gi, '<\\/$1')
+ // Reuse the request's CSP nonce (if any) so the injected script is allowed under a strict CSP
+ const nonce = response.headers.get('Content-Security-Policy')?.match(/'nonce-([\w+/=-]+)'/)?.[1]
+ const nonceAttr = nonce ? `nonce="${nonce}"` : ''
+ const script = ``
+ // Insert the script before the closing head tag
+ const newBody = body.replace('', `${script}`)
+ // Create a new response with the modified body
+ // Clone all headers except Content-Length which will be set automatically
+ const newHeaders = new Headers(response.headers)
+ newHeaders.delete('Content-Length') // Let the browser calculate the correct length
+ return new Response(newBody, {
+ status: response.status,
+ statusText: response.statusText,
+ headers: newHeaders,
+ })
+ }
+ return response
}
/**
* @param {Request} request
@@ -190,13 +197,13 @@ export async function paraglideMiddleware(request, resolve, options) {
* @returns {URL}
*/
function resolveMiddlewareUrl(request, effectiveRequestUrl) {
- if (typeof effectiveRequestUrl === "function") {
- return new URL(effectiveRequestUrl(request), request.url);
- }
- if (typeof effectiveRequestUrl === "string" || effectiveRequestUrl instanceof URL) {
- return new URL(effectiveRequestUrl, request.url);
- }
- return new URL(request.url);
+ if (typeof effectiveRequestUrl === 'function') {
+ return new URL(effectiveRequestUrl(request), request.url)
+ }
+ if (typeof effectiveRequestUrl === 'string' || effectiveRequestUrl instanceof URL) {
+ return new URL(effectiveRequestUrl, request.url)
+ }
+ return new URL(request.url)
}
/**
* Some metaframeworks (NextJS) require a new Request object.
@@ -214,33 +221,29 @@ function resolveMiddlewareUrl(request, effectiveRequestUrl) {
* @returns {Request}
*/
function cloneRequestWithFallback(request, url = request.url) {
- const targetUrl = typeof url === "string" ? url : url.href;
- if (targetUrl === request.url) {
- try {
- // Clone first so building a new Request does not consume the original body stream.
- return new Request(request.clone());
- }
- catch {
- try {
- return new Request(request);
- }
- catch {
- return request;
- }
- }
- }
+ const targetUrl = typeof url === 'string' ? url : url.href
+ if (targetUrl === request.url) {
try {
- // Clone first so building a new Request does not consume the original body stream.
- return new Request(targetUrl, request.clone());
+ // Clone first so building a new Request does not consume the original body stream.
+ return new Request(request.clone())
+ } catch {
+ try {
+ return new Request(request)
+ } catch {
+ return request
+ }
}
- catch {
- try {
- return new Request(targetUrl, request);
- }
- catch {
- return request;
- }
+ }
+ try {
+ // Clone first so building a new Request does not consume the original body stream.
+ return new Request(targetUrl, request.clone())
+ } catch {
+ try {
+ return new Request(targetUrl, request)
+ } catch {
+ return request
}
+ }
}
/**
* Creates a mock AsyncLocalStorage implementation for environments where
@@ -253,25 +256,24 @@ function cloneRequestWithFallback(request, url = request.url) {
* @returns {import("./runtime.js").ParaglideAsyncLocalStorage}
*/
function createMockAsyncLocalStorage() {
- /** @type {any} */
- let currentStore = undefined;
- return {
- getStore() {
- return currentStore;
- },
- async run(store, callback) {
- currentStore = store;
- try {
- return await callback();
- }
- finally {
- currentStore = undefined;
- }
- },
- };
+ /** @type {any} */
+ let currentStore = undefined
+ return {
+ getStore() {
+ return currentStore
+ },
+ async run(store, callback) {
+ currentStore = store
+ try {
+ return await callback()
+ } finally {
+ currentStore = undefined
+ }
+ },
+ }
}
// Used in generated server.js when async local storage is disabled.
-void createMockAsyncLocalStorage;
+void createMockAsyncLocalStorage
/**
* The compiled messages for the server middleware.
*
@@ -279,4 +281,4 @@ void createMockAsyncLocalStorage;
*
* @type {Record>}
*/
-const compiledBundles = {};
+const compiledBundles = {}