Skip to content

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

ฟังก์ชัน: registerLocalized() ​

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

อัลฟา

ลงทะเบียน custom elements พร้อมข้อความตาม locale และทิศทางการแสดงผล

ยอมรับ 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" });