Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate user-facing messages from Russian to English for better reach #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

WEBAPP_HOST = "0.0.0.0"
WEBAPP_PORT = int(os.environ.get("PORT", 5000))
user_message = 'Пользователь'
admin_message = 'Админ'
user_message = 'User'
admin_message = 'Admin'


@dp.message_handler(commands='start')
Expand All @@ -23,17 +23,17 @@ async def cmd_start(message: types.Message):

markup.row(user_message, admin_message)

await message.answer('''Привет! 👋
await message.answer('''Hi! 👋

🤖 Я бот-магазин по подаже товаров любой категории.
🤖 I'm a marketplace bot to buy products from any category.

🛍️ Чтобы перейти в каталог и выбрать приглянувшиеся товары возпользуйтесь командой /menu.
🛍️ To access the catalog and see the products use /menu command.

💰 Пополнить счет можно через Яндекс.кассу, Сбербанк или Qiwi.
💰 For deposits you can use Yandex, Sber and Qivi .

Возникли вопросы? Не проблема! Команда /sos поможет связаться с админами, которые постараются как можно быстрее откликнуться.
Have questions? Not a problem! /sos command will help you to cantact the admins.

🤝 Заказать похожего бота? Свяжитесь с разработчиком <a href="https://t.me/NikolaySimakov">Nikolay Simakov</a>, он не кусается)))
🤝 Want to order a similar bot? Contact the developer <a href="https://t.me/NikolaySimakov">Nikolay Simakov</a>, he doesn't bite)))
''', reply_markup=markup)


Expand All @@ -44,7 +44,7 @@ async def user_mode(message: types.Message):
if cid in config.ADMINS:
config.ADMINS.remove(cid)

await message.answer('Включен пользовательский режим.', reply_markup=ReplyKeyboardRemove())
await message.answer('User mode is on.', reply_markup=ReplyKeyboardRemove())


@dp.message_handler(text=admin_message)
Expand All @@ -54,7 +54,7 @@ async def admin_mode(message: types.Message):
if cid not in config.ADMINS:
config.ADMINS.append(cid)

await message.answer('Включен админский режим.', reply_markup=ReplyKeyboardRemove())
await message.answer('Admin mode is on.', reply_markup=ReplyKeyboardRemove())


async def on_startup(dp):
Expand Down
142 changes: 142 additions & 0 deletions data/messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# messages.py

MESSAGES = {
'en': {
# General messages
'start': '''Hi! 👋

🤖 I'm a marketplace bot to buy products from any category.

🛍️ To access the catalog and see the products, use the /menu command.

💰 For deposits, you can use Yandex, Sber, and Qiwi.

❓ Have questions? Not a problem! Use the /sos command to contact the admins.

🤝 Want to order a similar bot? Contact the developer <a href="https://t.me/NikolaySimakov">Nikolay Simakov</a>, he doesn't bite)))''',

'user_mode_on': 'User mode is on.',
'admin_mode_on': 'Admin mode is on.',
'menu': 'Menu',

# User menu items
'catalog': '🛍️ Catalog',
'balance': '💰 Balance',
'cart': '🛒 Cart',
'delivery_status': '🚚 Order status',

# Admin menu items
'settings': '⚙️ Catalog settings',
'orders': '🚚 Orders',
'questions': '❓ Questions',

# Cart messages
'cart_empty': 'Your cart is empty.',
'cart_product_info': '<b>{title}</b>\n\n{body}\n\nPrice: {price}$.',
'enter_name': 'Enter your name.',
'enter_address': 'Specify your address.',
'change_name': 'Change the name from <b>{name}</b>?',
'change_address': 'Change the address from <b>{address}</b>?',
'order_confirmed': 'Your order is on its way 🚀\nName: <b>{name}</b>\nAddress: <b>{address}</b>',
'not_enough_funds': 'You don\'t have enough funds. Make a deposit!',

# Catalog messages
'choose_category': 'Choose the category to see the products:',

