Skip to content

pantoken / renderers/web-components/src / createLocaleSet

Mahi: createLocaleSet()

createLocaleSet<K>(bundles): LocaleSet<K>

Alpha

Whakaritehia te hauraro reo (locale) e tautokohia ana e tō taupānga. Tāpaehia ngā kohinga kua kawemai hei taonga (object) ā ngā kī ko ngā tapanga reo (locale tags) (he māmā tēnei mā te whakarapopototanga o JavaScript). Ka whakatatahia e TypeScript gā tapanga reo e whakaaetia ana kia noho ki ngā kī anake kua whakarato koe.

Ki te kore rawa e karangahia createLocaleSet ka riro te pae katoa o ngā reo e 44 — whakamahia tēnei factory anake ina hiahia koe i te whakamana i te wā tāpae (compile-time validation) rānei i ngā tohu tangohanga-rākau tūtohu (explicit tree-shaking signals).

Ngā Tawhā Momo

K

K whānui string

Ngā Tawhā

bundles

Record<K, LocaleBundle>

Whakahokia

LocaleSet<K>

Tauira

ts
import { createLocaleSet, en, hu, de } from "@pantoken/web-components";

const locales = createLocaleSet({ en, hu, de });

locales.register("hu");          // ✓ type-safe
locales.register("fr");          // TypeScript error — not in this set
locales.has("hu");               // → true (type guard)
locales.get("hu");               // → LocaleBundle