A
A
Andrew2021-02-01 13:42:08
Python
Andrew, 2021-02-01 13:42:08

How to make two languages ​​in discord.py?

Hello, there is an idea to make 2 bots in the discord and, moreover, I use cogs, is it possible to do this:
1. Create 2 folders, for example 1 rus and eng (command translations are different)
2. Make a command and use if / else to change them, for example, the command / lang ru - switches to work with a Russian folder
. I don't know if it's possible to do this at all, I just thought about it and the idea came up in the morning. I have a code, but for some reason it says that the command was not found, can you check and help refine it if possible? the code itself:

@client.command
@commands.has_permissions(administrator=True)
async def lang(ctx, mean):
    if mean == 'Ru':
        for filename in os.listdir('./cog_ru'):
            if filename.endswith('.py'):
                await client.load_extension(f'cog_ru.{filename[:-3]}')
        Russian = discord.Embed(name='Успех!', description='Язык изменён на Русский', colour=0x9900FF)
        await ctx.send(embed=Russian)
    else:
        for filename in os.listdir('./cog_en'):
            if filename.endswith('.py'):
                await client.load_extension(f'cog_en.{filename[:-3]}')
        English = discord.Embed(name='Success!', description='language changed to English', colour=0x9900FF)
        await ctx.send(embed=English)

It's in the main script.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dooMoob, 2021-02-01
@Mikyc

https://docs.python.org/3/library/gettext.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question