# SOS messages
'sos_prompt': 'What\'s the problem? Describe it in detail and the operator will respond soon.',
'sos_sent': 'Sent!',
'sos_limit_exceeded': 'The limit for questions is exceeded.',
'no_questions': 'No questions.',

# Delivery status messages
'no_active_orders': 'You don\'t have active orders.',
'order_status': 'Order <b>№{order_number}</b>{status}',
'status_in_warehouse': ' in a warehouse.',
'status_on_the_way': ' on its way!',
'status_arrived': ' arrived at the post office!',

# Confirmation messages
'make_sure_correct': 'Make sure everything is correct.',
'ready': 'Ready!',
'cancelled': 'Canceled!',
'sent': 'Sent!',
'no_such_choice': 'There is no such choice.',

# Keyboard buttons
'back': '👈 Back',
'confirm_order': '✅ Confirm the order',
'all_correct': '✅ All is correct',
'cancel': '🚫 Cancel',
'answer': 'Answer',
},
'ru': {
# General messages
'start': '''Привет! 👋

🤖 Я бот-магазин для покупки товаров из любой категории.

🛍️ Чтобы получить доступ к каталогу и посмотреть товары, используйте команду /menu.

💰 Для пополнения можно использовать Яндекс, Сбер и Киви.

❓ Есть вопросы? Не проблема! Команда /sos поможет вам связаться с администраторами.

🤝 Хотите заказать похожего бота? Свяжитесь с разработчиком <a href="https://t.me/NikolaySimakov">Николаем Симаковым</a>, он не кусается)))''',

'user_mode_on': 'Режим пользователя включен.',
'admin_mode_on': 'Режим администратора включен.',
'menu': 'Меню',

# User menu items
'catalog': '🛍️ Каталог',
'balance': '💰 Баланс',
'cart': '🛒 Корзина',
'delivery_status': '🚚 Статус заказа',

# Admin menu items
'settings': '⚙️ Настройки каталога',
'orders': '🚚 Заказы',
'questions': '❓ Вопросы',

# Cart messages
'cart_empty': 'Ваша корзина пуста.',
'cart_product_info': '<b>{title}</b>\n\n{body}\n\nЦена: {price}₽.',
'enter_name': 'Введите ваше имя.',
'enter_address': 'Укажите ваш адрес.',
'change_name': 'Изменить имя с <b>{name}</b>?',
'change_address': 'Изменить адрес с <b>{address}</b>?',
'order_confirmed': 'Ваш заказ в пути 🚀\nИмя: <b>{name}</b>\nАдрес: <b>{address}</b>',
'not_enough_funds': 'У вас недостаточно средств. Пополните баланс!',

# Catalog messages
'choose_category': 'Выберите категорию, чтобы увидеть товары:',

# SOS messages
'sos_prompt': 'В чём проблема? Опишите её подробно, и оператор скоро ответит.',
'sos_sent': 'Отправлено!',
'sos_limit_exceeded': 'Превышен лимит вопросов.',
'no_questions': 'Нет вопросов.',

# Delivery status messages
'no_active_orders': 'У вас нет активных заказов.',
'order_status': 'Заказ <b>№{order_number}</b>{status}',
'status_in_warehouse': ' на складе.',
'status_on_the_way': ' в пути!',
'status_arrived': ' прибыл на почту!',

# Confirmation messages
'make_sure_correct': 'Убедитесь, что всё правильно.',
'ready': 'Готово!',
'cancelled': 'Отменено!',
'sent': 'Отправлено!',
'no_such_choice': 'Такого выбора нет.',

# Keyboard buttons
'back': '👈 Назад',
'confirm_order': '✅ Подтвердить заказ',
'all_correct': '✅ Всё верно',
'cancel': '🚫 Отмена',
'answer': 'Ответить',
}
}
50 changes: 25 additions & 25 deletions handlers/admin/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
category_cb = CallbackData('category', 'id', 'action')
product_cb = CallbackData('product', 'id', 'action')

