This repository has been archived on 2025-01-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2023-05-03 19:53:01 +03:00
|
|
|
from bot import db
|
2023-05-15 23:22:19 +03:00
|
|
|
from discord.app_commands import TranslationContextLocation as trans_loc
|
|
|
|
|
from discord import app_commands
|
2023-05-03 19:53:01 +03:00
|
|
|
|
|
|
|
|
def region_to_str(region):
|
|
|
|
|
# if region == discord.VoiceRegion.russia:
|
|
|
|
|
# return "RU"
|
|
|
|
|
# elif region == discord.VoiceRegion.japan:
|
|
|
|
|
# return "JP"
|
|
|
|
|
# else:
|
|
|
|
|
return "RU"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def translate(string, region):
|
|
|
|
|
if string is not None:
|
|
|
|
|
if string.startswith("$"):
|
|
|
|
|
string = string.replace("$", "")
|
|
|
|
|
string = string.split("_")
|
|
|
|
|
|
|
|
|
|
print(region)
|
|
|
|
|
|
|
|
|
|
pack = db.strings.find_one({"lang": region})
|
|
|
|
|
print(pack)
|
|
|
|
|
|
|
|
|
|
for i in string:
|
|
|
|
|
pack = pack[i]
|
|
|
|
|
print(pack)
|
|
|
|
|
|
|
|
|
|
return pack
|
|
|
|
|
else:
|
|
|
|
|
return string
|
2023-05-15 23:22:19 +03:00
|
|
|
|
2023-05-16 16:55:25 +03:00
|
|
|
async def get_text(inter, string, location = None):
|
2023-05-15 23:22:19 +03:00
|
|
|
data = await inter.translate(
|
2023-05-16 12:31:43 +03:00
|
|
|
string=app_commands.locale_str(string),
|
2023-05-15 23:22:19 +03:00
|
|
|
locale=inter.locale,
|
2023-05-16 12:31:43 +03:00
|
|
|
data=location
|
2023-05-15 23:22:19 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return data or string
|
|
|
|
|
|