moosmann
v0.4.0
Published
i18n for typescript developers
Downloads
8
Readme
moosmann
i18n for typescript developers
I'm currently developing this while doing other things because I wanted to have a simple system for localization. It is in no way ready to use in production and the API ~~may~~ will change on a whim.
How to use
- Create your locales:
// [locales/en.ts]
export default {
greeting: (name: string) => `Hello, ${name}!`,
};
// [locales/de.ts]
import type en from "./en";
export default {
greeting: (name) => `Hallo, ${name}!`,
} satisfies typeof en;
- Construct an instance of moosmann
export const i18n = moosmann({
en: en,
de: () => import("./locales/de"),
});
- Load a locale and use it
const t = await i18n.loadLocale("de");
const greeting = t("greeting", "Moosmann");
// => "Hallo, Moosmann!"
See examples for more!