Additionally, users can reply to any message with "!translate" to have the entire message translated. As of now, users can translate Japanese or English phrases by entering: "!translate " into the Discord chat. The bot is currently capable of Japanese to English translation, and English to Japanese translation (in most cases - see wiki for details). In this case, the message that the command replied to will be used as the source text for the translation. To do this, I added a condition to the translation function to check if the message containing the "!translate" command was empty (other than the command). See wiki and/or "Known Issues" below)Īdditionally, I implemented a feature allowing users to reply to a message with the translation command to have the entire message translated. Japanese characters cannot be encoded with ASCII, so messages containing non-ASCII characters are sent to DeepL as Japanese to be translated into English (known issue: emojis. I later iterated upon the !translate function to have it automatically detect the source language by checking if the source text can be encoded with ASCII. Finally, I used a Discord.py function to have the bot reply the translated text to the user who used the "!translate" command. Using the python request module, I set up a function to send the text from the translate command, along with the source & target languages, to the DeepL translation API, which would return the translated text. I then implemented a translation command, which would parse any text following "!translate" at the beginning of a chat message. I started by creating a simple Discord bot using the Discord.py library, which made it quick to set up a bot to monitor chat messages, waiting for a command. My hope is that by giving members access to a convenient translation tool, beginners will feel less overwhelmed when peering into a chat room full of higher-level Japanese speakers, and more confident to join in the conversation. I thought back on these times as I wondered why the "Japanese-only" chat room was so inactive in a Japanese learning Discord server I'm in, and decided to make a bot to help make the chat more accessible to beginners. I didn't want to pester people by asking them what their sentences meant, but I also didn't want to copy+paste dozens of messages into Google Translate so I could follow the conversation. As someone who studied Japanese for 4 years, I remember being a beginner in the language, shying away from participating in "Japanese-only" chats, since there were many words I didn't understand. I created this bot for use on a Japanese learning Discord server. See wiki for details & additional feature plans/ideas. This functionality allows users to quickly look up words they don't know how to say in Japanese, translate words they don't understand into English, or translate entire phrases between the two languages - all without having to switch back & forth between a dictionary website and Discord. (The abbreviation "!tl" can also be used, in place of "!translate".) Users can enter "!translate " into the Discord chat to have their text translated, or reply to a message with "!translate" to have the message they replied to translated. This bot translates Discord chat messages from Japanese to English (and vice versa). Discord Bot with Translation FunctionalityĬreated using the Discord.py python library for Discord chat integration, and DeepL's translation API.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |