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