feat: translate tier list

This commit is contained in:
tresabhi committed 2025-01-07 13:09:05 -06:00
1 parent 6b2dda0f9d
commit 571ae81306
7 files changed
+40 -13

No files matched your search

+2 -2
View File
@@ -2,6 +2,8 @@ name: Website
on: on:
push: push:
branches:
- main
workflow_dispatch: workflow_dispatch:
schedule: schedule:
@@ -52,8 +54,6 @@ jobs:
path: dist/website path: dist/website
deploy-github-pages: deploy-github-pages:
if: github.ref == 'refs/heads/main'
name: Deploy to GitHub Pages name: Deploy to GitHub Pages
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
+11 -1
View File
@@ -713,6 +713,12 @@
}, },
"website": { "website": {
"common": {
"copy_button": {
"copied": "Copied!"
}
},
"home": { "home": {
"hero": { "hero": {
"credit": "By %s1 ❤️" "credit": "By %s1 ❤️"
@@ -795,7 +801,11 @@
"name": "Tier list", "name": "Tier list",
"button": "Rank tanks", "button": "Rank tanks",
"description": "Rank Blitz tanks", "description": "Rank Blitz tanks",
"seo_description": "Explore tier lists ranking tanks from best to worst, based on player ratings and statistical performance in World of Tanks Blitz" "seo_description": "Explore tier lists ranking tanks from best to worst, based on player ratings and statistical performance in World of Tanks Blitz",
"buttons": {
"reset": "Reset",
"share": "Share"
}
}, },
"embed": { "embed": {
"name": "Embed", "name": "Embed",
@@ -1,5 +1,6 @@
import { Button, type ButtonProps, Tooltip } from '@radix-ui/themes'; import { Button, type ButtonProps, Tooltip } from '@radix-ui/themes';
import { useState } from 'react'; import { useState } from 'react';
import { useLocale } from '../hooks/useLocale';
interface CopyButtonProps extends ButtonProps { interface CopyButtonProps extends ButtonProps {
copy: () => string | undefined; copy: () => string | undefined;
@@ -7,9 +8,13 @@ interface CopyButtonProps extends ButtonProps {
export function CopyButton({ copy, ...props }: CopyButtonProps) { export function CopyButton({ copy, ...props }: CopyButtonProps) {
const [tooltipOpen, setTooltipOpen] = useState(false); const [tooltipOpen, setTooltipOpen] = useState(false);
const { strings } = useLocale();
return ( return (
<Tooltip open={tooltipOpen} content="Copied!"> <Tooltip
open={tooltipOpen}
content={strings.website.common.copy_button.copied}
>
<Button <Button
{...props} {...props}
onClick={() => { onClick={() => {
@@ -1,10 +1,12 @@
import { Share2Icon } from '@radix-ui/react-icons'; import { Share2Icon } from '@radix-ui/react-icons';
import { generateTierListParams } from '../../../../core/blitzkit/generateTierListParams'; import { generateTierListParams } from '../../../../core/blitzkit/generateTierListParams';
import { useLocale } from '../../../../hooks/useLocale';
import { TierList } from '../../../../stores/tierList'; import { TierList } from '../../../../stores/tierList';
import { CopyButton } from '../../../CopyButton'; import { CopyButton } from '../../../CopyButton';
export function Share() { export function Share() {
const rows = TierList.use((state) => state.rows); const rows = TierList.use((state) => state.rows);
const { strings } = useLocale();
return ( return (
<CopyButton <CopyButton
@@ -13,7 +15,7 @@ export function Share() {
`${location.origin}/tools/tier-list?${generateTierListParams(rows)}` `${location.origin}/tools/tier-list?${generateTierListParams(rows)}`
} }
> >
<Share2Icon /> Share <Share2Icon /> {strings.website.tools.tier_list.buttons.share}
</CopyButton> </CopyButton>
); );
} }
@@ -1,10 +1,12 @@
import { ReloadIcon } from '@radix-ui/react-icons'; import { ReloadIcon } from '@radix-ui/react-icons';
import { Button, Flex } from '@radix-ui/themes'; import { Button, Flex } from '@radix-ui/themes';
import { useLocale } from '../../../hooks/useLocale';
import { TierList, tierListInitialState } from '../../../stores/tierList'; import { TierList, tierListInitialState } from '../../../stores/tierList';
import { Share } from './components/Share'; import { Share } from './components/Share';
export function TierListControls() { export function TierListControls() {
const mutateTierList = TierList.useMutation(); const mutateTierList = TierList.useMutation();
const { strings } = useLocale();
return ( return (
<Flex justify="center" gap="2"> <Flex justify="center" gap="2">
@@ -16,7 +18,7 @@ export function TierListControls() {
}); });
}} }}
> >
<ReloadIcon /> Reset <ReloadIcon /> {strings.website.tools.tier_list.buttons.reset}
</Button> </Button>
<Share /> <Share />
@@ -4,16 +4,22 @@ import { TierListControls } from '../../../../components/TierList/Controls';
import { TierListTable } from '../../../../components/TierList/Table'; import { TierListTable } from '../../../../components/TierList/Table';
import { TierListTiles } from '../../../../components/TierList/Tiles'; import { TierListTiles } from '../../../../components/TierList/Tiles';
import { URLManager } from '../../../../components/TierList/URLManager'; import { URLManager } from '../../../../components/TierList/URLManager';
import {
LocaleProvider,
type LocaleAcceptorProps,
} from '../../../../hooks/useLocale';
import { TankopediaPersistent } from '../../../../stores/tankopediaPersistent'; import { TankopediaPersistent } from '../../../../stores/tankopediaPersistent';
import { TierList } from '../../../../stores/tierList'; import { TierList } from '../../../../stores/tierList';
export function Page() { export function Page({ locale }: LocaleAcceptorProps) {
return ( return (
<TierList.Provider> <LocaleProvider locale={locale}>
<TankopediaPersistent.Provider> <TierList.Provider>
<Content /> <TankopediaPersistent.Provider>
</TankopediaPersistent.Provider> <Content />
</TierList.Provider> </TankopediaPersistent.Provider>
</TierList.Provider>
</LocaleProvider>
); );
} }
@@ -4,8 +4,10 @@ import ToolLayout from '../../../../layouts/ToolLayout.astro';
import { Page } from './_index'; import { Page } from './_index';
export { getStaticPaths } from '../../index.astro'; export { getStaticPaths } from '../../index.astro';
const { locale } = Astro.params;
--- ---
<ToolLayout tool={tierListTool}> <ToolLayout tool={tierListTool}>
<Page client:load /> <Page {locale} client:load />
</ToolLayout> </ToolLayout>