Skip to content

pantoken-root / renderers/web-components/src / registerLocalized

函式: registerLocalized() ​

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

Alpha(內測)

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

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

參數 ​

bundle ​

string | LocaleBundle

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

target? ​

ElementRegistry

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

options? ​

會傳遞給 register()(例如 prefix、only)。

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" });