diff --git a/src/commands/breakdown.tsx b/src/commands/breakdown.tsx index 3c0e46ae5..9a7ed439a 100644 --- a/src/commands/breakdown.tsx +++ b/src/commands/breakdown.tsx @@ -2,7 +2,7 @@ import { Locale } from 'discord.js'; import { chunk } from 'lodash'; import * as Breakdown from '../components/Breakdown'; import CommandWrapper from '../components/CommandWrapper'; -import NoData, { NoDataType } from '../components/NoData'; +import NoData from '../components/NoData'; import TitleBar from '../components/TitleBar'; import { AllStats, getAccountInfo } from '../core/blitz/getAccountInfo'; import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo'; @@ -286,7 +286,7 @@ export async function renderBreakdown( description={`${name} • ${filterDescriptions}`} /> - + , ]; } diff --git a/src/commands/evolution.tsx b/src/commands/evolution.tsx index ffc3abf4e..fd6a61cdd 100644 --- a/src/commands/evolution.tsx +++ b/src/commands/evolution.tsx @@ -1,7 +1,7 @@ -import { SlashCommandSubcommandGroupBuilder } from 'discord.js'; +import { Locale, SlashCommandSubcommandGroupBuilder } from 'discord.js'; import CommandWrapper from '../components/CommandWrapper'; import * as Graph from '../components/Graph'; -import NoData, { NoDataType } from '../components/NoData'; +import NoData from '../components/NoData'; import TitleBar from '../components/TitleBar'; import { getAccountInfo } from '../core/blitz/getAccountInfo'; import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo'; @@ -36,6 +36,7 @@ async function render( { start, end, name }: ResolvedPeriod, type: 'player' | 'tank', tankId: number | null, + locale: Locale, ) { const accountInfo = await getAccountInfo(region, id); const clan = (await getClanAccountInfo(region, id, ['clan']))?.clan; @@ -100,7 +101,7 @@ async function render( )} - {plot.length === 0 && } + {plot.length === 0 && } ); } @@ -147,7 +148,13 @@ export const evolutionCommand = new Promise( }); return [ - await render(player, period, commandGroup, tankId), + await render( + player, + period, + commandGroup, + tankId, + interaction.locale, + ), buttonRefresh(interaction, path), await getBlitzStarsLinkButton( player.region, @@ -174,6 +181,7 @@ export const evolutionCommand = new Promise( period, commandGroup, parseInt(url.searchParams.get('tankId') ?? '0') || null, + interaction.locale, ); }, }); diff --git a/src/commands/fullStats.tsx b/src/commands/fullStats.tsx index 1026c5a79..5a3da27a0 100644 --- a/src/commands/fullStats.tsx +++ b/src/commands/fullStats.tsx @@ -1,7 +1,7 @@ import { Locale, SlashCommandBuilder } from 'discord.js'; import CommandWrapper from '../components/CommandWrapper'; import GenericAllStats from '../components/GenericAllStats'; -import NoData, { NoDataType } from '../components/NoData'; +import NoData from '../components/NoData'; import TierWeights from '../components/TierWeights'; import TitleBar from '../components/TitleBar'; import { getAccountInfo } from '../core/blitz/getAccountInfo'; @@ -56,7 +56,9 @@ async function render( description={`${name} • ${filterDescriptions}`} /> - {stats.battles === 0 && } + {stats.battles === 0 && ( + + )} {stats.battles > 0 && } {stats.battles > 0 && ( diff --git a/src/commands/inactive.tsx b/src/commands/inactive.tsx index f5a4807f5..39d803123 100644 --- a/src/commands/inactive.tsx +++ b/src/commands/inactive.tsx @@ -1,7 +1,7 @@ import { SlashCommandBuilder } from 'discord.js'; import CommandWrapper from '../components/CommandWrapper'; import GenericStats from '../components/GenericStats'; -import NoData, { NoDataType } from '../components/NoData'; +import NoData from '../components/NoData'; import TitleBar from '../components/TitleBar'; import { getAccountInfo } from '../core/blitz/getAccountInfo'; import { getClanInfo } from '../core/blitz/getClanInfo'; @@ -61,7 +61,9 @@ export const inactiveCommand = new Promise((resolve) => { description={`Inactive for ${threshold}+ Days • ${new Date().toDateString()}`} /> - {!hasInactiveMembers && } + {!hasInactiveMembers && ( + + )} {hasInactiveMembers && } ); diff --git a/src/commands/ownedTanks.tsx b/src/commands/ownedTanks.tsx index 4c8640c7a..c88dcb07a 100644 --- a/src/commands/ownedTanks.tsx +++ b/src/commands/ownedTanks.tsx @@ -1,6 +1,6 @@ import { SlashCommandBuilder } from 'discord.js'; import CommandWrapper from '../components/CommandWrapper'; -import NoData, { NoDataType } from '../components/NoData'; +import NoData from '../components/NoData'; import * as Tanks from '../components/Tanks'; import TitleBar from '../components/TitleBar'; import { encyclopediaInfo } from '../core/blitz/encyclopediaInfo'; @@ -74,7 +74,7 @@ export const ownedTanksCommand = new Promise((resolve) => { /> {filteredTanks.length === 0 && ( - + )} {filteredTanks.length > 0 && diff --git a/src/commands/stats.tsx b/src/commands/stats.tsx index ceca9cd0c..71f24f588 100644 --- a/src/commands/stats.tsx +++ b/src/commands/stats.tsx @@ -1,7 +1,7 @@ import { Locale, SlashCommandBuilder } from 'discord.js'; import AllStatsOverview from '../components/AllStatsOverview'; import CommandWrapper from '../components/CommandWrapper'; -import NoData, { NoDataType } from '../components/NoData'; +import NoData from '../components/NoData'; import TitleBar from '../components/TitleBar'; import { getAccountInfo } from '../core/blitz/getAccountInfo'; import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo'; @@ -50,7 +50,7 @@ async function render( description={`${name} • ${filterDescriptions}`} /> - {!stats.battles && } + {!stats.battles && } {stats.battles > 0 && ( )} diff --git a/src/components/NoData.tsx b/src/components/NoData.tsx index 3bf47967b..3f28d8fdf 100644 --- a/src/components/NoData.tsx +++ b/src/components/NoData.tsx @@ -1,3 +1,5 @@ +import { Locale } from 'discord.js'; +import { translator } from '../core/localization/translator'; import { theme } from '../stitches.config'; export enum NoDataType { @@ -7,16 +9,13 @@ export enum NoDataType { } export interface NoDataProps { - type: NoDataType; + type: 'battles_in_period' | 'players_in_period' | 'tanks_found'; + locale: Locale; } -const NO_DATA_MESSAGES: Record = { - [NoDataType.BattlesInPeriod]: 'No battles played in this period', - [NoDataType.PlayersInPeriod]: 'No players in this period', - [NoDataType.TanksFound]: 'No tanks found', -}; +export default function NoData({ type, locale }: NoDataProps) { + const { translate } = translator(locale); -export default function NoData({ type }: NoDataProps) { return (
- {NO_DATA_MESSAGES[type]} + {translate(`bot.common.no_data.${type}`)}
); diff --git a/src/lang/en-US.json b/src/lang/en-US.json index be0637bba..efdf3ff25 100644 --- a/src/lang/en-US.json +++ b/src/lang/en-US.json @@ -90,6 +90,12 @@ "filters": { "none": "No filters", "tier": "Tier %s" + }, + + "no_data": { + "battles_in_period": "No battles played in this period", + "players_in_period": "No players in this period", + "tanks_found": "No tanks found" } },