ArtificialSenseDocs

Docs / Infrastructure

SenseI18nService

Signal-based internationalisation for @artificialsenselabs/ui โ€” built-in EN/DE/ES/FR bundles, runtime overrides, and RTL direction.

Overview

Category: Infrastructure. Import: import { SenseI18nService, AS_FR } from '@artificialsenselabs/ui';

const i18n = inject(SenseI18nService);
const label = i18n.translate('select.clear');
i18n.setBundle(AS_FR, 'fr');
i18n.extend({ 'custom.key': 'Override' });

API

MemberDescription
translate(key, params?)Resolve a key with optional {placeholder} interpolation.
setBundle(bundle, locale)Swap locale pack; merges over English so missing keys still render.
extend(partial)Merge ad-hoc keys into the active bundle.
locale / dirActive BCP 47 tag and computed ltr | rtl direction.

Built-in bundles

  • AS_EN, AS_DE, AS_ES, AS_FR โ€” canonical key parity enforced in CI.
  • Typed keys via SenseTranslationKey (derived from en.ts).
  • Machine gate: pnpm run check:i18n blocks hardcoded ARIA/label strings in libs/ui.