i18n-ts
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

i18n-ts

I18n-ts is a type safe internationalization utility for TypeScript. The i18n messages are defined as plain TypeScript objects:

 
const en = {
   hello: "Hi!"
   greeting: (name: string) => `Hi ${name}`
};
 
const de = {
   hello: "Hallo!",
   greeting: (name: string) => `Hallo ${name}`
};
const i18n = {
   en: en,
   de: de,
   default: en
};
 
const messages = new I18nResolver(i18n, "de").translation;
 
// TypeScript will infere the precise type of messages
console.log(messages.hello);

Package Sidebar

Install

npm i i18n-ts

Weekly Downloads

8,327

Version

1.0.5

License

MIT

Unpacked Size

9.53 kB

Total Files

14

Last publish

Collaborators

  • sparkbit