Skip to content

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

Feidhm: createLocaleSet() ​

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

Ailfha

Sainmhínigh an fho-shraith de na locale a thacaíonn do d'fheidhmchlár. Pas na réada bundle allmhairithe mar réad ina bhfuil na heochracha ná na lipéid áitiúlachta (déantar an giorrúchán JavaScript seo go nádúrtha). Caolann TypeScript na lipéid áitiúlachta a nglactar leo chun na heochracha a sholáthraíonn tú amháin.

Má fhanann tú gan glaoch ar createLocaleSet ar chor ar bith tugann sé an bairille iomlán le 44 locale — ná húsáid an ghineadóir seo ach nuair is gá fíorú tráth-comhthátha nó comharthaí soiléire do tree-shaking.

Paraiméadair Cineál ​

K ​

K síneann string

Paraiméadair ​

bundles ​

Record<K, LocaleBundle>

Tuairisceáin ​

LocaleSet<K>

Sampla ​

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