From f3b7af3e82fcde5a349c79a640d85776d907c394 Mon Sep 17 00:00:00 2001 From: spla Date: Sat, 28 Nov 2020 18:07:52 +0100 Subject: [PATCH] Added 'es' locale! --- mastochess.py | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/mastochess.py b/mastochess.py index e0486f4..96ca4a1 100644 --- a/mastochess.py +++ b/mastochess.py @@ -994,7 +994,7 @@ def replying(): elif query_word[:search_move_slicing] == search_move: - moving = query_word[4:query_word_length].replace(" ","") + moving = query_word[moving_slicing:query_word_length].replace(" ","") reply = True elif query_word == search_end: @@ -1165,7 +1165,7 @@ def create_dir(): def usage(): - print('usage: python ' + sys.argv[0] + ' --play' + ' --eng') + print('usage: python ' + sys.argv[0] + ' --play' + ' --en') ############################################################################### # main @@ -1184,40 +1184,55 @@ if __name__ == '__main__': if len(sys.argv) == 3: - if sys.argv[2] == '--eng': + if sys.argv[2] == '--en': - bot_lang = 'eng' + bot_lang = 'en' + + elif sys.argv[2] == '--es': + + bot_lang = 'es' else: bot_lang = 'ca' - if bot_lang == "ca": + if bot_lang == 'ca': - language_filepath = "locales/cat.txt" + language_filepath = 'locales/ca.txt' - elif bot_lang == "eng": + elif bot_lang == 'en': - language_filepath = "locales/eng.txt" + language_filepath = 'locales/en.txt' + + elif bot_lang == 'es': + + language_filepath = 'locales/es.txt' else: - print("\nOnly 'cat' and 'eng' languages are supported.\n") + print("\nOnly 'ca', 'es' and 'en' languages are supported.\n") sys.exit(0) - - if bot_lang == 'ca': search_move_slicing = 3 + moving_slicing = 3 search_send_slicing = 5 send_game_slicing = 6 - elif bot_lang == 'eng': + elif bot_lang == 'en': search_move_slicing = 4 + moving_slicing = 4 search_send_slicing = 4 send_game_slicing = 5 + elif bot_lang == 'es': + + search_move_slicing = 5 + moving_slicing = 5 + search_send_slicing = 5 + send_game_slicing = 6 + search_end, search_move, search_new, search_games, search_send, new_game_started, playing_with, your_turn, game_name, chess_hashtag, send_error = load_strings(bot_lang) game_number_anotations, anotations_sent, game_no_exists, it_not_exists, game_already_started, wait_other_player, is_not_legal_move, check_done, check_mate = load_strings1(bot_lang) @@ -1690,7 +1705,7 @@ if __name__ == '__main__': query_word_length = len(query_word) - send_game = query_word[6:query_word_length].replace(' ', '') + send_game = query_word[search_send_slicing:query_word_length].replace(' ', '') emailed, game_id, game_found = send_anotation(send_game) @@ -1747,3 +1762,6 @@ if __name__ == '__main__': i += 1 + else: + + usage()