Skip to content

Commit 54168ba

Browse files
committed
feat: i18n wip
1 parent d8c9bee commit 54168ba

24 files changed

Lines changed: 772 additions & 88 deletions

File tree

apps/test-bot/commandkit.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig } from 'commandkit';
22
import { legacy } from '@commandkit/legacy';
3+
import { i18n } from '@commandkit/i18n';
34

45
export default defineConfig({
5-
plugins: [legacy({ skipBuiltInValidations: true })],
6+
plugins: [i18n(), legacy({ skipBuiltInValidations: true })],
67
});

apps/test-bot/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"commandkit": "workspace:*",
1313
"@commandkit/devtools": "workspace:*",
14+
"@commandkit/i18n": "workspace:*",
1415
"@commandkit/legacy": "workspace:*",
1516
"discord.js": "^14.17.3",
1617
"dotenv": "^16.4.7"

apps/test-bot/src/app/commands/(general)/avatar.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ export const command = {
2020
export async function userContextMenu(ctx: UserContextMenuCommandContext) {
2121
const target = ctx.interaction.targetUser;
2222

23+
const { t } = ctx.locale();
24+
2325
await ctx.interaction.reply({
2426
embeds: [
2527
{
26-
title: `${target.username}'s Avatar`,
28+
title: t('avatar', {
29+
user: target.username,
30+
}),
2731
image: {
2832
url: target.displayAvatarURL({ size: 2048 }),
2933
},
@@ -35,11 +39,14 @@ export async function userContextMenu(ctx: UserContextMenuCommandContext) {
3539

3640
export async function chatInput(ctx: SlashCommandContext) {
3741
const user = ctx.options.getUser('user') ?? ctx.interaction.user;
42+
const { t } = ctx.locale();
3843

3944
await ctx.interaction.reply({
4045
embeds: [
4146
{
42-
title: `${user.username}'s Avatar`,
47+
title: t('avatar', {
48+
user: user.username,
49+
}),
4350
image: {
4451
url: user.displayAvatarURL({ size: 2048 }),
4552
},
@@ -51,11 +58,14 @@ export async function chatInput(ctx: SlashCommandContext) {
5158

5259
export async function message(ctx: MessageCommandContext) {
5360
const user = ctx.options.getUser('user') ?? ctx.message.author;
61+
const { t } = ctx.locale();
5462

5563
await ctx.message.reply({
5664
embeds: [
5765
{
58-
title: `${user.username}'s Avatar`,
66+
title: t('avatar', {
67+
user: user.username,
68+
}),
5969
image: {
6070
url: user.displayAvatarURL({ size: 2048 }),
6171
},

apps/test-bot/src/app/locales/en-US/avatar.json

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default {
2+
$command: {
3+
name: 'avatar',
4+
description: 'This is an avatar command.',
5+
options: [
6+
{
7+
name: 'user',
8+
description: 'The user to get the avatar for.',
9+
},
10+
],
11+
},
12+
avatar: "{{user}}'s avatar",
13+
};

apps/test-bot/src/app/locales/en-US/cat.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

apps/test-bot/src/app/locales/en-US/legacy.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

apps/test-bot/src/app/locales/en-US/prompt.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

apps/test-bot/src/app/locales/fr/avatar.json

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default {
2+
$command: {
3+
name: 'avatar',
4+
description: "C'est une commande pour afficher l'avatar.",
5+
options: [
6+
{
7+
name: 'user',
8+
description: "L'utilisateur dont vous souhaitez voir l'avatar.",
9+
},
10+
],
11+
},
12+
avatar: 'Avatar de {{user}}',
13+
};

0 commit comments

Comments
 (0)