feat: no data translations

This commit is contained in:
TrèsAbhi committed 2024-03-06 16:26:36 -06:00
1 parent 716b446272
commit bd6f1f3570
8 files changed
+39 -22

No files matched your search

+2 -2
View File
@@ -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}`}
/>
<NoData type={NoDataType.BattlesInPeriod} />
<NoData type="battles_in_period" locale={locale} />
</CommandWrapper>,
];
}
+12 -4
View File
@@ -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(
</Graph.Root>
)}
{plot.length === 0 && <NoData type={NoDataType.BattlesInPeriod} />}
{plot.length === 0 && <NoData type="battles_in_period" locale={locale} />}
</CommandWrapper>
);
}
@@ -147,7 +148,13 @@ export const evolutionCommand = new Promise<CommandRegistry>(
});
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<CommandRegistry>(
period,
commandGroup,
parseInt(url.searchParams.get('tankId') ?? '0') || null,
interaction.locale,
);
},
});
+4 -2
View File
@@ -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 && <NoData type={NoDataType.BattlesInPeriod} />}
{stats.battles === 0 && (
<NoData type="battles_in_period" locale={locale} />
)}
{stats.battles > 0 && <TierWeights weights={tierWeights!} />}
{stats.battles > 0 && (
<GenericAllStats stats={stats} supplementaryStats={supplementary} />
+4 -2
View File
@@ -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<CommandRegistry>((resolve) => {
description={`Inactive for ${threshold}+ Days • ${new Date().toDateString()}`}
/>
{!hasInactiveMembers && <NoData type={NoDataType.PlayersInPeriod} />}
{!hasInactiveMembers && (
<NoData type="players_in_period" locale={interaction.locale} />
)}
{hasInactiveMembers && <GenericStats stats={inactive} />}
</CommandWrapper>
);
+2 -2
View File
@@ -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<CommandRegistry>((resolve) => {
/>
{filteredTanks.length === 0 && (
<NoData type={NoDataType.TanksFound} />
<NoData type="tanks_found" locale={interaction.locale} />
)}
{filteredTanks.length > 0 &&
+2 -2
View File
@@ -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 && <NoData type={NoDataType.BattlesInPeriod} />}
{!stats.battles && <NoData type="battles_in_period" locale={locale} />}
{stats.battles > 0 && (
<AllStatsOverview stats={stats} supplementaryStats={supplementary} />
)}
+7 -8
View File
@@ -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, string> = {
[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 (
<div
style={{
@@ -26,7 +25,7 @@ export default function NoData({ type }: NoDataProps) {
}}
>
<span style={{ fontSize: 16, color: theme.colors.textLowContrast }}>
{NO_DATA_MESSAGES[type]}
{translate(`bot.common.no_data.${type}`)}
</span>
</div>
);
+6
View File
@@ -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"
}
},