Documentation - v0.27.1
    Preparing search index...

    Module @mtcute/i18n

    @mtcute/i18n

    📖 API Reference

    Internationalization library built with TypeScript and mtcute in mind.

    • 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.
    // 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))
    })

    Interfaces

    I18nStrings
    MtcuteI18nParameters

    Type Aliases

    I18nValue
    I18nValueDynamic
    I18nValueLiteral
    MtcuteI18nAdapter
    MtcuteI18nFunction
    OtherLanguageWrap
    OtherLanguageWrapExhaustive

    Functions

    createMtcuteI18n
    createPluralEnglish
    createPluralRussian
    extractLanguageFromUpdate
    ordinalSuffixEnglish
    pluralizeEnglish
    pluralizeRussian