0.17.0 • Published 1 month ago

@mtcute/i18n v0.17.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month 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.17.0

1 month ago

0.16.9

2 months ago

0.16.7

3 months ago

0.13.0

6 months ago

0.14.0

5 months ago

0.15.0

5 months ago

0.16.0

4 months ago

0.12.0

6 months ago

0.11.0

7 months ago

0.10.0

8 months ago

0.9.0

8 months ago

0.8.0

8 months ago

0.7.0

9 months ago

0.5.0

11 months ago

0.6.0

11 months ago

0.4.0

11 months ago

0.3.0

11 months ago

0.2.0

12 months ago

0.1.1

1 year ago

0.1.0

1 year ago