Skip to content

pantoken / renderers/web-components/src / createLocaleSet

Function: createLocaleSet()

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

Alpha

Define the locale subset your app supports. Pass the imported bundle objects as an object whose keys are the locale tags (JavaScript shorthand makes this natural). TypeScript narrows the accepted locale tags to only the keys you provide.

Not calling createLocaleSet at all gives the full 44-locale barrel — use this factory only when you need compile-time validation or explicit tree-shaking signals.

Type Parameters

K

K extends string

Parameters

bundles

Record<K, LocaleBundle>

Returns

LocaleSet<K>

Example

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