mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: start of tankopedia translation
This commit is contained in:
1 parent
5a65fee1d1
commit
91b367cd70
6 files changed
+39
-92
No files matched your search
@@ -799,7 +799,9 @@
|
|||||||
"name": "Tankopedia",
|
"name": "Tankopedia",
|
||||||
"button": "Find tanks",
|
"button": "Find tanks",
|
||||||
"description": "Blitz tank encyclopedia",
|
"description": "Blitz tank encyclopedia",
|
||||||
"seo_description": "Statistics, armor, and more for all tanks in World of Tanks Blitz"
|
"seo_description": "Statistics, armor, and more for all tanks in World of Tanks Blitz",
|
||||||
|
"tank_seo_title": "%s1 - Tier %s2 %s3 %s4 | %s5 Tankopedia | World of Tanks Blitz (WoTB)",
|
||||||
|
"tank_seo_description": "%s1 armor, statistics, equipment, provisions, and more. %s2 DPM, %s3hp alpha, %s4mm penetration, %s5kph top speed, %s6hp health."
|
||||||
},
|
},
|
||||||
"compare": {
|
"compare": {
|
||||||
"name": "Compare",
|
"name": "Compare",
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
import { TIER_ROMAN_NUMERALS } from '@blitzkit/core';
|
import { TIER_ROMAN_NUMERALS } from '@blitzkit/core';
|
||||||
import strings from '@blitzkit/core/lang/en-US.json';
|
|
||||||
import { Flex, Heading, SegmentedControl, Text } from '@radix-ui/themes';
|
import { Flex, Heading, SegmentedControl, Text } from '@radix-ui/themes';
|
||||||
|
import { useLocale } from '../../../../../../hooks/useLocale';
|
||||||
import { Duel } from '../../../../../../stores/duel';
|
import { Duel } from '../../../../../../stores/duel';
|
||||||
import {
|
import {
|
||||||
TankopediaEphemeral,
|
TankopediaEphemeral,
|
||||||
@@ -13,6 +13,7 @@ export function CharacteristicsHeading() {
|
|||||||
);
|
);
|
||||||
const tank = Duel.use((state) => state.protagonist.tank);
|
const tank = Duel.use((state) => state.protagonist.tank);
|
||||||
const mutateTankopediaEphemeral = TankopediaEphemeral.useMutation();
|
const mutateTankopediaEphemeral = TankopediaEphemeral.useMutation();
|
||||||
|
const { strings } = useLocale();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
TankType,
|
TankType,
|
||||||
TIER_ROMAN_NUMERALS,
|
TIER_ROMAN_NUMERALS,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
import strings from '@blitzkit/core/lang/en-US.json';
|
|
||||||
import { ChevronLeftIcon, MixIcon, UpdateIcon } from '@radix-ui/react-icons';
|
import { ChevronLeftIcon, MixIcon, UpdateIcon } from '@radix-ui/react-icons';
|
||||||
import { Button, Code, Dialog, Flex, Link } from '@radix-ui/themes';
|
import { Button, Code, Dialog, Flex, Link } from '@radix-ui/themes';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
@@ -39,7 +38,7 @@ export function MetaSection() {
|
|||||||
const mutateDuel = Duel.useMutation();
|
const mutateDuel = Duel.useMutation();
|
||||||
const mutateTankopediaEphemeral = TankopediaEphemeral.useMutation();
|
const mutateTankopediaEphemeral = TankopediaEphemeral.useMutation();
|
||||||
const [showSwapDialog, setShowSwapDialog] = useState(false);
|
const [showSwapDialog, setShowSwapDialog] = useState(false);
|
||||||
const { locale } = useLocale();
|
const { locale, strings } = useLocale();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex justify="center" align="center">
|
<Flex justify="center" align="center">
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
import { asset, AverageDefinitions } from '@blitzkit/core';
|
|
||||||
import { Box, Flex, Heading, Text } from '@radix-ui/themes';
|
|
||||||
import { range } from 'lodash-es';
|
|
||||||
import { useAveragesExclusionRatio } from '../../hooks/useAveragesExclusionRatio';
|
|
||||||
import { Duel } from '../../stores/duel';
|
|
||||||
import { FIRST_AVERAGES_ENTRY } from '../Charts/constants';
|
|
||||||
import { ThemedLine } from '../Nivo/ThemedLine';
|
|
||||||
|
|
||||||
const currentEntry = Math.floor(Date.now() / 1000 / 60 / 60 / 24);
|
|
||||||
const days = await Promise.all(
|
|
||||||
range(FIRST_AVERAGES_ENTRY, currentEntry).map(async (day) => {
|
|
||||||
const url = asset(`averages/${day}.pb`);
|
|
||||||
const response = await fetch(url);
|
|
||||||
|
|
||||||
if (response.status !== 200) return null;
|
|
||||||
|
|
||||||
const buffer = await response.arrayBuffer();
|
|
||||||
const averageDefinitions = AverageDefinitions.decode(
|
|
||||||
new Uint8Array(buffer),
|
|
||||||
);
|
|
||||||
|
|
||||||
return { day, definitions: averageDefinitions };
|
|
||||||
}),
|
|
||||||
).then((days) => days.filter((day) => day !== null));
|
|
||||||
|
|
||||||
export function TankopediaCharts() {
|
|
||||||
const id = Duel.use((state) => state.protagonist.tank.id);
|
|
||||||
const ratio = useAveragesExclusionRatio();
|
|
||||||
const data = days.map(({ day, definitions }) => {
|
|
||||||
const entry = definitions.averages[id];
|
|
||||||
const x = new Date(day * 24 * 60 * 60 * 1000);
|
|
||||||
const y = entry ? Math.round((entry.samples.d_7 / 7) * ratio) : 0;
|
|
||||||
|
|
||||||
return { x, y };
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Flex direction="column" align="center">
|
|
||||||
<Flex direction="column" width="50rem">
|
|
||||||
<Heading>Players</Heading>
|
|
||||||
<Text color="gray" mb="5">
|
|
||||||
7-day rolling average
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<Box height="25rem">
|
|
||||||
<ThemedLine
|
|
||||||
enablePoints={false}
|
|
||||||
enableGridX={false}
|
|
||||||
data={[{ id: 'value', data }]}
|
|
||||||
xFormat={(date) => {
|
|
||||||
return (date as Date).toLocaleDateString(undefined, {
|
|
||||||
day: 'numeric',
|
|
||||||
month: 'short',
|
|
||||||
year: 'numeric',
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
xScale={{ type: 'time' }}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,6 @@ import { GameModeSection } from '../../../../../components/Tankopedia/GameModeSe
|
|||||||
import { HeroSection } from '../../../../../components/Tankopedia/HeroSection';
|
import { HeroSection } from '../../../../../components/Tankopedia/HeroSection';
|
||||||
import { HistorySection } from '../../../../../components/Tankopedia/HistorySection';
|
import { HistorySection } from '../../../../../components/Tankopedia/HistorySection';
|
||||||
import { MetaSection } from '../../../../../components/Tankopedia/MetaSection';
|
import { MetaSection } from '../../../../../components/Tankopedia/MetaSection';
|
||||||
import { TankopediaCharts } from '../../../../../components/Tankopedia/TankopediaCharts';
|
|
||||||
import { TechTreeSection } from '../../../../../components/Tankopedia/TechTreeSection';
|
import { TechTreeSection } from '../../../../../components/Tankopedia/TechTreeSection';
|
||||||
import { VideoSection } from '../../../../../components/Tankopedia/VideoSection';
|
import { VideoSection } from '../../../../../components/Tankopedia/VideoSection';
|
||||||
import { awaitableModelDefinitions } from '../../../../../core/awaitables/modelDefinitions';
|
import { awaitableModelDefinitions } from '../../../../../core/awaitables/modelDefinitions';
|
||||||
@@ -55,7 +54,6 @@ export function Page({ id, skeleton, locale }: PageProps) {
|
|||||||
)}
|
)}
|
||||||
<CharacteristicsSection />
|
<CharacteristicsSection />
|
||||||
<GameModeSection />
|
<GameModeSection />
|
||||||
<TankopediaCharts />
|
|
||||||
<VideoSection skeleton={skeleton} />
|
<VideoSection skeleton={skeleton} />
|
||||||
<HistorySection />
|
<HistorySection />
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
---
|
---
|
||||||
import {
|
import {
|
||||||
asset,
|
asset,
|
||||||
createDefaultProvisions,
|
createDefaultProvisions,
|
||||||
createDefaultSkills,
|
createDefaultSkills,
|
||||||
fetchEquipmentDefinitions,
|
DEFAULT_LOCALE,
|
||||||
fetchModelDefinitions,
|
fetchEquipmentDefinitions,
|
||||||
fetchProvisionDefinitions,
|
fetchModelDefinitions,
|
||||||
fetchSkillDefinitions,
|
fetchProvisionDefinitions,
|
||||||
fetchTankDefinitions,
|
fetchSkillDefinitions,
|
||||||
TIER_ROMAN_NUMERALS,
|
fetchTankDefinitions,
|
||||||
|
TIER_ROMAN_NUMERALS,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
import strings from '@blitzkit/core/lang/en-US.json';
|
|
||||||
import type { GetStaticPaths } from 'astro';
|
import type { GetStaticPaths } from 'astro';
|
||||||
import { tankCharacteristics } from '../../../../../core/blitzkit/tankCharacteristics';
|
import { tankCharacteristics } from '../../../../../core/blitzkit/tankCharacteristics';
|
||||||
|
import { getStrings } from '../../../../../core/i18n/getStrings';
|
||||||
|
import { literals } from '../../../../../core/i18n/literals';
|
||||||
import BaseLayout from '../../../../../layouts/BaseLayout.astro';
|
import BaseLayout from '../../../../../layouts/BaseLayout.astro';
|
||||||
import { genericDefaultEquipmentMatrix } from '../../../../../stores/duel/constants';
|
import { genericDefaultEquipmentMatrix } from '../../../../../stores/duel/constants';
|
||||||
import { getStaticPaths as parentGetStaticPaths } from '../index.astro';
|
import { getStaticPaths as parentGetStaticPaths } from '../index.astro';
|
||||||
@@ -31,8 +33,9 @@ export const getStaticPaths = (async () => {
|
|||||||
.flat();
|
.flat();
|
||||||
}) satisfies GetStaticPaths;
|
}) satisfies GetStaticPaths;
|
||||||
|
|
||||||
const {id} = Astro.params;
|
const { id } = Astro.params;
|
||||||
const locale = Astro.params.locale ?? DEFAULT_LOCALE;
|
const locale = Astro.params.locale ?? DEFAULT_LOCALE;
|
||||||
|
const strings = getStrings(locale);
|
||||||
const tankDefinitions = await fetchTankDefinitions();
|
const tankDefinitions = await fetchTankDefinitions();
|
||||||
const skillDefinitions = await fetchSkillDefinitions();
|
const skillDefinitions = await fetchSkillDefinitions();
|
||||||
const provisionDefinitions = await fetchProvisionDefinitions();
|
const provisionDefinitions = await fetchProvisionDefinitions();
|
||||||
@@ -41,11 +44,16 @@ const tankModelDefinitions = await fetchModelDefinitions();
|
|||||||
const tank = tankDefinitions.tanks[id];
|
const tank = tankDefinitions.tanks[id];
|
||||||
const tankModelDefinition = tankModelDefinitions.models[tank.id];
|
const tankModelDefinition = tankModelDefinitions.models[tank.id];
|
||||||
const name = tank.name_full ?? tank.name;
|
const name = tank.name_full ?? tank.name;
|
||||||
const title = `${name} - Tier ${TIER_ROMAN_NUMERALS[tank.tier]} ${
|
const title = literals(strings.website.tools.tankopedia.tank_seo_title, [
|
||||||
|
name,
|
||||||
|
TIER_ROMAN_NUMERALS[tank.tier],
|
||||||
strings.common.nations_adjectives[
|
strings.common.nations_adjectives[
|
||||||
tank.nation as keyof typeof strings.common.nations_adjectives
|
tank.nation as keyof typeof strings.common.nations_adjectives
|
||||||
]
|
],
|
||||||
} ${strings.common.tank_class_short[tank.class]} | BlitzKit Tankopedia | World of Tanks Blitz (WoTB)`;
|
strings.common.tank_class_short[tank.class],
|
||||||
|
'BlitzKit',
|
||||||
|
strings.common.nations[tank.nation as keyof typeof strings.common.nations],
|
||||||
|
]);
|
||||||
const url = import.meta.env.SITE + Astro.url.pathname;
|
const url = import.meta.env.SITE + Astro.url.pathname;
|
||||||
const icon = asset(`icons/tanks/big/${id}.webp`);
|
const icon = asset(`icons/tanks/big/${id}.webp`);
|
||||||
const turret = tank.turrets.at(-1)!;
|
const turret = tank.turrets.at(-1)!;
|
||||||
@@ -73,15 +81,17 @@ const characteristics = tankCharacteristics(
|
|||||||
},
|
},
|
||||||
{ equipmentDefinitions, provisionDefinitions, tankModelDefinition },
|
{ equipmentDefinitions, provisionDefinitions, tankModelDefinition },
|
||||||
);
|
);
|
||||||
const description = `${
|
const description = literals(
|
||||||
name
|
strings.website.tools.tankopedia.tank_seo_description,
|
||||||
} armor, statistics, equipment, provisions, and more. ${Math.round(
|
[
|
||||||
characteristics.dpm,
|
name,
|
||||||
).toLocaleString(locale)} DPM, ${characteristics.damage.toFixed(0)}hp alpha, ${characteristics.penetration.toFixed(
|
Math.round(characteristics.dpm).toLocaleString(locale),
|
||||||
0,
|
Math.round(characteristics.damage).toLocaleString(locale),
|
||||||
)}mm penetration, ${characteristics.speedForwards.toFixed(
|
Math.round(characteristics.penetration).toLocaleString(locale),
|
||||||
0,
|
Math.round(characteristics.speedForwards).toLocaleString(locale),
|
||||||
)}kph top speed, ${characteristics.health}hp health.`;
|
Math.round(characteristics.health).toLocaleString(locale),
|
||||||
|
],
|
||||||
|
);
|
||||||
---
|
---
|
||||||
|
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
|
|||||||
Reference in new issue
Block a user