0.12.0 • Published 3 days ago

@mtcute/i18n v0.12.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 days ago

@mtcute/i18n

📖 API Reference

Internationalization library built with TypeScript and mtcute in mind.

Features

  • Type-safe: All string keys and parameters are type-checked
  • Plurals: Supports pluralization
  • Customizable: Supports custom locales and customizing existing ones
  • Pluggable: Can be used with any library, not just mtcute. Can also be used with other i18n libraries.

Usage

// i18n/en.ts
export const en = {
    hello: (name: string) => `Hello, ${name}!`,
}

// i18n/ru.ts
export const ru: OtherLanguageWrap<typeof en> = {
    hello: (name: string) => `Привет, ${name}!`,
}

// i18n/index.ts
export const tr = createMtcuteI18n({
    primaryLanguage: {
        name: 'en',
        strings: en,
    },
    otherLanguages: { ru },
})

// main.ts
dp.onNewMessage(async (upd) => {
    await upd.replyText(tr(upd, 'hello', upd.sender.displayName))
})
0.12.0

3 days ago

0.11.0

19 days ago

0.10.0

1 month ago

0.9.0

2 months ago

0.8.0

2 months ago

0.7.0

3 months ago

0.5.0

5 months ago

0.6.0

5 months ago

0.4.0

5 months ago

0.3.0

5 months ago

0.2.0

5 months ago

0.1.1

6 months ago

0.1.0

6 months ago