Skip to content

pantoken / renderers/svelte/src / registerLocalized

函式: registerLocalized()

registerLocalized(bundle, target?, options?): void

實驗性

註冊自訂元素,並提供語系專屬的字串與文字方向。

接受已完全解析的 LocaleBundle 原始的 BCP47 標籤字串。當傳入字串時, makeStrings 會透過 Intl.DateTimeFormat 推斷星期名稱,其他所有字串 則回退到英文;若要完整翻譯,請傳入 bundle。

參數

bundle

string | LocaleBundle

一個 LocaleBundle 物件,或一個 BCP47 標籤("hu""ar"、…)。

target?

ElementRegistry

要定義到的註冊表(預設為 globalThis.customElements)。

options?

會傳遞給 register()(例如 prefixonly)。

prefix?

string | null

only?

readonly string[]

回傳

void

範例

ts
import { registerLocalized, hu } from "@pantoken/web-components";

registerLocalized(hu);
registerLocalized("ar"); // direction inferred from LOCALES
registerLocalized("x-custom", customElements, { prefix: "x" });