From 926c25edf7584852c84df590366a36b4d8e2c739 Mon Sep 17 00:00:00 2001 From: Kirill Loskutov Date: Tue, 20 Sep 2022 13:22:16 +0300 Subject: [PATCH 1/5] Remove .middleware() call --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1010a271..9a5dfc0b 100644 --- a/README.md +++ b/README.md @@ -37,23 +37,23 @@ Example bot import { Bot, Context } from "https://deno.land/x/grammy/mod.ts"; import { I18n, I18nFlavor } from "https://deno.land/x/grammy_i18n/mod.ts"; +// For proper typings and auto-completions in IDEs, +// extend the `Context` using `I18nFlavor`. +type MyContext = Context & I18nFlavor; + // Create a new I18n instance. const i18n = new I18n({ defaultLocale: "en", directory: "locales", }); -// For proper typings and auto-completions in IDEs, -// extend the `Context` using `I18nFlavor`. -type MyContext = Context & I18nFlavor; - // Create a bot as usual, but use the modified Context type. const bot = new Bot(""); // <- Put your bot token here // Tell the bot to use the middleware from the instance. // Remember to register this middleware before registering // other middlewares. -bot.use(i18n.middleware()); +bot.use(i18n); bot.command("start", async (ctx) => { // Use the method `t` or `translate` from the context and pass From 9f16b27bd65b06474a5204df588ade4bc6f14e6b Mon Sep 17 00:00:00 2001 From: Kirill Loskutov Date: Tue, 20 Sep 2022 13:34:30 +0300 Subject: [PATCH 2/5] Add MyContext --- README.md | 2 +- examples/node.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a5dfc0b..474946dc 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ import { I18n, I18nFlavor } from "https://deno.land/x/grammy_i18n/mod.ts"; type MyContext = Context & I18nFlavor; // Create a new I18n instance. -const i18n = new I18n({ +const i18n = new I18n({ defaultLocale: "en", directory: "locales", }); diff --git a/examples/node.ts b/examples/node.ts index 80d111f3..126e41c9 100644 --- a/examples/node.ts +++ b/examples/node.ts @@ -16,7 +16,7 @@ bot.use(session({ initial: () => ({ apples: 0 }), })); -const i18n = new I18n({ +const i18n = new I18n({ defaultLocale: "en", useSession: true, directory: "locales", From 09d6343a563af8c9f58b92c1d7af39e82439397b Mon Sep 17 00:00:00 2001 From: Kirill Loskutov Date: Tue, 20 Sep 2022 13:35:25 +0300 Subject: [PATCH 3/5] Update README.md Co-authored-by: KnorpelSenf --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 474946dc..af4f0adf 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ import { Bot, Context } from "https://deno.land/x/grammy/mod.ts"; import { I18n, I18nFlavor } from "https://deno.land/x/grammy_i18n/mod.ts"; // For proper typings and auto-completions in IDEs, -// extend the `Context` using `I18nFlavor`. +// customise the `Context` using `I18nFlavor`. type MyContext = Context & I18nFlavor; // Create a new I18n instance. From 8d445701d93adcb33814465bb71a1aa0c081c69b Mon Sep 17 00:00:00 2001 From: Kirill Loskutov Date: Tue, 20 Sep 2022 13:36:32 +0300 Subject: [PATCH 4/5] Update README.md Co-authored-by: KnorpelSenf --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af4f0adf..ec83bd94 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ import { Bot, Context } from "https://deno.land/x/grammy/mod.ts"; import { I18n, I18nFlavor } from "https://deno.land/x/grammy_i18n/mod.ts"; // For proper typings and auto-completions in IDEs, -// customise the `Context` using `I18nFlavor`. +// customize the `Context` using `I18nFlavor`. type MyContext = Context & I18nFlavor; // Create a new I18n instance. From 57a3548e86457646ed3041c940e025802586d578 Mon Sep 17 00:00:00 2001 From: Kirill Loskutov Date: Tue, 20 Sep 2022 13:50:58 +0300 Subject: [PATCH 5/5] Update comment --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index ec83bd94..deb8b0eb 100644 --- a/README.md +++ b/README.md @@ -50,9 +50,8 @@ const i18n = new I18n({ // Create a bot as usual, but use the modified Context type. const bot = new Bot(""); // <- Put your bot token here -// Tell the bot to use the middleware from the instance. // Remember to register this middleware before registering -// other middlewares. +// your handlers. bot.use(i18n); bot.command("start", async (ctx) => {