@marmeon/i18n
v0.3.0
Published
Translations for Marmeon apps: typed messages per module (TS files), an ICU subset, a translator per request and the locale middleware. UI-agnostic — `@marmeon/i18n/messages` is the browser-safe core the UI adapters build on.
Maintainers
Readme
@marmeon/i18n
Translations for Marmeon apps: typed language files per module, an ICU subset, the request's language, and formatting — on the server and in the browser.
Installation
Part of every new Marmeon app: pnpm create marmeon installs it.
A language file
const en = {
title: 'Notes',
count: '{count, plural, =0 {No notes yet} one {# note} other {# notes}}',
saved: 'Saved {title}.',
} as const;
export default en;
declare module '@marmeon/i18n/messages' {
interface Translations {
notes: typeof en;
}
}this.#translator.get('notes.count', { count: 3 }); // "3 notes"The English file is the source: the compiler checks every key and every placeholder against it. On the server the injected
Translator speaks the request's language; in a view, useTranslation() of @marmeon/react does.
Documentation
MIT · part of Marmeon