add_product = '➕ Добавить товар'
delete_category = '🗑️ Удалить категорию'
add_product = '➕ Add product'
delete_category = '🗑️ Delete a category'


@dp.message_handler(IsAdmin(), text=settings)
Expand All @@ -29,9 +29,9 @@ async def process_settings(message: Message):
title, callback_data=category_cb.new(id=idx, action='view')))

markup.add(InlineKeyboardButton(
'+ Добавить категорию', callback_data='add_category'))
'+ Add a category', callback_data='add_category'))

await message.answer('Настройка категорий:', reply_markup=markup)
await message.answer('Category settings:', reply_markup=markup)


@dp.callback_query_handler(IsAdmin(), category_cb.filter(action='view'))
Expand All @@ -44,7 +44,7 @@ async def category_callback_handler(query: CallbackQuery, callback_data: dict, s
(category_idx,))

await query.message.delete()
await query.answer('Все добавленные товары в эту категорию.')
await query.answer('All products added to the category.')
await state.update_data(category_index=category_idx)
await show_products(query.message, products, category_idx)

Expand All @@ -55,7 +55,7 @@ async def category_callback_handler(query: CallbackQuery, callback_data: dict, s
@dp.callback_query_handler(IsAdmin(), text='add_category')
async def add_category_callback_handler(query: CallbackQuery):
await query.message.delete()
await query.message.answer('Название категории?')
await query.message.answer('What\'s the category\'s name?')
await CategoryState.title.set()


Expand Down Expand Up @@ -83,7 +83,7 @@ async def delete_category_handler(message: Message, state: FSMContext):
'DELETE FROM products WHERE tag IN (SELECT title FROM categories WHERE idx=?)', (idx,))
db.query('DELETE FROM categories WHERE idx=?', (idx,))

await message.answer('Готово!', reply_markup=ReplyKeyboardRemove())
await message.answer('All ready!', reply_markup=ReplyKeyboardRemove())
await process_settings(message)


Expand All @@ -98,13 +98,13 @@ async def process_add_product(message: Message):
markup = ReplyKeyboardMarkup(resize_keyboard=True)
markup.add(cancel_message)

await message.answer('Название?', reply_markup=markup)
await message.answer('Name?', reply_markup=markup)


@dp.message_handler(IsAdmin(), text=cancel_message, state=ProductState.title)
async def process_cancel(message: Message, state: FSMContext):

await message.answer('Ок, отменено!', reply_markup=ReplyKeyboardRemove())
await message.answer('Okay, canceled!', reply_markup=ReplyKeyboardRemove())
await state.finish()

await process_settings(message)
Expand All @@ -122,7 +122,7 @@ async def process_title(message: Message, state: FSMContext):
data['title'] = message.text

await ProductState.next()
await message.answer('Описание?', reply_markup=back_markup())
await message.answer('Description?', reply_markup=back_markup())


@dp.message_handler(IsAdmin(), text=back_message, state=ProductState.body)
Expand All @@ -132,7 +132,7 @@ async def process_body_back(message: Message, state: FSMContext):

async with state.proxy() as data:

await message.answer(f"Изменить название с <b>{data['title']}</b>?", reply_markup=back_markup())
await message.answer(f"Change the name from <b>{data['title']}</b>?", reply_markup=back_markup())


@dp.message_handler(IsAdmin(), state=ProductState.body)
Expand All @@ -142,7 +142,7 @@ async def process_body(message: Message, state: FSMContext):
data['body'] = message.text

await ProductState.next()
await message.answer('Фото?', reply_markup=back_markup())
await message.answer('Photo?', reply_markup=back_markup())


@dp.message_handler(IsAdmin(), content_types=ContentType.PHOTO, state=ProductState.image)
Expand All @@ -156,7 +156,7 @@ async def process_image_photo(message: Message, state: FSMContext):
data['image'] = downloaded_file

await ProductState.next()
await message.answer('Цена?', reply_markup=back_markup())
await message.answer('Price?', reply_markup=back_markup())


