Skip to content

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