I have a Bot which im trying to make multilingual. Now when i try to run the command for the bot i get
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 7: ordinal not in range(128)
I tried removing the Emoji in the .po file and convert it back to .mo and then it worked. so it seems that is the problem of that all.
Example: My german .po file:
msgid "PING_TITLE"
msgstr "**PING **"
msgid "PING_DESCRIPTION"
msgstr "Meine Latenz ist **{ping}ms**!"
my Command:
import gettext
import io
import json
from datetime import datetime
import discord
from discord import app_commands
from discord.ext import commands
class Ping(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client
with open("data/languages.json", encoding="utf-8") as f:
guild_languages = json.load(f)
lang = guild_languages.get(str(interaction.guild.id), "en")
trans = gettext.translation(
domain="ping", localedir="locales", languages=[lang], fallback=True
)
embed = discord.Embed(
title=str(trans.gettext("PING_TITLE")),
description=str(trans.gettext("PING_DESCRIPTION").format(ping=ping)),
color=0x1365EA,
timestamp=datetime.now(),
)
embed.set_author(
name=f"{interaction.user}", icon_url=f"{interaction.user.avatar.url}"
)
await interaction.response.send_message(embed=embed)
async def setup(client):
await client.add_cog(Ping(client))
Like i said, without the Emoji everything works fine! But i want the Emoji to be part of the Command.
Reminder: I also have a .mo file.