Skip to content

Commit

Permalink
fix: small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
strbit committed Aug 29, 2024
1 parent f83ba72 commit 1b16657
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { I18n, I18nFlavor } from "https://deno.land/x/grammy_i18n/mod.ts";

An example project structure, you can also seperate your translations into different files to make it easier to maintain large projects.
Nested translations don't change how you use translation keys, so nothing should break if you decide to use them.

```
.
├── locales/
Expand Down
4 changes: 4 additions & 0 deletions examples/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ bot.command("checkout", async (ctx) => {
await ctx.reply(ctx.t("checkout"));
});

bot.command("multiline", async (ctx) => {
await ctx.reply(ctx.t("multiline"));
});

bot.start();
6 changes: 6 additions & 0 deletions examples/locales/ckb.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ greeting = سڵاو، { $first_name }!
cart = سڵاو، { $first_name }، لە سەبەتەکەتدا{ $apples } سێو هەن.
checkout = سپاس بۆ بازاڕیکردنەکەت!
language-set = کوردی هەڵبژێردرا!
multiline =
ئەمەش نموونەی...
ئە
فرە هێڵی
پەیام
بۆ ئەوەی بزانین چۆن فۆرمات کراون!
7 changes: 7 additions & 0 deletions examples/locales/de.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ cart = { $first_name }, es {
checkout = Danke für deinen Einkauf!
language-set = Die Sprache wurde zu Deutsch geändert!
multiline =
Dies ist ein Beispiel für
eine
mehrzeilige
Nachricht,
um zu sehen, wie sie formatiert sind!
7 changes: 7 additions & 0 deletions examples/locales/en.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ cart = { $first_name }, there {
checkout = Thank you for purchasing!
language-set = Language has been set to English!
multiline =
This is an example of
a
multiline
message
to see how they are formatted!
6 changes: 6 additions & 0 deletions examples/locales/ku.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ greeting = Silav, { $first_name }!
cart = { $first_name }, di sepeta te de { $apples } sêv hene.
checkout = Spas bo kirîna te!
language-set = Kurdî hate hilbijartin!
multiline =
Ev mînakek e
yek
multiline
agah
da ku bibînin ka ew çawa têne format kirin!
5 changes: 5 additions & 0 deletions examples/locales/ru/multiline.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
multiline =
Это пример
многострочных
сообщений
чтобы увидеть, как они отформатированы!
6 changes: 5 additions & 1 deletion examples/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bot.command("start", async (ctx) => {
await ctx.reply(ctx.t("greeting"));
});

bot.command(["en", "de", "ku", "ckb"], async (ctx) => {
bot.command(["en", "de", "ku", "ckb", "ru"], async (ctx) => {
const locale = ctx.msg.text.substring(1).split(" ")[0];
await ctx.i18n.setLocale(locale);
await ctx.reply(ctx.t("language-set"));
Expand All @@ -58,4 +58,8 @@ bot.command("checkout", async (ctx) => {
await ctx.reply(ctx.t("checkout"));
});

bot.command("multiline", async (ctx) => {
await ctx.reply(ctx.t("multiline"));
});

bot.start();

0 comments on commit 1b16657

Please sign in to comment.