Files
Ultroid-fork/assistant/localization.py
Anonymous 4e8b0543ce Ultroid 0.0.5 - 06/04/21
Co-authored-by: AndrewLaneX <AndrewLaneX@users.noreply.github.com>
Co-authored-by: Aditya <me@xditya.me>
Co-authored-by: Danish <danish@ultroid.tech>
Co-authored-by: buddhhu <buddhuu0@users.noreply.github.com>
Co-authored-by: sppidy <sppidy@users.noreply.github.com>
Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com>
Co-authored-by: divkix <divkix@users.noreply.github.com>
Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com>
Co-authored-by: Programming Error <error@notavailable.live>
Co-authored-by: New-dev0 <New-dev0@notavailable.live>
2021-04-07 07:32:24 +05:30

40 lines
1.1 KiB
Python

# Ultroid - UserBot
# Copyright (C) 2020 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 *
@callback("lang")
@owner
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("List Of Available Languages.", buttons=buttons)
@callback(re.compile(b"set_(.*)"))
@owner
async def settt(event):
lang = event.data_match.group(1).decode("UTF-8")
languages = get_languages()
udB.set("language", f"{lang}")
await event.edit(
f"Your language has been set to {languages[lang]['natively']} [{lang}].",
)