@dp.message_handler(IsAdmin(), content_types=ContentType.TEXT, state=ProductState.image)
Expand All @@ -168,11 +168,11 @@ async def process_image_url(message: Message, state: FSMContext):

async with state.proxy() as data:

await message.answer(f"Изменить описание с <b>{data['body']}</b>?", reply_markup=back_markup())
await message.answer(f"Change the description from <b>{data['body']}</b>?", reply_markup=back_markup())

else:

await message.answer('Вам нужно прислать фото товара.')
await message.answer('You need to send the product\'s photo.')


@dp.message_handler(IsAdmin(), lambda message: not message.text.isdigit(), state=ProductState.price)
Expand All @@ -184,11 +184,11 @@ async def process_price_invalid(message: Message, state: FSMContext):

async with state.proxy() as data:

await message.answer("Другое изображение?", reply_markup=back_markup())
await message.answer("Different image?", reply_markup=back_markup())

else:

await message.answer('Укажите цену в виде числа!')
await message.answer('The price should be a number!')


@dp.message_handler(IsAdmin(), lambda message: message.text.isdigit(), state=ProductState.price)
Expand All @@ -203,7 +203,7 @@ async def process_price(message: Message, state: FSMContext):
price = data['price']

await ProductState.next()
text = f'<b>{title}</b>\n\n{body}\n\nЦена: {price} рублей.'
text = f'<b>{title}</b>\n\n{body}\n\nPrice: {price} dollars.'

markup = check_markup()

Expand All @@ -214,7 +214,7 @@ async def process_price(message: Message, state: FSMContext):

@dp.message_handler(IsAdmin(), lambda message: message.text not in [back_message, all_right_message], state=ProductState.confirm)
async def process_confirm_invalid(message: Message, state: FSMContext):
await message.answer('Такого варианта не было.')
await message.answer('There is no such choice.')


@dp.message_handler(IsAdmin(), text=back_message, state=ProductState.confirm)
Expand All @@ -224,7 +224,7 @@ async def process_confirm_back(message: Message, state: FSMContext):

async with state.proxy() as data:

await message.answer(f"Изменить цену с <b>{data['price']}</b>?", reply_markup=back_markup())
await message.answer(f"Change the price from <b>{data['price']}</b>?", reply_markup=back_markup())


@dp.message_handler(IsAdmin(), text=all_right_message, state=ProductState.confirm)
Expand All @@ -246,7 +246,7 @@ async def process_confirm(message: Message, state: FSMContext):
(idx, title, body, image, int(price), tag))

await state.finish()
await message.answer('Готово!', reply_markup=ReplyKeyboardRemove())
await message.answer('Ready!', reply_markup=ReplyKeyboardRemove())
await process_settings(message)


Expand All @@ -258,7 +258,7 @@ async def delete_product_callback_handler(query: CallbackQuery, callback_data: d

product_idx = callback_data['id']
db.query('DELETE FROM products WHERE idx=?', (product_idx,))
await query.answer('Удалено!')
await query.answer('Deleted!')
await query.message.delete()


Expand All @@ -268,11 +268,11 @@ async def show_products(m, products, category_idx):

for idx, title, body, image, price, tag in products:

text = f'<b>{title}</b>\n\n{body}\n\nЦена: {price} рублей.'
text = f'<b>{title}</b>\n\n{body}\n\nPrice: {price} dollars.'

markup = InlineKeyboardMarkup()
markup.add(InlineKeyboardButton(
'🗑️ Удалить', callback_data=product_cb.new(id=idx, action='delete')))
'🗑️ Delete', callback_data=product_cb.new(id=idx, action='delete')))

await m.answer_photo(photo=image,
caption=text,
Expand All @@ -282,4 +282,4 @@ async def show_products(m, products, category_idx):
markup.add(add_product)
markup.add(delete_category)

await m.answer('Хотите что-нибудь добавить или удалить?', reply_markup=markup)
await m.answer('Want to delete or add something?', reply_markup=markup)
Loading