Skip to content

Commit

Permalink
More i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
woprandi committed Oct 23, 2024
1 parent cd95c81 commit 333674a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 18 deletions.
28 changes: 18 additions & 10 deletions src/components/boards/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,13 @@ function Board({
}
onClick={() => setViewPawnStructure(!viewPawnStructure)}
>
Toggle Pawn Structure View
{t("Board.Action.TogglePawnStructureView")}
</Menu.Item>
<Menu.Item
leftSection={<IconCamera size="1.3rem" />}
onClick={() => takeSnapshot()}
>
Take Snapshot
{t("Board.Action.TakeSnapshot")}
</Menu.Item>
</Menu.Dropdown>
</Menu>
Expand All @@ -384,9 +384,11 @@ function Board({
</Tooltip>
)}
<Tooltip
label={
currentTab?.type === "analysis" ? "Play from here" : "Analyze game"
}
label={t(
currentTab?.type === "analysis"
? "Board.Action.PlayFromHere"
: "Board.AnalyzeGame",
)}
>
<ActionIcon variant="default" size="lg" onClick={changeTabType}>
{currentTab?.type === "analysis" ? (
Expand All @@ -397,7 +399,7 @@ function Board({
</ActionIcon>
</Tooltip>
{!eraseDrawablesOnClick && (
<Tooltip label="Clear Drawings">
<Tooltip label={t("Board.Action.ClearDrawings")}>
<ActionIcon
variant={editingMode ? "filled" : "default"}
size="lg"
Expand All @@ -408,7 +410,7 @@ function Board({
</Tooltip>
)}
{!disableVariations && (
<Tooltip label="Edit Position">
<Tooltip label={t("Board.Action.EditPosition")}>
<ActionIcon
variant={editingMode ? "filled" : "default"}
size="lg"
Expand All @@ -424,7 +426,9 @@ function Board({
)}

{saveFile && (
<Tooltip label={`Save PGN (${keyMap.SAVE_FILE.keys})`}>
<Tooltip
label={t("Board.Action.SavePGN", { key: keyMap.SAVE_FILE.keys })}
>
<ActionIcon
onClick={() => saveFile()}
size="lg"
Expand All @@ -435,13 +439,17 @@ function Board({
</Tooltip>
)}
{addGame && currentTab?.file && (
<Tooltip label="Add Game">
<Tooltip label={t("Board.Action.AddGame")}>
<ActionIcon variant="default" size="lg" onClick={() => addGame()}>
<IconPlus size="1.3rem" />
</ActionIcon>
</Tooltip>
)}
<Tooltip label={`Flip Board (${keyMap.SWAP_ORIENTATION.keys})`}>
<Tooltip
label={t("Board.Action.FlipBoard", {
key: keyMap.SWAP_ORIENTATION.keys,
})}
>
<ActionIcon
variant="default"
size="lg"
Expand Down
17 changes: 10 additions & 7 deletions src/components/panels/info/FenInput.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { TreeStateContext } from "@/components/common/TreeStateContext";
import { getCastlingSquare, swapMove } from "@/utils/chessops";
import { Button, Checkbox, Group, Select, Stack, Text } from "@mantine/core";
import { type Setup, SquareSet } from "chessops";
import { EMPTY_FEN, INITIAL_FEN, makeFen, parseFen } from "chessops/fen";
import { memo, useCallback, useContext, useEffect, useMemo } from "react";
import { useTranslation } from "react-i18next";
import { useStore } from "zustand";
import FenSearch from "./FenSearch";
import { SquareSet, type Setup } from "chessops";

type Castlingrights = {
k: boolean;
Expand Down Expand Up @@ -116,6 +117,8 @@ function FenInput({ currentFen }: { currentFen: string }) {
setFen(makeFen({ ...setup, castlingRights: newCastlingRights }));
}, [blackCastling, setCastlingRights, setup, whiteCastling, setFen]);

const { t } = useTranslation();

return (
<Stack gap="sm">
<Group>
Expand All @@ -124,17 +127,17 @@ function FenInput({ currentFen }: { currentFen: string }) {
<FenSearch currentFen={currentFen} />
<Group>
<Button variant="default" onClick={() => setFen(INITIAL_FEN)}>
Start
{t("Fen.Start")}
</Button>
<Button variant="default" onClick={() => setFen(EMPTY_FEN)}>
Empty
{t("Fen.Empty")}
</Button>
<Select
flex={1}
allowDeselect={false}
data={[
{ label: "White to move", value: "white" },
{ label: "Black to move", value: "black" },
{ label: t("Fen.WhiteToMove"), value: "white" },
{ label: t("Fen.BlackToMove"), value: "black" },
]}
value={setup?.turn || "white"}
onChange={(value) => {
Expand All @@ -151,7 +154,7 @@ function FenInput({ currentFen }: { currentFen: string }) {
</Stack>
<Group>
<Stack>
<Text size="sm">White</Text>
<Text size="sm">{t("Fen.White")}</Text>
<Checkbox
label="O-O"
checked={whiteCastling.k}
Expand All @@ -170,7 +173,7 @@ function FenInput({ currentFen }: { currentFen: string }) {
/>
</Stack>
<Stack>
<Text size="sm">Black</Text>
<Text size="sm">{t("Fen.Black")}</Text>
<Checkbox
label="O-O"
checked={blackCastling.k}
Expand Down
2 changes: 1 addition & 1 deletion src/components/tabs/NewTabHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function NewTabHome({ id }: { id: string }) {
setTabs((prev: Tab[]) => {
const tab = prev.find((t) => t.value === id);
if (!tab) return prev;
tab.name = "Analysis Board";
tab.name = t("Home.Card.AnalysisBoard.Title");
tab.type = "analysis";
return [...prev];
});
Expand Down
17 changes: 17 additions & 0 deletions src/translation/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ export const en_US = {
"Home.Card.Puzzle.Desc": "Train your chess skills",
"Home.Card.Puzzle.Button": "Train",

"Board.Action.TogglePawnStructureView": "Toggle Pawn Structure View",
"Board.Action.TakeSnapshot": "Take Snapshot",
"Board.Action.AnalyzeGame": "Analyze game",
"Board.Action.PlayFromHere": "Play from here",
"Board.Action.ClearDrawings": "Clear Drawings",
"Board.Action.EditPosition": "Edit Position",
"Board.Action.SavePGN": "Save PGN ({{key}})",
"Board.Action.AddGame": "Add Game",
"Board.Action.FlipBoard": "Flip Board ({{key}})",

"Board.Tabs.Practice": "Practice",
"Board.Tabs.Analysis": "Analysis",
"Board.Tabs.Database": "Database",
Expand Down Expand Up @@ -267,6 +277,13 @@ export const en_US = {
"Errors.InvalidTurn": "Invalid turn",
"Errors.Unknown": "Unknown error",

"Fen.Start": "Start",
"Fen.Empty": "Empty",
"Fen.White": "White",
"Fen.Black": "Black",
"Fen.WhiteToMove": "White to move",
"Fen.BlackToMove": "Black to move",

"Files.Title": "Files",
"Files.FileType": "File type",
"Files.FileType.Game": "Game",
Expand Down
18 changes: 18 additions & 0 deletions src/translation/fr_FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ export const fr_FR = {
"Home.Card.Puzzle.Desc": "Entraînement pour vous améliorer",
"Home.Card.Puzzle.Button": "S'entraîner",

"Board.Action.TogglePawnStructureView":
"Basculer l'affichage de la structure de pions",
"Board.Action.TakeSnapshot": "Prendre une capture d'écran",
"Board.Action.AnalyzeGame": "Analyser la partie",
"Board.Action.PlayFromHere": "Jouer à partir d'ici",
"Board.Action.ClearDrawings": "Effacer les dessins",
"Board.Action.EditPosition": "Éditer la position",
"Board.Action.SavePGN": "Enregistrer le PGN ({{key}})",
"Board.Action.AddGame": "Ajouter une partie",
"Board.Action.FlipBoard": "Tourner l'échiquier ({{key}})",

"Board.Tabs.Practice": "Entraînement",
"Board.Tabs.Analysis": "Analyse",
"Board.Tabs.Database": "Base de données",
Expand Down Expand Up @@ -269,6 +280,13 @@ export const fr_FR = {
"Errors.InvalidTurn": "Trait invalide",
"Errors.Unknown": "Erreur inconnue",

"Fen.Start": "Départ",
"Fen.Empty": "Vide",
"Fen.White": "Blancs",
"Fen.Black": "Noirs",
"Fen.WhiteToMove": "Trait aux Blancs",
"Fen.BlackToMove": "Trait aux Noirs",

"Files.Title": "Fichiers",
"Files.FileType": "Type de fichier",
"Files.FileType.Game": "Partie",
Expand Down

0 comments on commit 333674a

Please sign in to comment.