Files
Ultroid-fork/assistant/localization.py
Devesh Pal 0afa1ade15 AI wrapper and twitter plugin (#465)
* Ultroid 2025

Co-authored-by: New-dev0 <New-dev0@users.noreply.github.com>
Co-authored-by: Amit Sharma <buddhhu@users.noreply.github.com>
Co-authored-by: TechiError <techierror@users.noreply.github.com>
Co-authored-by: Aditya <me@xditya.me>
Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com>
Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com>
Co-authored-by: sppidy <sppidy@users.noreply.github.com>
2025-02-21 23:05:48 +05:30

48 lines
1.3 KiB
Python

# Ultroid - UserBot
# Copyright (C) 2021-2025 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
import re
from . import (
Button,
ULTConfig,
callback,
get_back_button,
get_languages,
get_string,
udB,
)
@callback("lang", owner=True)
async def setlang(event):
languages = get_languages()
tultd = [
Button.inline(
f"{languages[ult]['natively']} [{ult.lower()}]",
data=f"set_{ult}",
)
for ult in languages
]
buttons = list(zip(tultd[::2], tultd[1::2]))
if len(tultd) % 2 == 1:
buttons.append((tultd[-1],))
buttons.append([Button.inline("« Back", data="mainmenu")])
await event.edit(get_string("ast_4"), buttons=buttons)
@callback(re.compile(b"set_(.*)"), owner=True)
async def settt(event):
lang = event.data_match.group(1).decode("UTF-8")
languages = get_languages()
ULTConfig.lang = lang
udB.del_key("language") if lang == "en" else udB.set_key("language", lang)
await event.edit(
f"Your language has been set to {languages[lang]['natively']} [{lang}].",
buttons=get_back_button("lang"),
)