# telegraf-fluent

> Fixed i18n plugin for Telegraf v4 (using fluent like @grammy/i18n)

Latest version **1.0.0** (published 2023-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install telegraf-fluent
pnpm add telegraf-fluent
yarn add telegraf-fluent
bun add telegraf-fluent
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-03-31 |
| First published | 2023-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Degreet |
| Maintainers | degreet |
| Keywords | telegraf, fluent, i18n |

## Links

- npm: https://www.npmjs.com/package/telegraf-fluent
- Repository: https://github.com/Degreet/telegraf-fluent
- Homepage: https://github.com/Degreet/telegraf-fluent#readme
- Issues: https://github.com/Degreet/telegraf-fluent/issues
- npm.io page: https://npm.io/package/telegraf-fluent

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^4.3.4
- [telegraf](https://npm.io/package/telegraf.md) ^4.12.2
- [@fluent/bundle](https://npm.io/package/@fluent/bundle.md) ^0.18.0

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2023-03-31

## README

# Telegraf Fluent I18n

Fixed i18n plugin for Telegraf v4 (using fluent like @grammy/i18n)

```
npm install telegraf-fluent
# or
yarn add telegraf-fluent
```

# Example

locales/en.ftl
```fluent
name = user
hello =
  Hello, {name}!
hello_world =
  Hello, {$name}!
```

index.ts

```typescript
import { Telegraf, Context } from 'telegraf';
import { I18n, match } from 'telegraf-fluent';
import * as path from 'path';

class MyContext extends Context {
  t: (name: string, pattern?: any) => string;
  i18nLocale: string;
}

const bot = new Telegraf('TOKEN', { contextType: MyContext });

const i18n = new I18n<MyContext>({
  locales: 'en',
  directory: path.resolve(__dirname, 'locales'),
});

bot.use(i18n.middleware());
bot.hears(match('hello'), (ctx) => ctx.reply(ctx.t('hello', { name: ctx.from?.first_name })))
```

index.js
```javascript
const { Telegraf, Context } = require('telegraf');
const { I18n, match } = require('telegraf-fluent');
const path = require('path')

const bot = new Telegraf('TOKEN');

const i18n = new I18n({
  locales: 'en',
  directory: path.resolve(__dirname, 'locales'),
});

bot.use(i18n.middleware());
bot.hears(match('hello'), (ctx) => ctx.reply(ctx.t('hello', { name: ctx.from?.first_name })))
```

# Debug

```typescript
import debug from 'debug'; // typescript
const debug = require('debug'); // javascript

debug.enable('telegraf:fluent');
```

---
_Source: https://npm.io/package/telegraf-fluent · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
