Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.3 KB

framework_i18n.rst

File metadata and controls

54 lines (39 loc) · 1.3 KB

Internationalization Framework

Basic Usage

from redbot.core import commands
from redbot.core.i18n import Translator, cog_i18n

_ = Translator("ExampleCog", __file__)

@cog_i18n(_)
class ExampleCog:
    """description"""

    @commands.command()
    async def mycom(self, ctx):
        """command description"""
        await ctx.send(_("This is a test command"))

Tutorial

After making your cog, generate a messages.pot file

We recommend using redgettext - a modified version of pygettext for Red. You can install redgettext by running pip install redgettext in a command prompt.

To generate the messages.pot file, you will now need to run python -m redgettext -c [path_to_cog] This file will contain all strings to be translated, including docstrings. (For advanced usage check python -m redgettext -h)

You can now use a tool like poedit to translate the strings in your messages.pot file.

API Reference

.. automodule:: redbot.core.i18n
    :members:
    :special-members: __call__