Skip to content

Locales Usage

In Seyfert the possibility to take your bot to multiple locales is quite simple.

How to use the locales

Seyfert provides a way to use the locales in your bot. The way to do it is quite simple.

There are some decorators that can be used to use the locales in your code.

Using @LocalesT decorator

You can automatically translate all command content using the @LocalesT decorator. This decorator will get all the locales that you have defined as DefaultLocale.

import {
class Command
Command
,
function LocalesT(name?: FlatObjectKeys<DefaultLocale>, description?: FlatObjectKeys<DefaultLocale>): <T extends {
new (...args: any[]): object;
}>(target: T) => {
new (...args: any[]): {
__t: {
name: undefined;
description: undefined;
};
};
} & T
LocalesT
} from 'seyfert';
@
function LocalesT(name?: FlatObjectKeys<DefaultLocale>, description?: FlatObjectKeys<DefaultLocale>): <T extends {
new (...args: any[]): object;
}>(target: T) => {
new (...args: any[]): {
__t: {
name: undefined;
description: undefined;
};
};
} & T
LocalesT
('my-command .name', 'my-command.description')
my-command.name
my-command.description
class
class MyCommand
MyCommand
extends
class Command
Command
{}

Using @GroupsT decorator

This decorator has a special structure and can be a bit confusing.

The decorator has the following structure:

@GroupsT({
// This is the name of the group... Created in the parent command
groupName: {
// This is obligatory! Is the default name of the group.
defaultDescription,
// This is optional! Is the localized name of the group.
name,
}
})

Once you understand how it works, you can use it as follows:

src/commands/supremacy.ts
import { Command, LocalesT } from 'seyfert';
@GroupsT({
supremacy: {
defaultDescription: "Ganyu Supremacy.",
name: "foo.bar",
}
})
export default class SupremacyCommand extends Command { }

Using locales object property

Seyfert provides a special property to add localizations in command options.

src/commands/supremacy.ts
import { createStringOption } from 'seyfert';
const options = {
supremacy: createStringOption({
description: "Enter a supremacy name.",
required: true,
// If you don't want to add a command localized name or description!
// Just remove the property from the object
locales: {
name: "hello",
description: "foo.bar",
}
})
}