Skip to content

Commit

Permalink
More i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
woprandi authored and franciscoBSalgueiro committed Dec 4, 2024
1 parent 7f4ebbd commit 7f7fff9
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 22 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
12 changes: 7 additions & 5 deletions src/components/common/CompleteMoveCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from "@tabler/icons-react";
import { useAtomValue } from "jotai";
import { memo, useContext, useState } from "react";
import { useTranslation } from "react-i18next";
import { useStore } from "zustand";
import MoveCell from "./MoveCell";
import { TreeStateContext } from "./TreeStateContext";
Expand Down Expand Up @@ -79,6 +80,7 @@ function CompleteMoveCell({
const currentTab = useAtomValue(currentTabAtom);

const transpositions = fen ? getTranspositions(fen, movePath, root) : [];
const { t } = useTranslation();

return (
<>
Expand Down Expand Up @@ -116,36 +118,36 @@ function CompleteMoveCell({
leftSection={<IconFlag size="0.875rem" />}
onClick={() => setStart(movePath)}
>
Mark as start
{t("Menu.MarkAsStart")}
</Menu.Item>
)}
<Menu.Item
leftSection={<IconChevronsUp size="0.875rem" />}
onClick={() => promoteToMainline(movePath)}
>
Promote to Main Line
{t("Menu.PromoteToMainLine")}
</Menu.Item>

<Menu.Item
leftSection={<IconChevronUp size="0.875rem" />}
onClick={() => promoteVariation(movePath)}
>
Promote Variation
{t("Menu.PromoteVariation")}
</Menu.Item>

<Menu.Item
leftSection={<IconCopy size="0.875rem" />}
onClick={() => copyVariationPgn(movePath)}
>
Copy Variation PGN
{t("Menu.CopyVariationPGN")}
</Menu.Item>

<Menu.Item
color="red"
leftSection={<IconX size="0.875rem" />}
onClick={() => deleteMove(movePath)}
>
Delete Move
{t("Menu.DeleteMove")}
</Menu.Item>
</Menu.Dropdown>
</Portal>
Expand Down
15 changes: 9 additions & 6 deletions src/components/panels/info/FenInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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";

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
23 changes: 23 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 All @@ -282,6 +299,12 @@ export const en_US = {
"Files.Create.Title": "Create file",
"Files.Search": "Search for files",

"Menu.MarkAsStart": "Mark as start",
"Menu.PromoteToMainLine": "Promote to Main Line",
"Menu.PromoteVariation": "Promote Variation",
"Menu.CopyVariationPGN": "Copy Variation PGN",
"Menu.DeleteMove": "Delete Move",

"Settings.Board": "Board",
"Settings.Inputs": "Inputs",
"Settings.OpeningReport": "Opening Report",
Expand Down
24 changes: 24 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 All @@ -284,6 +302,12 @@ export const fr_FR = {
"Files.Create.Title": "Créer fichier",
"Files.Search": "Rechercher des fichiers",

"Menu.MarkAsStart": "Marquer comme début",
"Menu.PromoteToMainLine": "Variante principale",
"Menu.PromoteVariation": "Promouvoir la variante",
"Menu.CopyVariationPGN": "Copier le PGN de la variante",
"Menu.DeleteMove": "Supprimer le coup",

"Settings.Board": "Échiquier",
"Settings.Inputs": "Entrées",
"Settings.OpeningReport": "Rapport d'ouverture",
Expand Down

0 comments on commit 7f7fff9

Please sign in to comment.