Skip to main content

A simple translation library for discord bots

Project description


A simple package to translate your discord bot to different languages

Key Features

  • Fast work and async support.
  • The only requirement is disnake.
  • next-translate-like file structure and syntax.


Python 3.8 or higher is required.

# Linux/macOS
python3 -m pip install -U distrans

# Windows
py -3 -m pip install -U distrans

Quick Example

Inline translation example

from distrans import TranslationInteractionBot 

bot = TranslationInteractionBot(
    languages=["en", "fr", "es", "uk"]

async def ping(inter, language: str):
    await inter.send(bot.get(

def main():"TOKEN")

if __name__ == "__main__":

Using async/await

translated = await bot.t(

Advanced usage

from distrans import TranslationInteractionBot

class MyTranslationInteractionBot(TranslationInteractionBot):
    def get_language(**kwargs):
        # kwargs - it's the same kwargs that you're passing to the
        # get() or t() method
        # like:
        # await bot.t("common:greeting", values={"name": "John"}, 
        # you will get an inter object in kwargs
        # Your code here
        return "en" # you can return language code based on current context
        # (guild, user, etc.)

#### locales/en/common.json

``` json
  "greeting": "Hello, $name!"


  "greeting": "Bonjour, $name!"


  "greeting": "Hola, $name!"


  "greeting": "Привіт, $name!"

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

distrans-1.0.1.tar.gz (5.2 kB view hashes)

Uploaded source

Built Distribution

distrans-1.0.1-py3-none-any.whl (6.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page