Skip to content

Commit 93b97fc

Browse files
committed
I18N middleware example was added
1 parent 1f6e60f commit 93b97fc

5 files changed

Lines changed: 485 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardMarkup, KeyboardButton
2+
3+
4+
def languages_keyboard():
5+
return InlineKeyboardMarkup(
6+
keyboard=[
7+
[
8+
InlineKeyboardButton(text="English", callback_data='en'),
9+
InlineKeyboardButton(text="Русский", callback_data='ru'),
10+
InlineKeyboardButton(text="O'zbekcha", callback_data='uz_Latn')
11+
]
12+
]
13+
)
14+
15+
16+
def clicker_keyboard(_):
17+
return InlineKeyboardMarkup(
18+
keyboard=[
19+
[
20+
InlineKeyboardButton(text=_("click"), callback_data='click'),
21+
]
22+
]
23+
)
24+
25+
26+
def menu_keyboard(_):
27+
keyboard = ReplyKeyboardMarkup(resize_keyboard=True)
28+
keyboard.add(
29+
KeyboardButton(text=_("My user id")),
30+
KeyboardButton(text=_("My user name")),
31+
KeyboardButton(text=_("My first name"))
32+
)
33+
34+
return keyboard
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# English translations for PROJECT.
2+
# Copyright (C) 2022 ORGANIZATION
3+
# This file is distributed under the same license as the PROJECT project.
4+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2022.
5+
#
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: PROJECT VERSION\n"
9+
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
10+
"POT-Creation-Date: 2022-02-19 18:37+0500\n"
11+
"PO-Revision-Date: 2022-02-18 16:22+0500\n"
12+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13+
"Language: en\n"
14+
"Language-Team: en <LL@li.org>\n"
15+
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=utf-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
"Generated-By: Babel 2.9.1\n"
20+
21+
#: keyboards.py:20
22+
msgid "click"
23+
msgstr ""
24+
25+
#: keyboards.py:29
26+
msgid "My user id"
27+
msgstr ""
28+
29+
#: keyboards.py:30
30+
msgid "My user name"
31+
msgstr ""
32+
33+
#: keyboards.py:31
34+
msgid "My first name"
35+
msgstr ""
36+
37+
#: main.py:97
38+
msgid ""
39+
"Hello, {user_fist_name}!\n"
40+
"This is the example of multilanguage bot.\n"
41+
"Available commands:\n"
42+
"\n"
43+
"/lang - change your language\n"
44+
"/plural - pluralization example\n"
45+
"/menu - text menu example"
46+
msgstr ""
47+
48+
#: main.py:121
49+
msgid "Language has been changed"
50+
msgstr ""
51+
52+
#: main.py:130 main.py:150
53+
#, fuzzy
54+
msgid "You have {number} click"
55+
msgid_plural "You have {number} clicks"
56+
msgstr[0] ""
57+
msgstr[1] ""
58+
59+
#: main.py:135 main.py:155
60+
msgid ""
61+
"This is clicker.\n"
62+
"\n"
63+
msgstr ""
64+
65+
#: main.py:163
66+
msgid "This is ReplyKeyboardMarkup menu example in multilanguage bot."
67+
msgstr ""
68+
69+
#: main.py:203
70+
msgid "Seems you confused language"
71+
msgstr ""
72+
73+
#~ msgid ""
74+
#~ "Hello, {user_fist_name}!\n"
75+
#~ "This is the example of multilanguage bot.\n"
76+
#~ "Available commands:\n"
77+
#~ "\n"
78+
#~ "/lang - change your language\n"
79+
#~ "/plural - pluralization example"
80+
#~ msgstr ""
81+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Russian translations for PROJECT.
2+
# Copyright (C) 2022 ORGANIZATION
3+
# This file is distributed under the same license as the PROJECT project.
4+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2022.
5+
#
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: PROJECT VERSION\n"
9+
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
10+
"POT-Creation-Date: 2022-02-19 18:37+0500\n"
11+
"PO-Revision-Date: 2022-02-18 16:22+0500\n"
12+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13+
"Language: ru\n"
14+
"Language-Team: ru <LL@li.org>\n"
15+
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
16+
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
17+
"MIME-Version: 1.0\n"
18+
"Content-Type: text/plain; charset=utf-8\n"
19+
"Content-Transfer-Encoding: 8bit\n"
20+
"Generated-By: Babel 2.9.1\n"
21+
22+
#: keyboards.py:20
23+
msgid "click"
24+
msgstr "Клик"
25+
26+
#: keyboards.py:29
27+
msgid "My user id"
28+
msgstr "Мой user id"
29+
30+
#: keyboards.py:30
31+
msgid "My user name"
32+
msgstr "Мой user name"
33+
34+
#: keyboards.py:31
35+
msgid "My first name"
36+
msgstr "Мой first name"
37+
38+
#: main.py:97
39+
msgid ""
40+
"Hello, {user_fist_name}!\n"
41+
"This is the example of multilanguage bot.\n"
42+
"Available commands:\n"
43+
"\n"
44+
"/lang - change your language\n"
45+
"/plural - pluralization example\n"
46+
"/menu - text menu example"
47+
msgstr ""
48+
"Привет, {user_fist_name}!\n"
49+
"Это пример мультиязычного бота.\n"
50+
"Доступные команды:\n"
51+
"\n"
52+
"/lang - изменить язык\n"
53+
"/plural - пример плюрализации\n"
54+
"/menu - Пример текстового меню"
55+
56+
#: main.py:121
57+
msgid "Language has been changed"
58+
msgstr "Язык был сменён"
59+
60+
#: main.py:130 main.py:150
61+
msgid "You have {number} click"
62+
msgid_plural "You have {number} clicks"
63+
msgstr[0] "У вас {number} клик"
64+
msgstr[1] "У вас {number} клика"
65+
msgstr[2] "У вас {number} кликов"
66+
67+
#: main.py:135 main.py:155
68+
msgid ""
69+
"This is clicker.\n"
70+
"\n"
71+
msgstr ""
72+
"Это кликер.\n"
73+
"\n"
74+
75+
#: main.py:163
76+
msgid "This is ReplyKeyboardMarkup menu example in multilanguage bot."
77+
msgstr "Это пример ReplyKeyboardMarkup меню в мультиязычном боте."
78+
79+
#: main.py:203
80+
msgid "Seems you confused language"
81+
msgstr "Кажется, вы перепутали язык"
82+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Uzbek (Latin) translations for PROJECT.
2+
# Copyright (C) 2022 ORGANIZATION
3+
# This file is distributed under the same license as the PROJECT project.
4+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2022.
5+
#
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: PROJECT VERSION\n"
9+
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
10+
"POT-Creation-Date: 2022-02-19 18:37+0500\n"
11+
"PO-Revision-Date: 2022-02-18 16:22+0500\n"
12+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13+
"Language: uz_Latn\n"
14+
"Language-Team: uz_Latn <LL@li.org>\n"
15+
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=utf-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
"Generated-By: Babel 2.9.1\n"
20+
21+
#: keyboards.py:20
22+
msgid "click"
23+
msgstr "clik"
24+
25+
#: keyboards.py:29
26+
msgid "My user id"
27+
msgstr "Mani user id"
28+
29+
#: keyboards.py:30
30+
msgid "My user name"
31+
msgstr "Mani user name"
32+
33+
#: keyboards.py:31
34+
msgid "My first name"
35+
msgstr "Mani first name"
36+
37+
#: main.py:97
38+
msgid ""
39+
"Hello, {user_fist_name}!\n"
40+
"This is the example of multilanguage bot.\n"
41+
"Available commands:\n"
42+
"\n"
43+
"/lang - change your language\n"
44+
"/plural - pluralization example\n"
45+
"/menu - text menu example"
46+
msgstr ""
47+
"Salom, {user_fist_name}!\n"
48+
"Bu multilanguage bot misoli.\n"
49+
"Mavjud buyruqlar:\n"
50+
"\n"
51+
"/lang - tilni ozgartirish\n"
52+
"/plural - pluralizatsiya misoli\n"
53+
"/menu - text menu misoli"
54+
55+
#: main.py:121
56+
msgid "Language has been changed"
57+
msgstr "Til ozgartirildi"
58+
59+
#: main.py:130 main.py:150
60+
msgid "You have {number} click"
61+
msgid_plural "You have {number} clicks"
62+
msgstr[0] "Sizda {number}ta clik"
63+
msgstr[1] "Sizda {number}ta clik"
64+
65+
#: main.py:135 main.py:155
66+
msgid ""
67+
"This is clicker.\n"
68+
"\n"
69+
msgstr ""
70+
"Bu clicker.\n"
71+
"\n"
72+
73+
#: main.py:163
74+
msgid "This is ReplyKeyboardMarkup menu example in multilanguage bot."
75+
msgstr "Bu multilanguage bot da replykeyboardmarkup menyu misoli."
76+
77+
#: main.py:203
78+
msgid "Seems you confused language"
79+
msgstr "Tilni adashtirdiz"
80+

0 commit comments

Comments
 (0)