Skip to content

Commit

Permalink
chore: add docs for localization
Browse files Browse the repository at this point in the history
  • Loading branch information
jab416171 committed Mar 22, 2022
1 parent 15ff75f commit 5e05b2c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 5 deletions.
55 changes: 55 additions & 0 deletions docs/Localization/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Localizations
---

Localizations are a way to make your bot more accessible to your users. You can localize the command
name, the names of any arguments, and any text that is displayed to the user.

## Syntax
```python
@commands.slash_command(
name="ping",
name_localizations={
"en-GB": "British_Ping"
},
description="Ping the bot",
description_localizations={
"en-GB": "British ping the bot"
},
options=[
Option(
name="Example",
name_localizations={
"en-GB": "British Example"
},
description="Example option that does nothing",
description_localizations={
"en-GB": "British example option that does nothing"
}
)
]
)
async def ping(ctx, example):
responses = {"en-US": "Pong!",
"en-GB": "British Pong!"}
await ctx.respond(responses.get(ctx.interaction.locale, responses['en-US']))

@commands.slash_command(
name="ping2",
name_localizations={
"en-GB": "British_Ping"
},
description="Ping the bot",
description_localizations={
"en-GB": "British ping the bot"
}
)
async def ping2(ctx, example: Option("Example", name_localizations={"en-GB": "British Example"}, description="Example option that does nothing", description_localizations={"en-GB": "British example option that does nothing"})):
responses = {"en-US": "Pong2!",
"en-GB": "British Pong2!"}
await ctx.respond(responses.get(ctx.interaction.locale, responses['en-US']))

```


- [`Locales`](https://discord.com/developers/docs/reference#locales) - List of valid locales recognized by Discord
17 changes: 12 additions & 5 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ const sidebars = {
label: "Interactions",
link: { type: "doc", id: "Interactions/index" },
items: [
"Interactions/buttons",
"Interactions/dropdowns",
"Interactions/slash-commands",
"Interactions/context-menus",
"Interactions/modal-dialogs"
{
type: "category",
label: "Application Commands",
items: [
"Interactions/slash-commands",
"Interactions/context-menus",
"Interactions/buttons",
"Interactions/dropdowns",
"Interactions/modal-dialogs"
]
},
"Localization/index"
],
},
{
Expand Down

0 comments on commit 5e05b2c

Please sign in to comment.