ci: revert Compile translations step from CI workflows

This commit is contained in:
yiling
2026-06-26 12:24:41 +08:00
parent ba5f7296a8
commit bbe36a028d
52 changed files with 2070 additions and 1784 deletions
-3
View File
@@ -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
-3
View File
@@ -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
+24 -21
View File
@@ -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 `<b>...</b>`.
- 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 `<ParaglideMessage>` 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
<ParaglideMessage
;<ParaglideMessage
message={m.welcome}
inputs={{ name: "Ada" }}
inputs={{ name: 'Ada' }}
markup={{
b: ({ children }) => <b>{children}</b>,
icon: () => <span aria-hidden="true" className="icon-wave" />,
+2 -2
View File
@@ -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'
+1 -1
View File
@@ -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'
export * as m from './messages/_index.js'
+20 -20
View File
@@ -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
@@ -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'
export * from './password_protected.js'
+23 -15
View File
@@ -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<All_CollectionsInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<All_CollectionsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_all_collections(inputs)
return zh_all_collections(inputs)
});
* | 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<All_CollectionsInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_all_collections(inputs)
return zh_all_collections(inputs)
}
)
+23 -15
View File
@@ -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<All_Share_LinksInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<All_Share_LinksInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_all_share_links(inputs)
return zh_all_share_links(inputs)
});
* | 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<All_Share_LinksInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_all_share_links(inputs)
return zh_all_share_links(inputs)
}
)
+23 -15
View File
@@ -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<Create_AccountInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<Create_AccountInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_create_account(inputs)
return zh_create_account(inputs)
});
* | 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<Create_AccountInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_create_account(inputs)
return zh_create_account(inputs)
}
)
+23 -15
View File
@@ -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<DashboardInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<DashboardInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_dashboard(inputs)
return zh_dashboard(inputs)
});
* | 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<DashboardInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_dashboard(inputs)
return zh_dashboard(inputs)
}
)
+23 -15
View File
@@ -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<File_Not_FoundInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<File_Not_FoundInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_file_not_found(inputs)
return zh_file_not_found(inputs)
});
* | 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<File_Not_FoundInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_file_not_found(inputs)
return zh_file_not_found(inputs)
}
)
+23 -15
View File
@@ -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<LanguageInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<LanguageInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_language(inputs)
return zh_language(inputs)
});
* | 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<LanguageInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_language(inputs)
return zh_language(inputs)
}
)
+23 -15
View File
@@ -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<Language_SettingsInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<Language_SettingsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_language_settings(inputs)
return zh_language_settings(inputs)
});
* | 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<Language_SettingsInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_language_settings(inputs)
return zh_language_settings(inputs)
}
)
+23 -15
View File
@@ -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<Link_VisibilityInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<Link_VisibilityInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_link_visibility(inputs)
return zh_link_visibility(inputs)
});
* | 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<Link_VisibilityInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_link_visibility(inputs)
return zh_link_visibility(inputs)
}
)
+23 -15
View File
@@ -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<NotificationsInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<NotificationsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_notifications(inputs)
return zh_notifications(inputs)
});
* | 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<NotificationsInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_notifications(inputs)
return zh_notifications(inputs)
}
)
@@ -1,4 +1,4 @@
{
"type": "module",
"sideEffects": false
"type": "module",
"sideEffects": false
}
+23 -15
View File
@@ -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<Password_ProtectedInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<Password_ProtectedInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_password_protected(inputs)
return zh_password_protected(inputs)
});
* | 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<Password_ProtectedInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_password_protected(inputs)
return zh_password_protected(inputs)
}
)
+23 -15
View File
@@ -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<Personal_InfoInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<Personal_InfoInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_personal_info(inputs)
return zh_personal_info(inputs)
});
* | 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<Personal_InfoInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_personal_info(inputs)
return zh_personal_info(inputs)
}
)
+23 -15
View File
@@ -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<ProjectsInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<ProjectsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_projects(inputs)
return zh_projects(inputs)
});
* | 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<ProjectsInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_projects(inputs)
return zh_projects(inputs)
}
)
@@ -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<Recently_Deleted_NoticeInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<Recently_Deleted_NoticeInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_recently_deleted_notice(inputs)
return zh_recently_deleted_notice(inputs)
});
* | 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<Recently_Deleted_NoticeInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_recently_deleted_notice(inputs)
return zh_recently_deleted_notice(inputs)
}
)
+23 -15
View File
@@ -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<Select_A_TeamInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<Select_A_TeamInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_select_a_team(inputs)
return zh_select_a_team(inputs)
});
* | 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<Select_A_TeamInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_select_a_team(inputs)
return zh_select_a_team(inputs)
}
)
@@ -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<Select_Asset_To_View_DetailsInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<Select_Asset_To_View_DetailsInputs, { locale?: "en" | "zh" }, {}>} */ ((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)
});
* | 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<Select_Asset_To_View_DetailsInputs, { locale?: "en" | "zh" }, {}>} */ (
(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)
}
)
@@ -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<Select_Preferred_LanguageInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<Select_Preferred_LanguageInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_select_preferred_language(inputs)
return zh_select_preferred_language(inputs)
});
* | 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<Select_Preferred_LanguageInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_select_preferred_language(inputs)
return zh_select_preferred_language(inputs)
}
)
+23 -15
View File
@@ -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<SettingsInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<SettingsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_settings(inputs)
return zh_settings(inputs)
});
* | 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<SettingsInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_settings(inputs)
return zh_settings(inputs)
}
)
+23 -15
View File
@@ -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<UploadsInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<UploadsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_uploads(inputs)
return zh_uploads(inputs)
});
* | 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<UploadsInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_uploads(inputs)
return zh_uploads(inputs)
}
)
+23 -15
View File
@@ -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<Welcome_BackInputs, {
locale?: "en" | "zh";
}, {}>;
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 = {}
@@ -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<Welcome_BackInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_welcome_back(inputs)
return zh_welcome_back(inputs)
});
* | 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<Welcome_BackInputs, { locale?: "en" | "zh" }, {}>} */ (
(inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === 'en') return en_welcome_back(inputs)
return zh_welcome_back(inputs)
}
)
+39 -7
View File
@@ -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'
+10 -10
View File
@@ -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);
};
const { unit, ...intlOptions } = options
return new Intl.RelativeTimeFormat(locale, intlOptions).format(Number(input), unit)
}
+223 -158
View File
@@ -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<string, string | null | undefined>} An object containing all named groups from the match.
*/
export function aggregateGroups(match: any): Record<string, string | null | undefined>;
export function aggregateGroups(match: any): Record<string, string | null | undefined>
/**
* @typedef {object} ShouldRedirectServerInput
* @property {Request} request
@@ -290,7 +295,7 @@ export function aggregateGroups(match: any): Record<string, string | null | unde
* @param {ShouldRedirectInput} [input]
* @returns {Promise<ShouldRedirectResult>}
*/
export function shouldRedirect(input?: ShouldRedirectInput): Promise<ShouldRedirectResult>;
export function shouldRedirect(input?: ShouldRedirectInput): Promise<ShouldRedirectResult>
/**
* High-level URL localization function optimized for client-side UI usage.
*
@@ -331,9 +336,12 @@ export function shouldRedirect(input?: ShouldRedirectInput): Promise<ShouldRedir
* @param {Locale} [options.locale] - Target locale. If not provided, uses `getLocale()`
* @returns {string} The localized href, relative if input was relative
*/
export function localizeHref(href: string, options?: {
locale?: Locale;
}): string;
export function localizeHref(
href: string,
options?: {
locale?: Locale
},
): string
/**
* High-level URL de-localization function optimized for client-side UI usage.
*
@@ -374,12 +382,12 @@ export function localizeHref(href: string, options?: {
* @param {string} href - The href to de-localize (can be relative or absolute)
* @returns {string} The de-localized href, relative if input was relative
*/
export function deLocalizeHref(href: string): string;
export function deLocalizeHref(href: string): string
/**
* @param {string} safeModuleId
* @param {Locale} locale
*/
export function trackMessageCall(safeModuleId: string, locale: Locale): void;
export function trackMessageCall(safeModuleId: string, locale: Locale): void
/**
* Generates localized URL variants for all provided URLs based on your configured locales and URL patterns.
*
@@ -423,7 +431,7 @@ export function trackMessageCall(safeModuleId: string, locale: Locale): void;
* @returns {URL[]} Array of URL objects representing all localized variants.
* The order follows each input URL with all its locale variants before moving to the next URL.
*/
export function generateStaticLocalizedUrls(urls: (string | URL)[]): URL[];
export function generateStaticLocalizedUrls(urls: (string | URL)[]): URL[]
/**
* Checks if the given strategy is a custom strategy.
*
@@ -431,7 +439,7 @@ export function generateStaticLocalizedUrls(urls: (string | URL)[]): URL[];
* Must be a string that starts with "custom-" followed by alphanumeric characters, hyphens, or underscores.
* @returns {boolean} Returns true if it is a custom strategy, false otherwise.
*/
export function isCustomStrategy(strategy: unknown): boolean;
export function isCustomStrategy(strategy: unknown): boolean
/**
* Defines a custom strategy that is executed on the server.
*
@@ -442,7 +450,10 @@ export function isCustomStrategy(strategy: unknown): boolean;
* the method getLocale.
* @returns {void}
*/
export function defineCustomServerStrategy(strategy: string, handler: CustomServerStrategyHandler): void;
export function defineCustomServerStrategy(
strategy: string,
handler: CustomServerStrategyHandler,
): void
/**
* Defines a custom strategy that is executed on the client.
*
@@ -453,7 +464,10 @@ export function defineCustomServerStrategy(strategy: string, handler: CustomServ
* methods getLocale and setLocale.
* @returns {void}
*/
export function defineCustomClientStrategy(strategy: string, handler: CustomClientStrategyHandler): void;
export function defineCustomClientStrategy(
strategy: string,
handler: CustomClientStrategyHandler,
): void
/**
* The project's base locale.
*
@@ -462,7 +476,7 @@ export function defineCustomClientStrategy(strategy: string, handler: CustomClie
* // do something
* }
*/
export const baseLocale: "en";
export const baseLocale: 'en'
/**
* The project's locales that have been specified in the settings.
*
@@ -471,19 +485,27 @@ export const baseLocale: "en";
* throw new Error('Locale is not available');
* }
*/
export const locales: readonly ["en", "zh"];
export const locales: readonly ['en', 'zh']
/** @type {string} */
export const cookieName: string;
export const cookieName: string
/** @type {number} */
export const cookieMaxAge: number;
export const cookieMaxAge: number
/** @type {string} */
export const cookieDomain: string;
export const cookieDomain: string
/** @type {string} */
export const localStorageKey: string;
export const localStorageKey: string
/**
* @type {Array<"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage" | `custom-${string}`>}
*/
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<void>} 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<Locale>;
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<Locale>
/**
* @typedef {"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage"} BuiltInStrategy
*/
@@ -597,73 +637,87 @@ export function extractLocaleFromRequestAsync(request: Request, options?: {
* @typedef {{ getLocale: () => Promise<string|undefined> | (string | undefined), setLocale: (locale: string) => Promise<void> | void }} CustomClientStrategyHandler
*/
/** @type {Map<string, CustomServerStrategyHandler>} */
export const customServerStrategies: Map<string, CustomServerStrategyHandler>;
export const customServerStrategies: Map<string, CustomServerStrategyHandler>
/** @type {Map<string, CustomClientStrategyHandler>} */
export const customClientStrategies: Map<string, CustomClientStrategyHandler>;
export const customClientStrategies: Map<string, CustomClientStrategyHandler>
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<string>;
} | undefined;
run: (store: {
locale?: Locale;
origin?: string;
messageCalls?: Set<string>;
}, cb: any) => any;
};
export type SetLocaleFn = (newLocale: Locale, options?: {
reload?: boolean;
}) => void | Promise<void>;
getStore():
| {
locale?: Locale
origin?: string
messageCalls?: Set<string>
}
| undefined
run: (
store: {
locale?: Locale
origin?: string
messageCalls?: Set<string>
},
cb: any,
) => any
}
export type SetLocaleFn = (
newLocale: Locale,
options?: {
reload?: boolean
},
) => void | Promise<void>
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<Strategy>;
/**
* - 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<Strategy>
export type CustomServerStrategyHandler = {
getLocale: (request?: Request) => Promise<string | undefined> | (string | undefined);
};
getLocale: (request?: Request) => Promise<string | undefined> | (string | undefined)
}
export type CustomClientStrategyHandler = {
getLocale: () => Promise<string | undefined> | (string | undefined);
setLocale: (locale: string) => Promise<void> | void;
};
getLocale: () => Promise<string | undefined> | (string | undefined)
setLocale: (locale: string) => Promise<void> | 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<string, unknown>;
export type MessageMarkupOptions = Record<string, unknown>
/**
* Record of markup attributes for a tag instance.
*/
export type MessageMarkupAttributes = Record<string, string | true>;
export type MessageMarkupAttributes = Record<string, string | true>
/**
* 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<string, MessageMarkupTag>;
export type MessageMarkupSchema = Record<string, MessageMarkupTag>
/**
* Type-only metadata attached to compiled message functions.
*/
export type MessageMetadata<Inputs, Options, Markup extends MessageMarkupSchema = Record<string, MessageMarkupTag>> = {
readonly __paraglide?: {
inputs: Inputs;
options: Options;
markup: Markup;
};
};
export type MessageMetadata<
Inputs,
Options,
Markup extends MessageMarkupSchema = Record<string, MessageMarkupTag>,
> = {
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<string, never>) => LocalizedString;
export type MessageFunction = (inputs?: Record<string, never>) => 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<T extends string> = (params: Record<string, never>, options: {
locale: T;
}) => LocalizedString;
export type MessageBundleFunction<T extends string> = (
params: Record<string, never>,
options: {
locale: T
},
) => LocalizedString
File diff suppressed because it is too large Load Diff
+8 -7
View File
@@ -87,10 +87,11 @@
* }
* ```
*/
export function paraglideMiddleware<T>(request: Request, resolve: (args: {
request: Request;
locale: import("./runtime.js").Locale;
}) => T | Promise<T>, options?: {
effectiveRequestUrl?: string | URL | ((request: Request) => string | URL);
onRedirect?: (response: Response) => void;
}): Promise<Response>;
export function paraglideMiddleware<T>(
request: Request,
resolve: (args: { request: Request; locale: import('./runtime.js').Locale }) => T | Promise<T>,
options?: {
effectiveRequestUrl?: string | URL | ((request: Request) => string | URL)
onRedirect?: (response: Response) => void
},
): Promise<Response>
+141 -139
View File
@@ -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<string>} */
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<string, string>} */
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<string>} */
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<string>' 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 = `<script ${nonceAttr}>globalThis.__paraglide = globalThis.__paraglide ?? {}; globalThis.__paraglide.ssr = { ${escapedMessages} }</script>`;
// Insert the script before the closing head tag
const newBody = body.replace("</head>", `${script}</head>`);
// 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<string, string>} */
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<string>} */
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<string>' 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 = `<script ${nonceAttr}>globalThis.__paraglide = globalThis.__paraglide ?? {}; globalThis.__paraglide.ssr = { ${escapedMessages} }</script>`
// Insert the script before the closing head tag
const newBody = body.replace('</head>', `${script}</head>`)
// 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<string, Record<import("./runtime.js").Locale, string>>}
*/
const compiledBundles = {};
const compiledBundles = {}