Onboarding notes for AI coding agents working in this repository.
@react5/i18n is a small, framework-free, published npm library of localization utilities. Keep it generic:
no UI, no bundled translations, no knowledge of any particular app's locales.
src/index.ts— the public API; export everything public from here.src/locale.ts—Locale,languageOf(locale, supported, fallback?),languageSubtag.src/resolveMessages.ts— per-message fallback and overrides; warns on missing messages only when the host passeswarnOnMissing(never readimport.meta.envin the library: Vite pre-bundles dependencies without it and the module would throw at load).src/formatMessage.ts— ICU formatting viaintl-messageformat; throws on bad input.src/store.ts—createI18nStore,I18nStore,LocaleSource,LocaleListener.src/format.ts—Intlwrappers:formatDate,formatDateTime,formatHours,compareText,formatLocale.src/negotiate.ts—negotiateLocale,isValidTimeZone,isValidLocaleTag.src/firstDayOfWeek.ts— locale-aware week start.bin/i18n-validate.mjs— thei18n-validateCLI andvalidateCatalog; plain ESM, no build step.tests/— Vitest forsrc/(*.test.ts) andnode:testfor the CLI (validate.test.mjs).
npm run build— type-check, emit declarations, fix declaration import extensions (scripts/fix-dts-extensions.mjs), bundle with Vite todist/i18n.js.npm test— CLI tests, then Vitest.npm run typecheck—tsc --noEmit.npm publishrunsprepublishOnly(build + test). Dependencies stay external in the bundle.
- Code style: Prettier (
.prettierrc.json: single quotes, no semicolons, width 100), ESM only,.tsimport extensions in source. - Never run
git commit; leave changes for the user to review and commit.