Skip to content

Commit

Permalink
docs: update readme with latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Damego authored Dec 28, 2022
1 parent e1548a5 commit 39148a3
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,16 @@ client = interactions.Client(...)

# Load an i18n extension
i18n = setup(client)
# Load a folder with locales
# Also you can load json file only
i18n.load("./locales/")

... # your cool commands
... # your cool commands and cogs loads

# Load a folder with localization
i18n.load("./locales/de")
client.start()
```

### Usage in Extension

Absolutely same as in the main file

```py
from interactions import Extension
from interactions.ext.i18n import Localization
Expand All @@ -49,7 +46,7 @@ class MyExt(Extension):
2. Create a `[CODE]` folder with found code and put it in the folder with locales.
3. Create two files. First is `commands.json` for your commands and second is `custom.json` for anything you want

## Getting and setting keys
## Example

Let's create a command with name `info` with some subcommands

Expand All @@ -69,7 +66,7 @@ async def user(ctx: interactions.CommandContext, member: interactions.Member):
await ctx.send(loc)
```

## Structure of json files
### Structure of json files

`locales/de/commands.json`

Expand Down Expand Up @@ -127,12 +124,12 @@ from interactions.ext.i18n import setup

bot = Client(...)
i18n = setup(bot)
i18n.load("./locales/")
# i18n.load("./locales/de")

... # your cool commands

# call this function in the end of main file
i18n.generate_files(Locale.GERMAN, "./locales/") # Second argument is optional. It needs if you want to generate files in different folder
i18n.generate_files(Locale.GERMAN, "./locales/")
# bot.start() # comment line where starts your bot

```

0 comments on commit 39148a3

Please sign in to comment.