Skip to content

Commit

Permalink
Merge pull request #16 from karayaman/karayaman-french-voices
Browse files Browse the repository at this point in the history
Support for French voices.
  • Loading branch information
karayaman committed Feb 11, 2023
2 parents beea2df + ae8bf06 commit ddd73c7
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gui.py
Expand Up @@ -113,8 +113,8 @@ def start_game(ignore=None):
voice_index = VOICE_OPTIONS.index(selected_voice) - 1
arguments.append("voice=" + str(voice_index))
language = "English"
languages = ["English", "German", "Russian", "Turkish", "Italian"]
codes = ["en_", "de_", "ru_", "tr_", "it_"]
languages = ["English", "German", "Russian", "Turkish", "Italian", "French"]
codes = ["en_", "de_", "ru_", "tr_", "it_", "fr_"]
for l, c in zip(languages, codes):
if (l in selected_voice) or (l.lower() in selected_voice) or (c in selected_voice):
language = l
Expand Down
54 changes: 53 additions & 1 deletion languages.py
Expand Up @@ -312,4 +312,56 @@ def comment(self, board, move):
if promotion:
comment += " promuove a " + self.name(promotion)
comment += check
return comment
return comment


class French:
def __init__(self):
self.game_started = "Partie démarrée"
self.move_failed = "La reconnaissance a échoué. Veuillez réessayer."

def name(self, piece_type):
if piece_type == chess.PAWN:
return "pion"
elif piece_type == chess.KNIGHT:
return "cavalier"
elif piece_type == chess.BISHOP:
return "fou"
elif piece_type == chess.ROOK:
return "tour"
elif piece_type == chess.QUEEN:
return "reine"
elif piece_type == chess.KING:
return "roi"

def comment(self, board, move):
check = ""
if board.is_checkmate():
check = " échec et mat"
elif board.is_check():
check = " échec"
board.pop()
if board.is_kingside_castling(move):
board.push(move)
return "petit roc" + check
if board.is_queenside_castling(move):
board.push(move)
return "grand roc" + check

piece = board.piece_at(move.from_square)
from_square = chess.square_name(move.from_square)
to_square = chess.square_name(move.to_square)
promotion = move.promotion

is_capture = board.is_capture(move)
board.push(move)
comment = ""
comment += self.name(piece.piece_type)

comment += " " + from_square
comment += " prend" if is_capture else " vers"
comment += " " + to_square
if promotion:
comment += " promu en " + self.name(promotion)
comment += check
return comment
2 changes: 2 additions & 0 deletions main.py
Expand Up @@ -57,6 +57,8 @@
language = Turkish()
elif "Italian" in argument:
language = Italian()
elif "French" in argument:
language = French()
elif argument.startswith("token="):
token = argument[len("token="):].strip()
MOTION_START_THRESHOLD = 1.0
Expand Down

0 comments on commit ddd73c7

Please sign in to comment.