Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag some errors message as translatable #402

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/boards/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ function Board({

{error && (
<Text ta="center" c="red">
{chessopsError(error)}
{t(chessopsError(error))}
</Text>
)}

Expand Down
15 changes: 15 additions & 0 deletions src/translation/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,21 @@ export const en_US = {
"Databases.Delete.Message":
"Are you sure you want to delete this database?",

"Errors.EmptyBoard": "Empty board",
"Errors.InvalidKings": "Invalid number of kings",
"Errors.OppositeCheck": "Opposite check",
"Errors.PawnsOnBackrank": "Pawns on backrank",
"Errors.InvalidBoard": "Invalid board",
"Errors.InvalidCastlingRights": "Invalid castling rights",
"Errors.InvalidEpSquare": "Invalid en passant square",
"Errors.InvalidFen": "Invalid FEN",
"Errors.InvalidFullmoves": "Invalid fullmove number",
"Errors.InvalidHaldmoves": "Invalid halfmove number",
"Errors.InvalidPockets": "Invalid pockets",
"Errors.InvalidRemainingChecks": "Invalid remaining checks",
"Errors.InvalidTurn": "Invalid turn",
"Errors.Unknown": "Unknown error",

"Files.Title": "Files",
"Files.FileType": "File type",
"Files.FileType.Game": "Game",
Expand Down
15 changes: 15 additions & 0 deletions src/translation/fr_FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,21 @@ export const fr_FR = {
"Databases.Delete.Message":
"Êtes-vous sûr de vouloir supprimer cette base de données ?",

"Errors.EmptyBoard": "Échiquier vide",
"Errors.InvalidKings": "Nombre de Rois invalide",
"Errors.OppositeCheck": "Échec opposé",
"Errors.PawnsOnBackrank": "Pions en dernière rangée",
"Errors.InvalidBoard": "Échiquier invalide",
"Errors.InvalidCastlingRights": "Droits de roque invalide",
"Errors.InvalidEpSquare": "Case en passant invalide",
"Errors.InvalidFen": "FEN invalide",
"Errors.InvalidFullmoves": "Nombre de coup complet invalide",
"Errors.InvalidHalfmoves": "Nombre de demi-coup invalide",
"Errors.InvalidPockets": "Invalid pockets",
"Errors.InvalidRemainingChecks": "Échecs restant invalide",
"Errors.InvalidTurn": "Trait invalide",
"Errors.Unknown": "Erreur inconnue",

"Files.Title": "Fichiers",
"Files.FileType": "Type de fichier",
"Files.FileType.Game": "Partie",
Expand Down
34 changes: 20 additions & 14 deletions src/utils/chessops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,29 @@ export function squareToCoordinates(

export function chessopsError(error: PositionError | FenError) {
return match(error)
.with({ message: IllegalSetup.Empty }, () => "Empty board")
.with({ message: IllegalSetup.Kings }, () => "Invalid number of kings")
.with({ message: IllegalSetup.OppositeCheck }, () => "Opposite check")
.with({ message: IllegalSetup.PawnsOnBackrank }, () => "Pawns on backrank")
.with({ message: InvalidFen.Board }, () => "Invalid board")
.with({ message: InvalidFen.Castling }, () => "Invalid castling rights")
.with({ message: InvalidFen.EpSquare }, () => "Invalid en passant square")
.with({ message: InvalidFen.Fen }, () => "Invalid FEN")
.with({ message: InvalidFen.Fullmoves }, () => "Invalid fullmove number")
.with({ message: InvalidFen.Halfmoves }, () => "Invalid halfmove number")
.with({ message: InvalidFen.Pockets }, () => "Invalid pockets")
.with({ message: IllegalSetup.Empty }, () => "Errors.EmptyBoard")
.with({ message: IllegalSetup.Kings }, () => "Errors.InvalidKings")
.with({ message: IllegalSetup.OppositeCheck }, () => "Errors.OppositeCheck")
.with(
{ message: IllegalSetup.PawnsOnBackrank },
() => "Errors.PawnsOnBackrank",
)
.with({ message: InvalidFen.Board }, () => "Errors.InvalidBoard")
.with(
{ message: InvalidFen.Castling },
() => "Errors.InvalidCastlingRights",
)
.with({ message: InvalidFen.EpSquare }, () => "Errors.InvalidEpSquare")
.with({ message: InvalidFen.Fen }, () => "Errors.InvalidFen")
.with({ message: InvalidFen.Fullmoves }, () => "Errors.InvalidFullmoves")
.with({ message: InvalidFen.Halfmoves }, () => "Errors.InvalidHalfmoves")
.with({ message: InvalidFen.Pockets }, () => "Errors.InvalidPockets")
.with(
{ message: InvalidFen.RemainingChecks },
() => "Invalid remaining checks",
() => "Errors.InvalidRemainingChecks",
)
.with({ message: InvalidFen.Turn }, () => "Invalid turn")
.otherwise(() => "Unknown error");
.with({ message: InvalidFen.Turn }, () => "Errors.InvalidTurn")
.otherwise(() => "Errors.Unknown");
}

export function forceEnPassant(
Expand Down
Loading