Esempio n. 1
0
async def locale_button(client, query):
    lang_match = re.findall(r"en-US|hi", query.data)
    if lang_match:
        if lang_match[0]:
            switch_to_locale(Owner, lang_match[0])
            await query.answer(text=tld('language_switch_success_pm').format(
                list_locales[lang_match[0]]))
        else:
            await query.answer(text="Error!", show_alert=True)
    try:
        LANGUAGE = prev_locale(Owner)
        locale = LANGUAGE.locale_name
        curr_lang = list_locales[locale]
    except Exception:
        curr_lang = "English (US)"

    text = tld("language_select_language")
    text += tld("language_current_locale").format(curr_lang)
    buttons = [[
        InlineKeyboardButton("English (US) 🇺🇸",
                             callback_data="set_lang_en-US"),
        InlineKeyboardButton("Hindi 🇮🇳", callback_data="set_lang_hi")
    ]]
    await client.edit_message_text(chat_id=Owner,
                                   message_id=query.message.message_id,
                                   text=text,
                                   parse_mode='markdown',
                                   reply_markup=InlineKeyboardMarkup(buttons))
    await client.answer_callback_query(query.id)
Esempio n. 2
0
async def locale_button(_, query):
    lang_match = re.findall(
        r"en-US|hi|he|id|fa|el|dv|es|ja|de|ta|pt-br|ar",
        query.data
    )
    if lang_match:
        if lang_match[0]:
            switch_to_locale(Owner, lang_match[0])
            await query.answer(
                text=tld("language_switch_success_pm").format(
                    list_locales[lang_match[0]]
                ),
                show_alert=True,
            )
        else:
            await query.answer(text="Error!", show_alert=True)
    try:
        LANGUAGE = prev_locale(Owner)
        locale = LANGUAGE.locale_name
        curr_lang = list_locales[locale]
    except Exception:
        curr_lang = "English (US)"

    text = tld("language_select_language")
    text += tld("language_current_locale").format(curr_lang)
    buttons = [
        [
            InlineKeyboardButton("🇺🇸", callback_data="set_lang_en-US"),
            InlineKeyboardButton("🇮🇳", callback_data="set_lang_hi"),
            InlineKeyboardButton("🇮🇱", callback_data="set_lang_he"),
            InlineKeyboardButton("🇮🇩", callback_data="set_lang_id"),
            InlineKeyboardButton("🇮🇷", callback_data="set_lang_fa"),
        ],
        [
            InlineKeyboardButton("🇯🇵", callback_data="set_lang_ja"),
            InlineKeyboardButton("🇬🇷", callback_data="set_lang_el"),
            InlineKeyboardButton("🇲🇻", callback_data="set_lang_dv"),
            InlineKeyboardButton("🇪🇸", callback_data="set_lang_es"),
            InlineKeyboardButton("🇩🇪", callback_data="set_lang_de"),
        ],
        [
            InlineKeyboardButton("🇱🇰", callback_data="set_lang_ta"),
            InlineKeyboardButton("🇧🇷", callback_data="set_lang_pt-br"),
            InlineKeyboardButton("🇸🇦", callback_data="set_lang_pt-ar"),
        ],
        [InlineKeyboardButton("◀️", callback_data="language_back")],
    ]
    try:
        await query.message.edit(
            text,
            parse_mode="markdown",
            reply_markup=InlineKeyboardMarkup(buttons),
        )
        await query.answer()
    except errors.exceptions.bad_request_400.MessageNotModified:
        return
Esempio n. 3
0
async def locale_button(client, query):
    lang_match = re.findall(r"en-US|hi|he|id|fa|el|dv|es|ja", query.data)
    if lang_match:
        if lang_match[0]:
            switch_to_locale(Owner, lang_match[0])
            await query.answer(text=tld("language_switch_success_pm").format(
                list_locales[lang_match[0]]))
        else:
            await query.answer(text="Error!", show_alert=True)
    try:
        LANGUAGE = prev_locale(Owner)
        locale = LANGUAGE.locale_name
        curr_lang = list_locales[locale]
    except Exception:
        curr_lang = "English (US)"

    text = tld("language_select_language")
    text += tld("language_current_locale").format(curr_lang)
    buttons = [
        [
            InlineKeyboardButton("🇺🇸 English (US)",
                                 callback_data="set_lang_en-US"),
            InlineKeyboardButton("🇮🇳 हिंदी", callback_data="set_lang_hi"),
        ],
        [
            InlineKeyboardButton("🇮🇱 עברית", callback_data="set_lang_he"),
            InlineKeyboardButton("🇮🇩 bahasa Indonesia",
                                 callback_data="set_lang_id"),
        ],
        [
            InlineKeyboardButton("🇮🇷 فارسی", callback_data="set_lang_fa"),
            InlineKeyboardButton("🇯🇵 日本人", callback_data="set_lang_ja"),
        ],
        [
            InlineKeyboardButton("🇬🇷 Ελληνικά", callback_data="set_lang_el"),
            InlineKeyboardButton("🇲🇻 ދިވެހި", callback_data="set_lang_dv"),
        ],
        [InlineKeyboardButton("🇪🇸 Espanol", callback_data="set_lang_es")],
    ]
    await client.edit_message_text(
        chat_id=Owner,
        message_id=query.message.message_id,
        text=text,
        parse_mode="markdown",
        reply_markup=InlineKeyboardMarkup(buttons),
    )
    await client.answer_callback_query(query.id)