# i18n (provideKptI18n / KptI18n) Translations for component labels. Base languages: EN (default, always in the bundle), PL (a separate subpath). Signal-based (zoneless-friendly), with no external dependencies. Import: `import { provideKptI18n, KptI18n } from '@konce-pt/angular';` ## Configuration (provider) - `provideKptI18n({ locale?, messages? }): EnvironmentProviders` - in `bootstrapApplication`. - `locale`: 'en' | 'pl' | any string (default 'en'). - `messages`: `Record>` - registers a new language or overrides an existing one (deep merge onto the language base - built-in or EN). ## Polish import { KPT_MESSAGES_PL } from '@konce-pt/angular/i18n/pl'; provideKptI18n({ locale: 'pl', messages: { pl: KPT_MESSAGES_PL } }); The Polish dictionary is not in the core entry, so an English-only app does not carry it. Without it in `messages`, `KptI18n` loads it lazily the first time PL is active - until then the labels are EN and a dev build warns once. An app that starts in Polish or switches languages live should pass it explicitly. ## The KptI18n service (providedIn: 'root') - `locale: Signal` - the current language. - `setLocale(locale)` - a runtime change (reactive across every component). - `registerMessages(locale, patch)` - adds to or overrides a dictionary at runtime. - `t(key, params?)` - translates a dotted key (`'paginator.range'`) with `{name}` interpolation; ICU plural blocks (`{count, plural, one {...} other {...}}`) follow the plural rules of the current `locale`. ## Adding your own language (one JSON file) import de from './i18n/de.json'; // the shape is the KptMessages interface provideKptI18n({ locale: 'de', messages: { de } }); // at runtime: inject(KptI18n).registerMessages('de', de); inject(KptI18n).setLocale('de'); ## Switching language at runtime const i18n = inject(KptI18n); i18n.setLocale('pl'); ## The key contract (KptMessages) Namespaces: `common` (close/remove/previous/next/clear/done/all), `paginator` (rowsPerPage/range/prevPage/nextPage), `select`, `listbox`, `dataView`, `dataTable`, `confirm`, `fileUpload`, `chipsInput`, `dateRange`, `datepicker`, `pickList`, `orderList`, `inputNumber`, `password`, `rating`, `slider`, `colorPicker`, `inputOtp`, `autocomplete`, `spinner`, `speedDial`, `scrollTop`, `splitButton`, `panel`, `splitter`, `stepper`, `image`, `toast`, `avatarGroup`, `meterGroup`, `breadcrumb`, `richText`, `auth` (including `auth.promo.*`). Interpolations: `paginator.range` ({start},{end},{total}), `dataTable.filter*` ({column}), `richText.styleHeading` ({level}), `auth.continueWith` ({provider}), `auth.passwordHint` and `auth.errorMinLength` ({min}), `rating.star` ({value},{max}), `panel.toggleNamed` ({header}), `stepper.step*` ({index},{label}), `carousel.slideOf` and `galleria.position` ({index},{total}), `image.previewOf` ({alt}), `avatarGroup.more` ({count}), `inputOtp.cell` ({index},{count}), `autocomplete.results` ({count}), `chipsInput.added`/`removed`/`duplicate` ({value}), `dateRange.rangeStart`/`rangeEnd`/`inRange`/`pickEnd` ({date}) and `dateRange.picked` ({start},{end}). Day and month names in calendars are derived from `Intl` per locale (not from the dictionary). ## Note Individual labels can also be overridden per component through the matching `input()` (e.g. `emptyMessage`, `acceptLabel`) - the input takes priority over the i18n dictionary. ## Where the dictionaries live The contract (`KptMessages`), the base EN/PL dictionaries and the translation core (`translate`, `deepMerge`) live in `@konce-pt/i18n` - a pure-TypeScript package with no framework dependency, shared with the React port so both render identical labels. `@konce-pt/angular` re-exports all of it (PL through `@konce-pt/angular/i18n/pl`), so you never need to install `@konce-pt/i18n` yourself. ## Runtime dictionaries, keys and the page language `registerMessages()` after start-up (a lazily loaded JSON) repaints the components at once, also for the active language. `t()` accepts `KptMessageKey` (the base dictionary's dotted keys, with editor completion) or any string; a key found in no dictionary returns the key itself and, in a dev build, warns once in the console. The library does not set `` - set it yourself together with the language, so a screen reader reads the labels with the right pronunciation.