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

This decorator will get all the locales that you have defined as DefaultLocale.

src/commands/supremacy.ts
import { Command, Declare, LocalesT } from 'seyfert';
@Declare({
name: 'supremacy',
description: 'Ganyu Supremacy.'
})
// You can also pass 'undefined'
// if you don't want to add a command localized name or description!
// Like this: @LocalesT(undefined 'some.command.description')
@LocalesT('hello', 'foo.bar')
export default class SupremacyCommand extends 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",
}
})
}