@gcommands/plugin-language
v1.0.5
Published
Easy to use i18n system in gcommands
Downloads
7
Maintainers
Readme
GCommands Plugin More Events
Official plugin for GCommands
Installation
Install with npm / yarn / pnpm:
npm install @gcommands/plugin-language
yarn add @gcommands/plugin-language
pnpm add @gcommands/plugin-language
TIP
You can change default gcommands responses
NOT_FOUND
ERROR
COOLDOWN
-> {duration} {name}ARGUMENT_REQUIRED
-> {user} {name} {type}ARGUMENT_TIME
-> {user}https://github.com/Garlic-Team/gcommands/blob/next/src/responses.json
// index.js
const { Plugins } = require('gcommands');
const { readFileSync } = require('fs');
require('@gcommands/plugin-language').default({
defaultLanguage: 'en-GB',
languageText: JSON.parse(readFileSync(`${__dirname}/responses.json`, 'utf-8'))
});
Plugins.search(__dirname);
// responses.json
{
"en-GB": {
"hello": "Hello!",
"ERROR": "Broken :(",
"COOLDOWN": "You need wait {duration} for {name}",
"NOT_FOUND": "Undefined command"
},
"en-US": {
"hello": "Hello!",
"ERROR": "Broken :(",
"COOLDOWN": "You need wait {duration} for {name}",
"NOT_FOUND": "Undefined command"
},
"da": {
"hello": "Hej"
},
"de": {
"hello": "Hallo"
},
"es-ES": {
},
"fr": {
},
"hr": {
},
"it": {
},
"lt": {
},
"hu": {
},
"nl": {
},
"no": {
},
"pl": {
},
"pt-BR": {
},
"ro": {
},
"fi": {
},
"sv-SE": {
},
"vi": {
},
"tr": {
},
"cs": {
},
"el": {
},
"bg": {
},
"ru": {
},
"uk": {
},
"hi": {
},
"th": {
},
"zh-CN": {
},
"ja": {
},
"zh-TW": {
},
"ko": {
}
}
// ^
// command.js
const { Command } = require('gcommands');
const { LanguageManager } = require('@gcommands/plugin-language');
new Command({
run: (ctx) => {
const hello = LanguageManager.__(ctx.interaction, 'hello');
ctx.reply({
content: hello
});
}
})