diff --git a/ikabot/command_line.py b/ikabot/command_line.py index 2a0f25da..8175e78c 100755 --- a/ikabot/command_line.py +++ b/ikabot/command_line.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- import datetime -import gettext import multiprocessing import os import sys @@ -48,10 +47,6 @@ from ikabot.helpers.process import updateProcessList from ikabot.web.session import * -t = gettext.translation("command_line", localedir, languages=languages, fallback=True) -_ = t.gettext - - def menu(session, checkUpdate=True): """ Parameters @@ -149,28 +144,28 @@ def menu(session, checkUpdate=True): 2108: loadCustomModule } - print(_("(0) Exit")) - print(_("(1) Construction list")) - print(_("(2) Send resources")) - print(_("(3) Distribute resources")) - print(_("(4) Account status")) - print(_("(5) Activate Shrine")) - print(_("(6) Login daily")) - print(_("(7) Alerts / Notifications")) - print(_("(8) Marketplace")) - print(_("(9) Donate")) - print(_("(10) Activate vacation mode")) - print(_("(11) Activate miracle")) - print(_("(12) Military actions")) - print(_("(13) See movements")) - print(_("(14) Construct building")) - print(_("(15) Update Ikabot")) - print(_("(16) Ikabot Web Server")) - print(_("(17) Auto-Pirate")) - print(_("(18) Investigate")) - print(_("(19) Attack barbarians")) - print(_("(20) Dump / Monitor world")) - print(_("(21) Options / Settings")) + print("(0) Exit") + print("(1) Construction list") + print("(2) Send resources") + print("(3) Distribute resources") + print("(4) Account status") + print("(5) Activate Shrine") + print("(6) Login daily") + print("(7) Alerts / Notifications") + print("(8) Marketplace") + print("(9) Donate") + print("(10) Activate vacation mode") + print("(11) Activate miracle") + print("(12) Military actions") + print("(13) See movements") + print("(14) Construct building") + print("(15) Update Ikabot") + print("(16) Ikabot Web Server") + print("(17) Auto-Pirate") + print("(18) Investigate") + print("(19) Attack barbarians") + print("(20) Dump / Monitor world") + print("(21) Options / Settings") total_options = len(menu_actions) + 1 selected = read(min=0, max=total_options, digit=True, empty=True) @@ -180,9 +175,9 @@ def menu(session, checkUpdate=True): if selected == 7: banner() - print(_("(0) Back")) - print(_("(1) Alert attacks")) - print(_("(2) Alert wine running out")) + print("(0) Back") + print("(1) Alert attacks") + print("(2) Alert wine running out") selected = read(min=0, max=2, digit=True) if selected == 0: @@ -193,9 +188,9 @@ def menu(session, checkUpdate=True): if selected == 8: banner() - print(_("(0) Back")) - print(_("(1) Buy resources")) - print(_("(2) Sell resources")) + print("(0) Back") + print("(1) Buy resources") + print("(2) Sell resources") selected = read(min=0, max=2, digit=True) if selected == 0: @@ -206,9 +201,9 @@ def menu(session, checkUpdate=True): if selected == 9: banner() - print(_("(0) Back")) - print(_("(1) Donate once")) - print(_("(2) Donate automatically")) + print("(0) Back") + print("(1) Donate once") + print("(2) Donate automatically") selected = read(min=0, max=2, digit=True) if selected == 0: @@ -219,9 +214,9 @@ def menu(session, checkUpdate=True): if selected == 12: banner() - print(_("(0) Back")) - print(_("(1) Train Army")) - print(_("(2) Send Troops/Ships")) + print("(0) Back") + print("(1) Train Army") + print("(2) Send Troops/Ships") selected = read(min=0, max=2, digit=True) if selected == 0: menu(session) @@ -230,9 +225,9 @@ def menu(session, checkUpdate=True): selected += 1200 if selected == 20: - print(_("(0) Back")) - print(_("(1) Monitor islands")) - print(_("(2) Dump & Search world")) + print("(0) Back") + print("(1) Monitor islands") + print("(2) Dump & Search world") selected = read(min=0, max=2, digit=True) if selected == 0: @@ -243,18 +238,18 @@ def menu(session, checkUpdate=True): if selected == 21: banner() - print(_("(0) Back")) - print(_("(1) Configure Proxy")) + print("(0) Back") + print("(1) Configure Proxy") if telegramDataIsValid(session): - print(_("(2) Change the Telegram data")) + print("(2) Change the Telegram data") else: - print(_("(2) Enter the Telegram data")) - print(_("(3) Kill tasks")) - print(_("(4) Configure captcha resolver")) - print(_("(5) Logs")) - print(_("(6) Message Telegram Bot")) - print(_("(7) Import / Export cookie")) - print(_("(8) Load custom ikabot module")) + print("(2) Enter the Telegram data") + print("(3) Kill tasks") + print("(4) Configure captcha resolver") + print("(5) Logs") + print("(6) Message Telegram Bot") + print("(7) Import / Export cookie") + print("(8) Load custom ikabot module") selected = read(min=0, max=8, digit=True) if selected == 0: @@ -290,7 +285,7 @@ def menu(session, checkUpdate=True): if isWindows: # in unix, you can exit ikabot and close the terminal and the processes will continue to execute # in windows, you can exit ikabot but if you close the terminal, the processes will die - print(_("Closing this console will kill the processes.")) + print("Closing this console will kill the processes.") enter() clear() os._exit( diff --git a/ikabot/config.py b/ikabot/config.py index 0959729d..e569bd35 100644 --- a/ikabot/config.py +++ b/ikabot/config.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import locale import os @@ -11,16 +10,7 @@ IKABOT_VERSION_TAG = "v" + IKABOT_VERSION -local = locale.setlocale(locale.LC_ALL, "") -if "es_" in local: - languages = ["es"] -else: - languages = ["en"] -languages = ["none"] -localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "locale") -t = gettext.translation("config", localedir, languages=languages, fallback=True) -_ = t.gettext update_msg = "" @@ -42,7 +32,7 @@ city_url = "view=city&cityId=" island_url = "view=island&islandId=" prompt = " >> " -materials_names = [_("Wood"), _("Wine"), _("Marble"), _("Cristal"), _("Sulfur")] +materials_names = ["Wood", "Wine", "Marble", "Cristal", "Sulfur"] materials_names_english = ["Wood", "Wine", "Marble", "Cristal", "Sulfur"] miracle_names_english = [ "", @@ -64,11 +54,11 @@ "9b5578a7dfa3e98124439cca4a387a61", ] tradegoods_names = [ - _("Saw mill"), - _("Vineyard"), - _("Quarry"), - _("Crystal Mine"), - _("Sulfur Pit"), + "Saw mill", + "Vineyard", + "Quarry", + "Crystal Mine", + "Sulfur Pit", ] ConnectionError_wait = 5 * 60 actionRequest = "REQUESTID" diff --git a/ikabot/function/activateMiracle.py b/ikabot/function/activateMiracle.py index efc555b2..d385e93f 100644 --- a/ikabot/function/activateMiracle.py +++ b/ikabot/function/activateMiracle.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import json import traceback @@ -14,11 +13,6 @@ from ikabot.helpers.signals import setInfoSignal from ikabot.helpers.varios import * -t = gettext.translation( - "activateMiracle", localedir, languages=languages, fallback=True -) -_ = t.gettext - def obtainMiraclesAvailable(session): """ @@ -133,18 +127,18 @@ def chooseIsland(islands): ------- island : dict """ - print(_("Which miracle do you want to activate?")) + print("Which miracle do you want to activate?") # Sort islands by name sorted_islands = sorted(islands, key=lambda x: x["wonderName"]) i = 0 - print(_("(0) Exit")) + print("(0) Exit") for island in sorted_islands: i += 1 if island["available"]: print("({:d}) {}".format(i, island["wonderName"])) else: print( - _("({:d}) {} (available in: {})").format( + "({:d}) {} (available in: {})".format( i, island["wonderName"], daysHoursMinutes(island["available_in"]) ) ) @@ -172,7 +166,7 @@ def activateMiracle(session, event, stdin_fd, predetermined_input): islands = obtainMiraclesAvailable(session) if islands == []: - print(_("There are no miracles available.")) + print("There are no miracles available.") enter() event.set() return @@ -183,8 +177,8 @@ def activateMiracle(session, event, stdin_fd, predetermined_input): return if island["available"]: - print(_("\nThe miracle {} will be activated").format(island["wonderName"])) - print(_("Proceed? [Y/n]")) + print("\nThe miracle {} will be activated").format(island["wonderName"]) + print("Proceed? [Y/n]") activate_miracle_input = read(values=["y", "Y", "n", "N", ""]) if activate_miracle_input.lower() == "n": event.set() @@ -194,7 +188,7 @@ def activateMiracle(session, event, stdin_fd, predetermined_input): if miracle_activation_result[1][1][0] == "error": print( - _("The miracle {} could not be activated.").format( + "The miracle {} could not be activated.".format( island["wonderName"] ) ) @@ -210,19 +204,19 @@ def activateMiracle(session, event, stdin_fd, predetermined_input): break wait_time = enddate - currentdate - print(_("The miracle {} was activated.").format(island["wonderName"])) + print("The miracle {} was activated.".format(island["wonderName"])) enter() banner() while True: - print(_("Do you wish to activate it again when it is finished? [y/N]")) + print("Do you wish to activate it again when it is finished? [y/N]") reactivate_again_input = read(values=["y", "Y", "n", "N", ""]) if reactivate_again_input.lower() != "y": event.set() return - iterations = read(msg=_("How many times?: "), digit=True, min=0) + iterations = read(msg="How many times?: ", digit=True, min=0) if iterations == 0: event.set() @@ -230,9 +224,9 @@ def activateMiracle(session, event, stdin_fd, predetermined_input): duration = wait_time * iterations - print(_("It will finish in:{}").format(daysHoursMinutes(duration))) + print("It will finish in:{}".format(daysHoursMinutes(duration))) - print(_("Proceed? [Y/n]")) + print("Proceed? [Y/n]") reactivate_again_input = read(values=["y", "Y", "n", "N", ""]) if reactivate_again_input.lower() == "n": banner() @@ -240,11 +234,11 @@ def activateMiracle(session, event, stdin_fd, predetermined_input): break else: print( - _("\nThe miracle {} will be activated in {}").format( + "\nThe miracle {} will be activated in {}".format( island["wonderName"], daysHoursMinutes(island["available_in"]) ) ) - print(_("Proceed? [Y/n]")) + print("Proceed? [Y/n]") user_confirm = read(values=["y", "Y", "n", "N", ""]) if user_confirm.lower() == "n": event.set() @@ -252,18 +246,18 @@ def activateMiracle(session, event, stdin_fd, predetermined_input): wait_time = island["available_in"] iterations = 1 - print(_("\nThe mirable will be activated.")) + print("\nThe mirable will be activated.") enter() banner() while True: - print(_("Do you wish to activate it again when it is finished? [y/N]")) + print("Do you wish to activate it again when it is finished? [y/N]") reactivate_again_input = read(values=["y", "Y", "n", "N", ""]) again = reactivate_again_input.lower() == "y" if again is True: try: - iterations = read(msg=_("How many times?: "), digit=True, min=0) + iterations = read(msg="How many times?: ", digit=True, min=0) except KeyboardInterrupt: iterations = 1 break @@ -275,11 +269,10 @@ def activateMiracle(session, event, stdin_fd, predetermined_input): iterations += 1 duration = wait_time * iterations print( - _( - "It is not possible to calculate the time of finalization. (at least: {})" - ).format(daysHoursMinutes(duration)) + + "It is not possible to calculate the time of finalization. (at least: {})".format(daysHoursMinutes(duration)) ) - print(_("Proceed? [Y/n]")) + print("Proceed? [Y/n]") try: activate_input = read(values=["y", "Y", "n", "N", ""]) @@ -299,14 +292,14 @@ def activateMiracle(session, event, stdin_fd, predetermined_input): set_child_mode(session) event.set() - info = _("\nI activate the miracle {} {:d} times\n").format( + info = "\nI activate the miracle {} {:d} times\n".format( island["wonderName"], iterations ) setInfoSignal(session, info) try: do_it(session, island, iterations) except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) finally: session.logout() @@ -348,7 +341,7 @@ def wait_for_miracle(session, island): else: wait_time = 60 - msg = _("I wait {:d} seconds to activate the miracle {}").format( + msg = "I wait {:d} seconds to activate the miracle {}".format( wait_time, island["wonderName"] ) sendToBotDebug(session, msg, debugON_activateMiracle) @@ -371,7 +364,7 @@ def do_it(session, island, iterations): response = activateMiracleHttpCall(session, island) if response[1][1][0] == "error": - msg = _("The miracle {} could not be activated.").format( + msg = "The miracle {} could not be activated.".format( island["wonderName"] ) sendToBot(session, msg) @@ -380,5 +373,5 @@ def do_it(session, island, iterations): session.setStatus( f"Activated {island['wonderName']} @{getDateTime()}, iterations left: {iterations_left}" ) - msg = _("Miracle {} successfully activated").format(island["wonderName"]) + msg = "Miracle {} successfully activated".format(island["wonderName"]) sendToBotDebug(session, msg, debugON_activateMiracle) diff --git a/ikabot/function/alertAttacks.py b/ikabot/function/alertAttacks.py index 6be65c11..53e3fe7d 100644 --- a/ikabot/function/alertAttacks.py +++ b/ikabot/function/alertAttacks.py @@ -12,9 +12,6 @@ from ikabot.helpers.signals import setInfoSignal from ikabot.helpers.varios import daysHoursMinutes -t = gettext.translation("alertAttacks", localedir, languages=languages, fallback=True) -_ = t.gettext - def alertAttacks(session, event, stdin_fd, predetermined_input): """ @@ -35,14 +32,13 @@ def alertAttacks(session, event, stdin_fd, predetermined_input): banner() default = 20 minutes = read( - msg=_( - "How often should I search for attacks?(min:3, default: {:d}): " - ).format(default), + msg= + "How often should I search for attacks?(min:3, default: {:d}): ".format(default), min=3, default=default, ) # min_units = read(msg=_('Attacks with less than how many units should be ignored? (default: 0): '), digit=True, default=0) - print(_("I will check for attacks every {:d} minutes").format(minutes)) + print("I will check for attacks every {:d} minutes".format(minutes)) enter() except KeyboardInterrupt: event.set() @@ -51,12 +47,12 @@ def alertAttacks(session, event, stdin_fd, predetermined_input): set_child_mode(session) event.set() - info = _("\nI check for attacks every {:d} minutes\n").format(minutes) + info = "\nI check for attacks every {:d} minutes\n".format(minutes) setInfoSignal(session, info) try: do_it(session, minutes) except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) finally: session.logout() @@ -92,7 +88,7 @@ def respondToAttack(session): # mv activateVacationMode(session) else: - sendToBot(session, _("Invalid command: {:d}").format(action)) + sendToBot(session, "Invalid command: {:d}".format(action)) def do_it(session, minutes): @@ -143,22 +139,22 @@ def do_it(session, minutes): timeLeft = int(militaryMovement["eventTime"]) - timeNow # send alert - msg = _("-- ALERT --\n") + msg = "-- ALERT --\n" msg += missionText + "\n" - msg += _("from the city {} of {}\n").format( + msg += "from the city {} of {}\n".format( origin["name"], origin["avatarName"] ) - msg += _("a {}\n").format(target["name"]) - msg += _("{} units\n").format(amountTroops) - msg += _("{} fleet\n").format(amountFleets) - msg += _("arrival in: {}\n").format(daysHoursMinutes(timeLeft)) - msg += _("If you want to put the account in vacation mode send:\n") - msg += _("{:d}:1").format(os.getpid()) + msg += "a {}\n".format(target["name"]) + msg += "{} units\n".format(amountTroops) + msg += "{} fleet\n".format(amountFleets) + msg += "arrival in: {}\n".format(daysHoursMinutes(timeLeft)) + msg += "If you want to put the account in vacation mode send:\n" + msg += "{:d}:1".format(os.getpid()) sendToBot(session, msg) except Exception as e: - info = _("\nI check for attacks every {:d} minutes\n").format(minutes) - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + info = "\nI check for attacks every {:d} minutes\n".format(minutes) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) # remove old attacks from knownAttacks diff --git a/ikabot/function/attackBarbarians.py b/ikabot/function/attackBarbarians.py index f3cdc4bd..60b7f8f1 100644 --- a/ikabot/function/attackBarbarians.py +++ b/ikabot/function/attackBarbarians.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import json import math import re @@ -20,11 +19,6 @@ from ikabot.helpers.signals import setInfoSignal from ikabot.helpers.varios import * -t = gettext.translation( - "attackBarbarians", localedir, languages=languages, fallback=True -) -_ = t.gettext - getcontext().prec = 30 @@ -50,16 +44,16 @@ def choose_island(session): def pad(island_name): return " " * (longest_island_name_length - len(island_name)) + island_name - print(_("In which island do you want to attack the barbarians?")) - print(_(" 0) Exit")) + print("In which island do you want to attack the barbarians?") + print(" 0) Exit") for i, island in enumerate(islands): num = " " + str(i + 1) if i < 9 else str(i + 1) if island["barbarians"]["destroyed"] == 1: - warn = _("(currently destroyed)") + warn = "(currently destroyed)" else: warn = "" print( - _("{}) [{}:{}] {} ({}) : barbarians lv: {} ({}) {}").format( + "{}) [{}:{}] {} ({}) : barbarians lv: {} ({}) {}".format( num, island["x"], island["y"], @@ -195,13 +189,13 @@ def plan_attack(session, city, babarians_info): units_available[unit_id]["name"] = total_units[unit_id]["name"] if len(units_available) == 0: - print(_("No more troops available to send")) + print("No more troops available to send") enter() break attack_round = {} attack_round["units"] = {} - print(_("Which troops do you want to send?")) + print("Which troops do you want to send?") for unit_id in units_available: unit_amount = units_available[unit_id]["amount"] unit_name = units_available[unit_id]["name"] @@ -223,9 +217,9 @@ def plan_attack(session, city, babarians_info): if len(plan) > 0: round_def = len(plan) + 1 attack_round["round"] = read( - msg=_( + msg= "In which battle round do you want to send them? (min: 2, default: {:d}): " - ).format(round_def), + .format(round_def), min=2, default=round_def, ) @@ -239,9 +233,9 @@ def plan_attack(session, city, babarians_info): max_ships = total_ships - sum([ar["ships"] for ar in plan]) if max_ships > 0: attack_round["ships"] = read( - msg=_( + msg= "How many ships do you want to send in this round? (min: 0, max: {:d}): " - ).format(max_ships), + .format(max_ships), min=0, max=max_ships, ) @@ -254,14 +248,14 @@ def plan_attack(session, city, babarians_info): if last: break - print(_("Do you want to send another round of troops? [y/N]")) + print("Do you want to send another round of troops? [y/N]") resp = read(values=["y", "Y", "n", "N"], default="n") if resp.lower() != "y": print("") print( - _( + "Do you want to select the troops that will be used to collect the remaining resources? (they need to destroy the wall) [y/N]" - ) + ) resp = read(values=["y", "Y", "n", "N"], default="n") if resp.lower() != "y": @@ -295,13 +289,13 @@ def attackBarbarians(session, event, stdin_fd, predetermined_input): babarians_info = get_barbarians_lv(session, island) banner() - print(_("The barbarians have:")) + print("The barbarians have:") for name, amount in babarians_info["troops"]: - print(_("{} units of {}").format(amount, name)) + print("{} units of {}".format(amount, name)) print("") banner() - print(_("From which city do you want to attack?")) + print("From which city do you want to attack?") city = chooseCity(session) plan = plan_attack(session, city, babarians_info) @@ -311,7 +305,7 @@ def attackBarbarians(session, event, stdin_fd, predetermined_input): banner() print( - _("The barbarians in [{}:{}] will be attacked.").format( + "The barbarians in [{}:{}] will be attacked.".format( island["x"], island["y"] ) ) @@ -324,12 +318,12 @@ def attackBarbarians(session, event, stdin_fd, predetermined_input): set_child_mode(session) event.set() - info = _("\nI attack the barbarians in [{}:{}]\n").format(island["x"], island["y"]) + info = "\nI attack the barbarians in [{}:{}]\n".format(island["x"], island["y"]) setInfoSignal(session, info) try: do_it(session, island, city, babarians_info, plan) except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) finally: session.logout() diff --git a/ikabot/function/autoPirate.py b/ikabot/function/autoPirate.py index 86d4bf2f..f5d4dd35 100644 --- a/ikabot/function/autoPirate.py +++ b/ikabot/function/autoPirate.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import re import sys import time @@ -18,8 +17,6 @@ from ikabot.helpers.varios import timeStringToSec, wait from ikabot.helpers.apiComm import getPiratesCaptchaSolution -t = gettext.translation("buyResources", localedir, languages=languages, fallback=True) -_ = t.gettext def autoPirate(session, event, stdin_fd, predetermined_input): @@ -251,7 +248,7 @@ def autoPirate(session, event, stdin_fd, predetermined_input): break except Exception: info = "" - msg = _("Error in:\n{}\nCause:\n{}").format( + msg = "Error in:\n{}\nCause:\n{}".format( info, traceback.format_exc() ) sendToBot(session, msg) @@ -262,7 +259,7 @@ def autoPirate(session, event, stdin_fd, predetermined_input): except Exception: info = "" - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) event.set() return diff --git a/ikabot/function/buyResources.py b/ikabot/function/buyResources.py index de179bbe..83720255 100644 --- a/ikabot/function/buyResources.py +++ b/ikabot/function/buyResources.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import json import math import re @@ -21,8 +20,6 @@ from ikabot.helpers.signals import setInfoSignal from ikabot.helpers.varios import addThousandSeparator -t = gettext.translation("buyResources", localedir, languages=languages, fallback=True) -_ = t.gettext def chooseResource(session, city): @@ -32,7 +29,7 @@ def chooseResource(session, city): session : ikabot.web.session.Session city : dict """ - print(_("Which resource do you want to buy?")) + print("Which resource do you want to buy?") for index, material_name in enumerate(materials_names): print("({:d}) {}".format(index + 1, material_name)) choise = read(min=1, max=5) @@ -150,7 +147,7 @@ def chooseCommertialCity(commercial_cities): ------- commercial_city : dict """ - print(_("From which city do you want to buy resources?\n")) + print("From which city do you want to buy resources?\n") for i, city in enumerate(commercial_cities): print("({:d}) {}".format(i + 1, city["name"])) selected_city_index = read(min=1, max=len(commercial_cities)) @@ -174,7 +171,7 @@ def buyResources(session, event, stdin_fd, predetermined_input): # get all the cities with a store commercial_cities = getCommercialCities(session) if len(commercial_cities) == 0: - print(_("There is no store build")) + print("There is no store build") enter() event.set() return @@ -193,7 +190,7 @@ def buyResources(session, event, stdin_fd, predetermined_input): # get all the offers of the chosen resource from the chosen city offers = getOffers(session, city) if len(offers) == 0: - print(_("There are no offers available.")) + print("There are no offers available.") enter() event.set() return @@ -205,30 +202,30 @@ def buyResources(session, event, stdin_fd, predetermined_input): amount = offer["amountAvailable"] price = offer["precio"] cost = amount * price - print(_("amount:{}").format(addThousandSeparator(amount))) - print(_("price :{:d}").format(price)) - print(_("cost :{}").format(addThousandSeparator(cost))) + print("amount:{}".format(addThousandSeparator(amount))) + print("price :{:d}".format(price)) + print("cost :{}".format(addThousandSeparator(cost))) print("") total_price += cost total_amount += amount # ask how much to buy print( - _("Total amount available to purchase: {}, for {}").format( + "Total amount available to purchase: {}, for {}".format( addThousandSeparator(total_amount), addThousandSeparator(total_price) ) ) available = city["freeSpaceForResources"][resource] if available < total_amount: print( - _("You just can buy {} due to storing capacity").format( + "You just can buy {} due to storing capacity".format( addThousandSeparator(available) ) ) total_amount = available print("") amount_to_buy = read( - msg=_("How much do you want to buy?: "), min=0, max=total_amount + msg="How much do you want to buy?: ", min=0, max=total_amount ) if amount_to_buy == 0: event.set() @@ -239,19 +236,19 @@ def buyResources(session, event, stdin_fd, predetermined_input): total_cost = calculateCost(offers, amount_to_buy) print( - _("\nCurrent gold: {}.\nTotal cost : {}.\nFinal gold : {}.").format( + "\nCurrent gold: {}.\nTotal cost : {}.\nFinal gold : {}.".format( addThousandSeparator(gold), addThousandSeparator(total_cost), addThousandSeparator(gold - total_cost), ) ) - print(_("Proceed? [Y/n]")) + print("Proceed? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "n": event.set() return - print(_("It will be purchased {}").format(addThousandSeparator(amount_to_buy))) + print("It will be purchased {}".format(addThousandSeparator(amount_to_buy))) enter() except KeyboardInterrupt: event.set() @@ -260,14 +257,14 @@ def buyResources(session, event, stdin_fd, predetermined_input): set_child_mode(session) event.set() - info = _("\nI will buy {} from {} to {}\n").format( + info = "\nI will buy {} from {} to {}\n".format( addThousandSeparator(amount_to_buy), materials_names[resource], city["cityName"] ) setInfoSignal(session, info) try: do_it(session, city, offers, amount_to_buy) except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) finally: session.logout() @@ -333,7 +330,7 @@ def buy(session, city, offer, amount_to_buy, ships_available): else: data_dict["cargo_tradegood{}".format(resource)] = amount_to_buy session.post(params=data_dict) - msg = _("I buy {} to {} from {}").format( + msg = "I buy {} to {} from {}".format( addThousandSeparator(amount_to_buy), offer["ciudadDestino"], offer["jugadorAComprar"], diff --git a/ikabot/function/checkForUpdate.py b/ikabot/function/checkForUpdate.py index b5305603..6b0f0019 100644 --- a/ikabot/function/checkForUpdate.py +++ b/ikabot/function/checkForUpdate.py @@ -1,17 +1,11 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import re import ikabot.config as config from ikabot.helpers.process import run -t = gettext.translation( - "checkForUpdate", config.localedir, languages=config.languages, fallback=True -) -_ = t.gettext - def checkForUpdate(): upgrade = run("python3 -m pip search ikabot") @@ -28,4 +22,4 @@ def checkForUpdate(): return new = match.group(1) - config.update_msg = _("[+] ikabot version {} is available\n").format(new) + config.update_msg = "[+] ikabot version {} is available\n".format(new) diff --git a/ikabot/function/constructBuilding.py b/ikabot/function/constructBuilding.py index 33d6232e..35400846 100644 --- a/ikabot/function/constructBuilding.py +++ b/ikabot/function/constructBuilding.py @@ -1,7 +1,7 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext + import json import re @@ -9,10 +9,6 @@ from ikabot.helpers.gui import * from ikabot.helpers.pedirInfo import * -t = gettext.translation( - "constructBuilding", localedir, languages=languages, fallback=True -) -_ = t.gettext def constructBuilding(session, event, stdin_fd, predetermined_input): @@ -29,7 +25,7 @@ def constructBuilding(session, event, stdin_fd, predetermined_input): try: banner() - print(_("City where to build:")) + print("City where to build:") city = chooseCity(session) banner() @@ -83,13 +79,13 @@ def constructBuilding(session, event, stdin_fd, predetermined_input): ) if len(buildings) == 0: - print(_("No building can be built.")) + print("No building can be built.") enter() event.set() return # show list of buildings to the user - print(_("What building do you want to build?\n")) + print("What building do you want to build?\n") i = 0 for building in buildings: i += 1 @@ -109,7 +105,7 @@ def constructBuilding(session, event, stdin_fd, predetermined_input): if len(options) == 1: option = options[0] else: - print(_("In which position do you want to build?\n")) + print("In which position do you want to build?\n") i = 0 for option in options: i += 1 diff --git a/ikabot/function/constructionList.py b/ikabot/function/constructionList.py index b753f36b..9d67613a 100644 --- a/ikabot/function/constructionList.py +++ b/ikabot/function/constructionList.py @@ -1,7 +1,7 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext + import hashlib import json import math @@ -27,11 +27,6 @@ from ikabot.helpers.varios import * from ikabot.web.session import normal_get -t = gettext.translation( - "constructionList", localedir, languages=languages, fallback=True -) -_ = t.gettext - sendResources = True expand = True thread = None @@ -67,7 +62,7 @@ def waitForConstruction(session, city_id, final_lvl): final_time = int(construction_time) seconds_to_wait = final_time - current_time - msg = _("{}: I wait {:d} seconds so that {} gets to the level {:d}").format( + msg = "{}: I wait {:d} seconds so that {} gets to the level {:d}".format( city["cityName"], seconds_to_wait, construction_building["name"], @@ -120,10 +115,10 @@ def expandBuilding(session, cityId, building, waitForResources): wait(seconds + 5) if building["canUpgrade"] is False: - msg = _("City:{}\n").format(city["cityName"]) - msg += _("Building:{}\n").format(building["name"]) - msg += _("The building could not be completed due to lack of resources.\n") - msg += _("Missed {:d} levels").format(levels_to_upgrade - lv) + msg = "City:{}\n".format(city["cityName"]) + msg += "Building:{}\n".format(building["name"]) + msg += "The building could not be completed due to lack of resources.\n" + msg += "Missed {:d} levels".format(levels_to_upgrade - lv) sendToBot(session, msg) return @@ -140,19 +135,19 @@ def expandBuilding(session, cityId, building, waitForResources): city = getCity(html) building = city["position"][position] if building["isBusy"] is False: - msg = _("{}: The building {} was not extended").format( + msg = "{}: The building {} was not extended".format( city["cityName"], building["name"] ) sendToBot(session, msg) sendToBot(session, resp) return - msg = _("{}: The building {} is being extended to level {:d}.").format( + msg = "{}: The building {} is being extended to level {:d}.".format( city["cityName"], building["name"], building["level"] + 1 ) sendToBotDebug(session, msg, debugON_constructionList) - msg = _("{}: The building {} finished extending to level: {:d}.").format( + msg = "{}: The building {} finished extending to level: {:d}.".format( city["cityName"], building["name"], building["level"] + 1 ) sendToBotDebug(session, msg, debugON_constructionList) @@ -319,11 +314,11 @@ def getResourcesNeeded(session, city, building, current_level, final_level): if levels_to_upgrade < final_level - current_level: print( - _("This building only allows you to expand {:d} more levels").format( + "This building only allows you to expand {:d} more levels".format( levels_to_upgrade ) ) - msg = _("Expand {:d} levels? [Y/n]:").format(levels_to_upgrade) + msg = "Expand {:d} levels? [Y/n]:".format(levels_to_upgrade) rta = read(msg=msg, values=["Y", "y", "N", "n", ""]) if rta.lower() == "n": return [-1, -1, -1, -1, -1] @@ -341,7 +336,7 @@ def sendResourcesNeeded(session, destination_city_id, city_origins, missing_reso missing_resources : dict[int, int] """ - info = _("\nTransport resources to upload building\n") + info = "\nTransport resources to upload building\n" try: routes = [] @@ -366,7 +361,7 @@ def sendResourcesNeeded(session, destination_city_id, city_origins, missing_reso routes.append(route) executeRoutes(session, routes, useFreighters) except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) # no s.logout() because this is a thread, not a process @@ -388,7 +383,7 @@ def chooseResourceProviders(session, cities_ids, cities, city_id, resource, miss expand = True banner() - print(_("From what cities obtain {}?").format(materials_names[resource].lower())) + print("From what cities obtain {}?".format(materials_names[resource].lower())) tradegood_initials = [material_name[0] for material_name in materials_names] maxName = max( @@ -431,15 +426,15 @@ def chooseResourceProviders(session, cities_ids, cities, city_id, resource, miss return origin_cities # if we reach this part, there are not enough resources to expand the building - print(_("\nThere are not enough resources.")) + print("\nThere are not enough resources.") if len(origin_cities) > 0: - print(_("\nSend the resources anyway? [Y/n]")) + print("\nSend the resources anyway? [Y/n]") choice = read(values=["y", "Y", "n", "N", ""]) if choice.lower() == "n": sendResources = False - print(_("\nTry to expand the building anyway? [y/N]")) + print("\nTry to expand the building anyway? [y/N]") choice = read(values=["y", "Y", "n", "N", ""]) if choice.lower() == "n" or choice == "": expand = False @@ -467,7 +462,7 @@ def sendResourcesMenu(session, city_id, missing, useFreighters=False): session, cities_ids, cities, city_id, resource, missing[resource] ) if sendResources is False and expand: - print(_("\nThe building will be expanded if possible.")) + print("\nThe building will be expanded if possible.") enter() return elif sendResources is False: @@ -476,12 +471,12 @@ def sendResourcesMenu(session, city_id, missing, useFreighters=False): if expand: print( - _( + "\nThe resources will be sent and the building will be expanded if possible." - ) + ) else: - print(_("\nThe resources will be sent.")) + print("\nThe resources will be sent.") enter() @@ -515,8 +510,8 @@ def getBuildingsToExpand(session, cityId): banner() # show the buildings available to expand (ignore empty spaces) - print(_("Which buildings do you want to expand? Separate numbers with commas (7, 1, 3, 5, ...)\n")) - print(_("(0)\t\texit")) + print("Which buildings do you want to expand? Separate numbers with commas (7, 1, 3, 5, ...)\n") + print("(0)\t\texit") buildings = [ building for building in city["position"] if building["name"] != "empty" ] @@ -537,7 +532,7 @@ def getBuildingsToExpand(session, cityId): level = str(level) if building["isBusy"]: level = level + "+" - print(_("({:d})\tlv:{}\t{}{}{}").format(i + 1, level, color, building["name"], bcolors.ENDC)) + print("({:d})\tlv:{}\t{}{}{}").format(i + 1, level, color, building["name"], bcolors.ENDC) selected_building_ids = read().split(",") selected_building_ids = [int(id.strip()) for id in selected_building_ids if id.strip().isdigit()] @@ -555,10 +550,10 @@ def getBuildingsToExpand(session, cityId): current_level += 1 banner() - print(_("building:{}").format(building["name"])) - print(_("current level:{}").format(current_level)) + print("building:{}").format(building["name"]) + print("current level:{}").format(current_level) - final_level = read(min=current_level, msg=_("increase to level:")) + final_level = read(min=current_level, msg="increase to level:") building["upgradeTo"] = final_level selected_buildings.append(building) @@ -604,7 +599,7 @@ def constructionList(session, event, stdin_fd, predetermined_input): banner() wait_resources = False - print(_("In which city do you want to expand buildings?")) + print("In which city do you want to expand buildings?") city = chooseCity(session) cityId = city["id"] buildings = getBuildingsToExpand(session, cityId) @@ -643,27 +638,27 @@ def constructionList(session, event, stdin_fd, predetermined_input): # show missing resources to the user if sum(missing) > 0: - print(_("\nMissing:")) + print("\nMissing:") for i in range(len(materials_names)): if missing[i] == 0: continue name = materials_names[i].lower() - print(_("{} of {}").format(addThousandSeparator(missing[i]), name)) + print("{} of {}").format(addThousandSeparator(missing[i]), name) print("") # if the user wants, send the resources from the selected cities - print(_("Automatically transport resources? [Y/n]")) + print("Automatically transport resources? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "n": - print(_("Proceed anyway? [Y/n]")) + print("Proceed anyway? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "n": event.set() return else: - print(_("What type of ships do you want to use? (Default: Trade ships)")) - print(_("(1) Trade ships")) - print(_("(2) Freighters")) + print("What type of ships do you want to use? (Default: Trade ships)") + print("(1) Trade ships") + print("(2) Freighters") shiptype = read(min=1, max=2, digit=True, empty=True) if shiptype == '': shiptype = 1 @@ -674,8 +669,8 @@ def constructionList(session, event, stdin_fd, predetermined_input): wait_resources = True sendResourcesMenu(session, cityId, missing, useFreighters) else: - print(_("\nYou have enough materials")) - print(_("Proceed? [Y/n]")) + print("\nYou have enough materials") + print("Proceed? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "n": event.set() @@ -687,8 +682,8 @@ def constructionList(session, event, stdin_fd, predetermined_input): set_child_mode(session) event.set() - info = _("\nUpgrade building\n") - info = info + _("City: {}\nBuilding: {}. From {:d}, to {:d}").format( + info = "\nUpgrade building\n" + info = info + "City: {}\nBuilding: {}. From {:d}, to {:d}".format( city["cityName"], building["name"], current_level, final_level ) @@ -700,7 +695,7 @@ def constructionList(session, event, stdin_fd, predetermined_input): elif thread: thread.join() except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) finally: session.logout() diff --git a/ikabot/function/decaptchaConf.py b/ikabot/function/decaptchaConf.py index f0a0dd0a..84877dcb 100644 --- a/ikabot/function/decaptchaConf.py +++ b/ikabot/function/decaptchaConf.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- import base64 -import gettext import sys import time @@ -13,9 +12,6 @@ from ikabot.helpers.pedirInfo import enter, read from ikabot.helpers.process import run, updateProcessList -t = gettext.translation("killTasks", localedir, languages=languages, fallback=True) -_ = t.gettext - decaptcha_test_pictures = [ { "ground_truth": "WURY5G", diff --git a/ikabot/function/distributeResources.py b/ikabot/function/distributeResources.py index 5753e6cd..12eca5d6 100644 --- a/ikabot/function/distributeResources.py +++ b/ikabot/function/distributeResources.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import traceback from ikabot.config import * @@ -15,11 +14,6 @@ from ikabot.helpers.signals import setInfoSignal from ikabot.helpers.varios import addThousandSeparator -t = gettext.translation( - "distributeResources", localedir, languages=languages, fallback=True -) -_ = t.gettext - def distributeResources(session, event, stdin_fd, predetermined_input): """ @@ -35,9 +29,9 @@ def distributeResources(session, event, stdin_fd, predetermined_input): try: banner() - print(_("What type of ships do you want to use? (Default: Trade ships)")) - print(_("(1) Trade ships")) - print(_("(2) Freighters")) + print("What type of ships do you want to use? (Default: Trade ships)") + print("(1) Trade ships") + print("(2) Freighters") shiptype = read(min=1, max=2, digit=True, empty=True) if shiptype == '': shiptype = 1 @@ -45,8 +39,8 @@ def distributeResources(session, event, stdin_fd, predetermined_input): useFreighters = False elif shiptype == 2: useFreighters = True - print(_("What resource do you want to distribute?")) - print(_("(0) Exit")) + print("What resource do you want to distribute?") + print("(0) Exit") for i in range(len(materials_names)): print("({:d}) {}".format(i + 1, materials_names[i])) resource = read(min=0, max=5) @@ -98,7 +92,7 @@ def distributeResources(session, event, stdin_fd, predetermined_input): return banner() - print(_("\nThe following shipments will be made:\n")) + print("\nThe following shipments will be made:\n") for route in routes: print( "{} -> {} : {} {}".format( @@ -109,7 +103,7 @@ def distributeResources(session, event, stdin_fd, predetermined_input): ) ) # displays all routes to be executed in console - print(_("\nProceed? [Y/n]")) + print("\nProceed? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "n": event.set() @@ -122,13 +116,13 @@ def distributeResources(session, event, stdin_fd, predetermined_input): set_child_mode(session) event.set() # this is where we give back control to main process - info = _("\nDistribute {}\n").format(materials_names[resource]) + info = "\nDistribute {}\n".format(materials_names[resource]) setInfoSignal(session, info) try: executeRoutes(session, routes, useFreighters) # plan trips for all the routes except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) # sends message to telegram bot finally: session.logout() @@ -302,11 +296,11 @@ def distribute_unevenly(session, resource_type, cities_ids, cities): destination_cities[destination_city_id] = city if total_available_resources_from_all_cities <= 0: - print(_("\nThere are no resources to send.")) + print("\nThere are no resources to send.") enter() return None if len(destination_cities) == 0: - print(_("\nThere is no space available to send resources.")) + print("\nThere is no space available to send resources.") enter() return None diff --git a/ikabot/function/donate.py b/ikabot/function/donate.py index c81d67c1..3e2228f4 100644 --- a/ikabot/function/donate.py +++ b/ikabot/function/donate.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import json import re @@ -12,9 +11,6 @@ from ikabot.helpers.resources import * from ikabot.helpers.varios import * -t = gettext.translation("donate", localedir, languages=languages, fallback=True) -_ = t.gettext - def donate(session, event, stdin_fd, predetermined_input): """ @@ -62,13 +58,13 @@ def donate(session, event, stdin_fd, predetermined_input): tradegoodUpgrading = tradegoodEndUpgradeTime > 0 if resourceUpgrading: - resourceUpgradeMsg = _("(upgrading, ends in:{})").format( + resourceUpgradeMsg = "(upgrading, ends in:{})".format( daysHoursMinutes(resourceEndUpgradeTime) ) else: resourceUpgradeMsg = "" if tradegoodUpgrading: - tradegoodUpgradeMsg = _("(upgrading, ends in:{})").format( + tradegoodUpgradeMsg = "(upgrading, ends in:{})".format( daysHoursMinutes(tradegoodEndUpgradeTime) ) else: @@ -85,14 +81,14 @@ def donate(session, event, stdin_fd, predetermined_input): if resourceUpgrading and tradegoodUpgrading: print( - _( - "Both the {} (ends in:{}) and the {} (ends in:{}) are being upgraded rigth now.\n".format( - resource_name, - daysHoursMinutes(resourceEndUpgradeTime), - tradegood_name, - daysHoursMinutes(tradegoodEndUpgradeTime), - ) + + "Both the {} (ends in:{}) and the {} (ends in:{}) are being upgraded rigth now.\n".format( + resource_name, + daysHoursMinutes(resourceEndUpgradeTime), + tradegood_name, + daysHoursMinutes(tradegoodEndUpgradeTime), ) + ) enter() event.set() @@ -136,10 +132,10 @@ def donate(session, event, stdin_fd, predetermined_input): ) ) - print(_("Wood available:{}\n").format(addThousandSeparator(woodAvailable))) + print("Wood available:{}\n".format(addThousandSeparator(woodAvailable))) if resourceUpgrading is False and tradegoodUpgrading is False: - msg = _("Donate to {} (1) or {} (2)?:").format( + msg = "Donate to {} (1) or {} (2)?:".format( resource_name, tradegood_name ) donation_type = read(msg=msg, min=1, max=2) @@ -161,7 +157,7 @@ def donate(session, event, stdin_fd, predetermined_input): max=woodAvailable, default=0, additionalValues=["all", "half"], - msg=_("Amount (number, all, half):"), + msg="Amount (number, all, half):", ) if amount == "all": amount = woodAvailable @@ -170,8 +166,8 @@ def donate(session, event, stdin_fd, predetermined_input): elif amount == 0: event.set() return - print(_("Will donate {} to the {}?").format(addThousandSeparator(amount), name)) - print(_("\nProceed? [Y/n]")) + print("Will donate {} to the {}?").format(addThousandSeparator(amount), name) + print("\nProceed? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "n": event.set() diff --git a/ikabot/function/donationBot.py b/ikabot/function/donationBot.py index ca8560c5..4f7afc01 100644 --- a/ikabot/function/donationBot.py +++ b/ikabot/function/donationBot.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import time import traceback @@ -15,9 +14,6 @@ from ikabot.helpers.signals import setInfoSignal from ikabot.helpers.varios import wait, getDateTime -t = gettext.translation("donationBot", localedir, languages=languages, fallback=True) -_ = t.gettext - def donationBot(session, event, stdin_fd, predetermined_input): """ @@ -55,14 +51,13 @@ def donationBot(session, event, stdin_fd, predetermined_input): tradegood = cities[cityId]["tradegood"] initial = initials[int(tradegood)] print( - _( - "In {} ({}), Do you wish to donate to the forest, to the trading good, to both or none? [f/t/b/n]" - ).format(cities[cityId]["name"], initial) + + "In {} ({}), Do you wish to donate to the forest, to the trading good, to both or none? [f/t/b/n]".format(cities[cityId]["name"], initial) ) - f = _("f") - t = _("t") - b = _("b") - n = _("n") + f = "f" + t = "t" + b = "b" + n = "n" rta = read(values=[f, f.upper(), t, t.upper(), b, b.upper(), n, n.upper()]) if rta.lower() == f: @@ -77,9 +72,9 @@ def donationBot(session, event, stdin_fd, predetermined_input): if donation_type is not None and donate_method == 1: print( - _( - "What is the maximum percentage of your storage capacity that you wish to keep occupied? (the resources that exceed it, will be donated) (default: 80%)" - ) + + "What is the maximum percentage of your storage capacity that you wish to keep occupied? (the resources that exceed it, will be donated) (default: 80%)" + ) percentage = read(min=0, max=100, empty=True) if percentage == "": @@ -90,9 +85,9 @@ def donationBot(session, event, stdin_fd, predetermined_input): donation_type = None elif donation_type is not None and donate_method == 2: print( - _( - "What is the percentage of your production that you wish to donate? (enter 0 to disable donation for the town) (default: 50%)" - ) + + "What is the percentage of your production that you wish to donate? (enter 0 to disable donation for the town) (default: 50%)" + ) percentage = read( min=0, max=100, empty=True @@ -103,9 +98,9 @@ def donationBot(session, event, stdin_fd, predetermined_input): donation_type = None elif donation_type is not None and donate_method == 3: print( - _( - "What is the amount would you like to donate? (enter 0 to disable donation for the town) (default: 10000)" - ) + + "What is the amount would you like to donate? (enter 0 to disable donation for the town) (default: 10000)" + ) percentage = read( min=0, empty=True @@ -120,7 +115,7 @@ def donationBot(session, event, stdin_fd, predetermined_input): "percentage": percentage, } - print(_("I will donate every {} minutes.".format(waiting_time))) + print("I will donate every {} minutes.".format(waiting_time)) enter() except KeyboardInterrupt: event.set() @@ -129,7 +124,7 @@ def donationBot(session, event, stdin_fd, predetermined_input): set_child_mode(session) event.set() - info = _("\nI donate every {} minutes\n".format(waiting_time)) + info = "\nI donate every {} minutes\n".format(waiting_time) setInfoSignal(session, info) try: do_it( @@ -141,7 +136,7 @@ def donationBot(session, event, stdin_fd, predetermined_input): donate_method, ) except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) finally: session.logout() @@ -270,7 +265,7 @@ def do_it( session.setStatus( f"Donated {total_donated} wood @{getDateTime()}" ) - msg = _("I donated automatically.") + msg = "I donated automatically." sendToBotDebug(session, msg, debugON_donationBot) # sleep a day diff --git a/ikabot/function/dumpWorld.py b/ikabot/function/dumpWorld.py index e0526d83..c632d32f 100644 --- a/ikabot/function/dumpWorld.py +++ b/ikabot/function/dumpWorld.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- import ast -import gettext import gzip import json import os @@ -22,9 +21,6 @@ from ikabot.helpers.signals import setInfoSignal from ikabot.helpers.varios import getDateTime, wait -t = gettext.translation("dumpWorld", localedir, languages=languages, fallback=True) -_ = t.gettext - LINE_UP = "\033[1A" LINE_CLEAR = "\x1b[2K" # status, history, start_time @@ -103,7 +99,7 @@ def dumpWorld(session, event, stdin_fd, predetermined_input): thread = threading.Thread(target=update_terminal, args=(shared_data,), daemon=True) thread.start() set_child_mode(session) - info = _("\nDumped world data\n") + info = "\nDumped world data\n" setInfoSignal(session, info) dump_path = do_it( @@ -130,7 +126,7 @@ def dumpWorld(session, event, stdin_fd, predetermined_input): shared_data[3].set() shared_data[4].acquire(timeout=10) event.set() - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) return diff --git a/ikabot/function/getStatus.py b/ikabot/function/getStatus.py index e4f11b58..473ed5ed 100644 --- a/ikabot/function/getStatus.py +++ b/ikabot/function/getStatus.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import os import re from decimal import * @@ -15,9 +14,6 @@ from ikabot.helpers.resources import * from ikabot.helpers.varios import * -t = gettext.translation("getStatus", localedir, languages=languages, fallback=True) -_ = t.gettext - getcontext().prec = 30 @@ -84,8 +80,8 @@ def getStatus(session, event, stdin_fd, predetermined_input): + json_data["upkeep"] ) ) - print(_("Ships {:d}/{:d}").format(int(available_ships), int(total_ships))) - print(_("\nTotal:")) + print("Ships {:d}/{:d}".format(int(available_ships), int(total_ships))) + print("\nTotal:") print("{:>10}".format(" "), end="|") for i in range(len(materials_names)): print("{:>12}".format(materials_names_english[i]), end="|") @@ -115,7 +111,7 @@ def getStatus(session, event, stdin_fd, predetermined_input): end="", ) - print(_("\nOf which city do you want to see the state?")) + print("\nOf which city do you want to see the state?") city = chooseCity(session) banner() @@ -134,7 +130,7 @@ def getStatus(session, event, stdin_fd, predetermined_input): color_resources.append(bcolors.RED) else: color_resources.append(bcolors.ENDC) - print(_("Population:")) + print("Population:") print( "{}: {} {}: {}".format( "Housing space", @@ -143,8 +139,8 @@ def getStatus(session, event, stdin_fd, predetermined_input): addThousandSeparator(citizens), ) ) - print(_("Storage: {}".format(addThousandSeparator(storageCapacity)))) - print(_("Resources:")) + print("Storage: {}".format(addThousandSeparator(storageCapacity))) + print("Resources:") for i in range(len(materials_names)): print( "{} {}{}{} ".format( @@ -157,7 +153,7 @@ def getStatus(session, event, stdin_fd, predetermined_input): ) print("") - print(_("Production:")) + print("Production:") print( "{}: {} {}: {}".format( materials_names[0], @@ -172,7 +168,7 @@ def getStatus(session, event, stdin_fd, predetermined_input): consumption_per_hour = city["wineConsumptionPerHour"] if consumption_per_hour == 0: print( - _("{}{}Does not consume wine!{}").format( + "{}{}Does not consume wine!{}".format( bcolors.RED, bcolors.BOLD, bcolors.ENDC ) ) @@ -189,7 +185,7 @@ def getStatus(session, event, stdin_fd, predetermined_input): elapsed_time_run_out = daysHoursMinutes( remaining_resources_to_consume ) - print(_("There is wine for: {}").format(elapsed_time_run_out)) + print("There is wine for: {}".format(elapsed_time_run_out)) for building in [ building for building in city["position"] if building["name"] != "empty" @@ -210,7 +206,7 @@ def getStatus(session, event, stdin_fd, predetermined_input): level = level + "+" print( - _("lv:{}\t{}{}{}").format(level, color, building["name"], bcolors.ENDC) + "lv:{}\t{}{}{}".format(level, color, building["name"], bcolors.ENDC) ) enter() diff --git a/ikabot/function/importExportCookie.py b/ikabot/function/importExportCookie.py index 4a05b8d9..33e86178 100644 --- a/ikabot/function/importExportCookie.py +++ b/ikabot/function/importExportCookie.py @@ -1,6 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext + import json import sys @@ -10,8 +10,6 @@ from ikabot.helpers.gui import * from ikabot.helpers.pedirInfo import read -t = gettext.translation("insertCookies", localedir, languages=languages, fallback=True) -_ = t.gettext def importExportCookie(session, event, stdin_fd, predetermined_input): diff --git a/ikabot/function/investigate.py b/ikabot/function/investigate.py index 1e5096f9..161f0972 100644 --- a/ikabot/function/investigate.py +++ b/ikabot/function/investigate.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import json import traceback @@ -14,8 +13,6 @@ from ikabot.helpers.signals import setInfoSignal from ikabot.helpers.varios import * -t = gettext.translation("investigate", localedir, languages=languages, fallback=True) -_ = t.gettext def get_studies(session): @@ -137,12 +134,12 @@ def investigate(session, event, stdin_fd, predetermined_input): available.append(num_study) if len(available) == 0: - print(_("There are no available studies.")) + print("There are no available studies.") enter() event.set() return - print(_("Which one do you wish to study?")) + print("Which one do you wish to study?") print("0) None") for index, num_study in enumerate(available): print( @@ -160,7 +157,7 @@ def investigate(session, event, stdin_fd, predetermined_input): return study(session, studies, available[choice - 1]) - print(_("Done.")) + print("Done.") enter() event.set() else: diff --git a/ikabot/function/killTasks.py b/ikabot/function/killTasks.py index 681ec052..78ffb1c2 100644 --- a/ikabot/function/killTasks.py +++ b/ikabot/function/killTasks.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- import datetime -import gettext import sys from ikabot.config import * @@ -9,9 +8,6 @@ from ikabot.helpers.pedirInfo import enter, read from ikabot.helpers.process import run, updateProcessList -t = gettext.translation("killTasks", localedir, languages=languages, fallback=True) -_ = t.gettext - def killTasks(session, event, stdin_fd, predetermined_input): """ @@ -32,7 +28,7 @@ def killTasks(session, event, stdin_fd, predetermined_input): process for process in process_list if process["action"] != "killTasks" ] if len(process_list) == 0: - print(_("There are no tasks running")) + print("There are no tasks running") enter() event.set() return diff --git a/ikabot/function/loginDaily.py b/ikabot/function/loginDaily.py index 78535092..e3281a48 100644 --- a/ikabot/function/loginDaily.py +++ b/ikabot/function/loginDaily.py @@ -1,7 +1,7 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext + import sys import time import traceback @@ -14,9 +14,6 @@ from ikabot.helpers.signals import setInfoSignal from ikabot.helpers.varios import getDateTime, timeStringToSec, wait -t = gettext.translation("loginDaily", localedir, languages=languages, fallback=True) -_ = t.gettext - earliest_wakeup_time = 24 * 60 * 60 wine_city = wood_city = luxury_city = favour_tasks = None @@ -86,7 +83,7 @@ def modify_tasks(): modify_tasks() - print(_("I will do the thing.")) + print("I will do the thing.") enter() except KeyboardInterrupt: event.set() @@ -95,7 +92,7 @@ def modify_tasks(): set_child_mode(session) event.set() - info = _("\nI enter every day\n") + info = "\nI enter every day\n" setInfoSignal(session, info) try: do_it( @@ -106,7 +103,7 @@ def modify_tasks(): favour_tasks=favour_tasks, ) except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) finally: session.logout() diff --git a/ikabot/function/logs.py b/ikabot/function/logs.py index 92990d36..9edbe61b 100644 --- a/ikabot/function/logs.py +++ b/ikabot/function/logs.py @@ -2,17 +2,12 @@ # -*- coding: utf-8 -*- import logging -import gettext import sys from ikabot.config import * from ikabot.helpers.gui import * from ikabot.helpers.pedirInfo import enter, read -t = gettext.translation("logs", localedir, languages=languages, fallback=True) -_ = t.gettext - - def logs(session, event, stdin_fd, predetermined_input): """ diff --git a/ikabot/function/proxyConf.py b/ikabot/function/proxyConf.py index 8df3673d..f6227bef 100644 --- a/ikabot/function/proxyConf.py +++ b/ikabot/function/proxyConf.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import sys import requests @@ -10,22 +9,17 @@ from ikabot.helpers.gui import * from ikabot.helpers.pedirInfo import read -t = gettext.translation( - "proxy", config.localedir, languages=config.languages, fallback=True -) -_ = t.gettext - def show_proxy(session): session_data = session.getSessionData() - msg = _("using proxy:") + msg = "using proxy:" if "proxy" in session_data and session_data["proxy"]["set"] is True: curr_proxy = session_data["proxy"]["conf"]["https"] if test_proxy(session, session_data["proxy"]["conf"]) is False: session_data["proxy"]["set"] = False session.setSessionData(session_data) sys.exit( - _("the {} proxy does not work, it has been removed").format(curr_proxy) + "the {} proxy does not work, it has been removed".format(curr_proxy) ) if msg not in config.update_msg: # add proxy message @@ -59,17 +53,17 @@ def test_proxy(session, proxy_dict): def read_proxy(session): print( - _( - "Enter the proxy: protocol://username:password@address:port\n(examples: socks5://127.0.0.1:9050, https://45.117.163.22:8080):" - ) + + "Enter the proxy: protocol://username:password@address:port\n(examples: socks5://127.0.0.1:9050, https://45.117.163.22:8080):" + ) proxy_str = read(msg="proxy: ") proxy_dict = {"http": proxy_str, "https": proxy_str} if test_proxy(session, proxy_dict) is False: - print(_("The proxy does not work.")) + print("The proxy does not work.") enter() return None - print(_("The proxy works and it will be used for all future requests sent by new ikabot processes.")) + print("The proxy works and it will be used for all future requests sent by new ikabot processes.") enter() return proxy_dict @@ -88,12 +82,12 @@ def proxyConf(session, event, stdin_fd, predetermined_input): try: banner() print( - _("Warning: The proxy does not apply to the requests sent to the lobby!\n") + "Warning: The proxy does not apply to the requests sent to the lobby!\n" ) session_data = session.getSessionData() if "proxy" not in session_data or session_data["proxy"]["set"] is False: - print(_("Right now, there is no proxy configured.")) + print("Right now, there is no proxy configured.") proxy_dict = read_proxy(session) if proxy_dict is None: event.set() @@ -103,11 +97,11 @@ def proxyConf(session, event, stdin_fd, predetermined_input): session_data["proxy"]["set"] = True else: curr_proxy = session_data["proxy"]["conf"]["https"] - print(_("Current proxy: {}").format(curr_proxy)) - print(_("What do you want to do?")) - print(_("0) Exit")) - print(_("1) Set a new proxy")) - print(_("2) Remove the current proxy")) + print("Current proxy: {}").format(curr_proxy) + print("What do you want to do?") + print("0) Exit") + print("1) Set a new proxy") + print("2) Remove the current proxy") rta = read(min=0, max=2) if rta == 0: @@ -122,7 +116,7 @@ def proxyConf(session, event, stdin_fd, predetermined_input): session_data["proxy"]["set"] = True if rta == 2: session_data["proxy"]["set"] = False - print(_("The proxy has been removed.")) + print("The proxy has been removed.") enter() session.setSessionData(session_data) diff --git a/ikabot/function/searchForIslandSpaces.py b/ikabot/function/searchForIslandSpaces.py index 35edf073..0cc7e72e 100644 --- a/ikabot/function/searchForIslandSpaces.py +++ b/ikabot/function/searchForIslandSpaces.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import sys import time import traceback @@ -15,11 +14,6 @@ from ikabot.helpers.signals import setInfoSignal from ikabot.helpers.varios import getDateTime, wait -t = gettext.translation( - "searchForIslandSpaces", localedir, languages=languages, fallback=True -) -_ = t.gettext - def searchForIslandSpaces(session, event, stdin_fd, predetermined_input): """ @@ -76,7 +70,7 @@ def searchForIslandSpaces(session, event, stdin_fd, predetermined_input): ) fights = read(values=["y", "Y", "n", "N"]) banner() - print(_("I will search for changes in the selected islands")) + print("I will search for changes in the selected islands") enter() except KeyboardInterrupt: event.set() @@ -85,12 +79,12 @@ def searchForIslandSpaces(session, event, stdin_fd, predetermined_input): set_child_mode(session) event.set() - info = _("\nI search for new spaces each hour\n") + info = "\nI search for new spaces each hour\n" setInfoSignal(session, info) try: do_it(session, islandList, time, fights) except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) finally: session.logout() @@ -143,9 +137,7 @@ def do_it(session, islandList, time, fights): city_now["id"] for city_now in cities_now ]: # we didn't find the city_before in the cities_now - msg = _( - "The city {} of the player {} disappeared in {} {}:{} {}" - ).format( + msg = "The city {} of the player {} disappeared in {} {}:{} {}".format( city_before["name"], city_before["Name"], materials_names[int(island["tradegood"])], @@ -164,9 +156,7 @@ def do_it(session, islandList, time, fights): and "armyAction" in city_now["infos"] and city_now["infos"]["armyAction"] == "fight" ): - msg = _( - "A fight started in the city {} of the player {} on island {} {}:{} {}" - ).format( + msg = "A fight started in the city {} of the player {} on island {} {}:{} {}".format( city_before["name"], city_before["Name"], materials_names[int(island["tradegood"])], @@ -181,9 +171,7 @@ def do_it(session, islandList, time, fights): and "armyAction" in city_before["infos"] and city_before["infos"]["armyAction"] == "fight" ): - msg = _( - "A fight stopped in the city {} of the player {} on island {} {}:{} {}" - ).format( + msg = "A fight stopped in the city {} of the player {} on island {} {}:{} {}".format( city_before["name"], city_before["Name"], materials_names[int(island["tradegood"])], @@ -199,9 +187,7 @@ def do_it(session, islandList, time, fights): city_before["id"] for city_before in cities_before ]: # we didn't find the city_now in the cities_before - msg = _( - "Player {} created a new city {} in {} {}:{} {}" - ).format( + msg = "Player {} created a new city {} in {} {}:{} {}".format( city_now["Name"], city_now["name"], materials_names[int(island["tradegood"])], diff --git a/ikabot/function/sellResources.py b/ikabot/function/sellResources.py index 1be0b0ab..6aa5ceb7 100644 --- a/ikabot/function/sellResources.py +++ b/ikabot/function/sellResources.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import json import math import time @@ -19,9 +18,6 @@ from ikabot.helpers.signals import setInfoSignal from ikabot.helpers.varios import addThousandSeparator, wait -t = gettext.translation("sellResources", localedir, languages=languages, fallback=True) -_ = t.gettext - def chooseCommercialCity(commercial_cities): """ @@ -33,7 +29,7 @@ def chooseCommercialCity(commercial_cities): ------- commercial_city : dict """ - print(_("In which city do you want to sell resources?\n")) + print("In which city do you want to sell resources?\n") for i, city in enumerate(commercial_cities): print("({:d}) {}".format(i + 1, city["name"])) ind = read(min=1, max=len(commercial_cities)) @@ -120,12 +116,12 @@ def sellToOffers(session, city_to_buy_from, resource_type, event): offers = getOffers(session, city_to_buy_from, resource_type) if len(offers) == 0: - print(_("No offers available.")) + print("No offers available.") enter() event.set() return - print(_("Which offers do you want to sell to?\n")) + print("Which offers do you want to sell to?\n") chosen_offers = [] total_amount = 0 @@ -136,7 +132,7 @@ def sellToOffers(session, city_to_buy_from, resource_type, event): amount = amount.replace(",", "").replace(".", "") amount = int(amount) price = int(price) - msg = _("{} ({}): {} at {:d} each ({} in total) [Y/n]").format( + msg = "{} ({}): {} at {:d} each ({} in total) [Y/n]".format( cityname, username, addThousandSeparator(amount), @@ -159,7 +155,7 @@ def sellToOffers(session, city_to_buy_from, resource_type, event): banner() print( - _("\nHow much do you want to sell? [max = {}]").format( + "\nHow much do you want to sell? [max = {}]".format( addThousandSeparator(amount_to_sell) ) ) @@ -180,7 +176,7 @@ def sellToOffers(session, city_to_buy_from, resource_type, event): left_to_sell -= sell profit += sell * price print( - _("\nSell {} of {} for a total of {}? [Y/n]").format( + "\nSell {} of {} for a total of {}? [Y/n]".format( addThousandSeparator(amount_to_sell), materials_names[resource_type], addThousandSeparator(profit), @@ -194,7 +190,7 @@ def sellToOffers(session, city_to_buy_from, resource_type, event): set_child_mode(session) event.set() - info = _("\nI sell {} of {} in {}\n").format( + info = "\nI sell {} of {} in {}\n".format( addThousandSeparator(amount_to_sell), materials_names[resource_type], city_to_buy_from["name"], @@ -203,7 +199,7 @@ def sellToOffers(session, city_to_buy_from, resource_type, event): try: do_it1(session, amount_to_sell, chosen_offers, resource_type, city_to_buy_from) except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) finally: session.logout() @@ -227,7 +223,7 @@ def createOffer(session, my_offering_market_city, resource_type, event): ] print( - _("How much do you want to sell? [max = {}]").format( + "How much do you want to sell? [max = {}]".format( addThousandSeparator(total_available_amount_of_resource) ) ) @@ -241,18 +237,18 @@ def createOffer(session, my_offering_market_city, resource_type, event): ] price_max = int(price_max) price_min = int(price_min) - print(_("\nAt what price? [min = {:d}, max = {:d}]").format(price_min, price_max)) + print("\nAt what price? [min = {:d}, max = {:d}]".format(price_min, price_max)) price = read(min=price_min, max=price_max) print( - _("\nI will sell {} of {} at {}: {}").format( + "\nI will sell {} of {} at {}: {}".format( addThousandSeparator(amount_to_sell), materials_names[resource_type], addThousandSeparator(price), addThousandSeparator(price * amount_to_sell), ) ) - print(_("\nProceed? [Y/n]")) + print("\nProceed? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "n": event.set() @@ -261,7 +257,7 @@ def createOffer(session, my_offering_market_city, resource_type, event): set_child_mode(session) event.set() - info = _("\nI sell {} of {} in {}\n").format( + info = "\nI sell {} of {} in {}\n".format( addThousandSeparator(amount_to_sell), materials_names[resource_type], my_offering_market_city["name"], @@ -277,7 +273,7 @@ def createOffer(session, my_offering_market_city, resource_type, event): my_offering_market_city, ) except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) finally: session.logout() @@ -299,7 +295,7 @@ def sellResources(session, event, stdin_fd, predetermined_input): commercial_cities = getCommercialCities(session) if len(commercial_cities) == 0: - print(_("There is no store built")) + print("There is no store built") enter() event.set() return @@ -310,7 +306,7 @@ def sellResources(session, event, stdin_fd, predetermined_input): city = chooseCommercialCity(commercial_cities) banner() - print(_("What resource do you want to sell?")) + print("What resource do you want to sell?") for index, material_name in enumerate(materials_names): print("({:d}) {}".format(index + 1, material_name)) selected_material = read(min=1, max=len(materials_names)) @@ -318,9 +314,9 @@ def sellResources(session, event, stdin_fd, predetermined_input): banner() print( - _( - "Do you want to sell to existing offers (1) or do you want to make your own offer (2)?" - ) + + "Do you want to sell to existing offers (1) or do you want to make your own offer (2)?" + ) selected = read(min=1, max=2) [sellToOffers, createOffer][selected - 1](session, city, resource, event) @@ -467,7 +463,7 @@ def do_it2(session, amount_to_sell, price, resource_type, sell_market_capacity, html = getMarketInfo(session, city) currently_on_sell = onSellInMarket(html)[resource_type] if currently_on_sell <= previous_on_sell: - msg = _("{} of {} was sold at {:d}").format( + msg = "{} of {} was sold at {:d}".format( addThousandSeparator(initial_amount_to_sell), materials_names[resource_type], price, diff --git a/ikabot/function/sendResources.py b/ikabot/function/sendResources.py index 61858b9b..23aa9181 100644 --- a/ikabot/function/sendResources.py +++ b/ikabot/function/sendResources.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import traceback from ikabot.config import * @@ -15,9 +14,6 @@ from ikabot.helpers.signals import setInfoSignal from ikabot.helpers.varios import addThousandSeparator -t = gettext.translation("sendResources", localedir, languages=languages, fallback=True) -_ = t.gettext - def sendResources(session, event, stdin_fd, predetermined_input): """ @@ -31,9 +27,9 @@ def sendResources(session, event, stdin_fd, predetermined_input): sys.stdin = os.fdopen(stdin_fd) config.predetermined_input = predetermined_input try: - print(_("What type of ships do you want to use? (Default: Trade ships)")) - print(_("(1) Trade ships")) - print(_("(2) Freighters")) + print("What type of ships do you want to use? (Default: Trade ships)") + print("(1) Trade ships") + print("(2) Freighters") shiptype = read(min=1, max=2, digit=True, empty=True) if shiptype == '': shiptype = 1 @@ -45,12 +41,12 @@ def sendResources(session, event, stdin_fd, predetermined_input): while True: banner() - print(_("Origin city:")) + print("Origin city:") try: cityO = chooseCity(session) except KeyboardInterrupt: if routes: - print(_("Send shipment? [Y/n]")) + print("Send shipment? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() != "n": break @@ -58,7 +54,7 @@ def sendResources(session, event, stdin_fd, predetermined_input): return banner() - print(_("Destination city")) + print("Destination city") cityD = chooseCity(session, foreign=True) idIsland = cityD["islandId"] @@ -89,9 +85,9 @@ def sendResources(session, event, stdin_fd, predetermined_input): ) if len(msg) > 0: - print(_("You can store just:\n{}").format(msg)) + print("You can store just:\n{}").format(msg) - print(_("Available:")) + print("Available:") for i in range(len(materials_names)): print( "{}:{} ".format( @@ -101,7 +97,7 @@ def sendResources(session, event, stdin_fd, predetermined_input): ) print("") - print(_("Send:")) + print("Send:") try: max_name = max([len(material) for material in materials_names]) send = [] @@ -109,7 +105,7 @@ def sendResources(session, event, stdin_fd, predetermined_input): material_name = materials_names[i] pad = " " * (max_name - len(material_name)) val = askForValue( - _("{}{}:".format(pad, material_name)), resources_left[i] + "{}{}:".format(pad, material_name), resources_left[i] ) send.append(val) except KeyboardInterrupt: @@ -119,7 +115,7 @@ def sendResources(session, event, stdin_fd, predetermined_input): banner() print( - _("About to send from {} to {}").format( + "About to send from {} to {}".format( cityO["cityName"], cityD["cityName"] ) ) @@ -133,12 +129,12 @@ def sendResources(session, event, stdin_fd, predetermined_input): ) print("") - print(_("Proceed? [Y/n]")) + print("Proceed? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() != "n": route = (cityO, cityD, idIsland, *send) routes.append(route) - print(_("Create another shipment? [y/N]")) + print("Create another shipment? [y/N]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() != "y": break @@ -149,13 +145,13 @@ def sendResources(session, event, stdin_fd, predetermined_input): set_child_mode(session) event.set() - info = _("\nSend resources\n") + info = "\nSend resources\n" setInfoSignal(session, info) try: executeRoutes(session, routes, useFreighters) except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format(info, traceback.format_exc()) + msg = "Error in:\n{}\nCause:\n{}".format(info, traceback.format_exc()) sendToBot(session, msg) finally: session.logout() diff --git a/ikabot/function/shipMovements.py b/ikabot/function/shipMovements.py index 6de58da8..1aecf4f6 100644 --- a/ikabot/function/shipMovements.py +++ b/ikabot/function/shipMovements.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import json import math import re @@ -15,9 +14,6 @@ from ikabot.helpers.pedirInfo import read from ikabot.helpers.varios import * -t = gettext.translation("shipMovements", localedir, languages=languages, fallback=True) -_ = t.gettext - def isHostile(movement): """ @@ -52,7 +48,7 @@ def shipMovements(session, event, stdin_fd, predetermined_input): banner() print( - _("Ships {:d}/{:d}\n").format( + "Ships {:d}/{:d}\n".format( getAvailableShips(session), getTotalShips(session) ) ) @@ -67,7 +63,7 @@ def shipMovements(session, event, stdin_fd, predetermined_input): time_now = int(resp[0][1]["time"]) if len(movements) == 0: - print(_("There are no movements")) + print("There are no movements") enter() event.set() return @@ -106,7 +102,7 @@ def shipMovements(session, event, stdin_fd, predetermined_input): troops = movement["army"]["amount"] fleets = movement["fleet"]["amount"] print( - _("Troops:{}\nFleets:{}").format( + "Troops:{}\nFleets:{}".format( addThousandSeparator(troops), addThousandSeparator(fleets) ) ) @@ -120,7 +116,7 @@ def shipMovements(session, event, stdin_fd, predetermined_input): else: fleets += int(mov["amount"]) print( - _("Troops:{}\nFleets:{}\n Ships:{}").format( + "Troops:{}\nFleets:{}\n Ships:{}".format( addThousandSeparator(troops), addThousandSeparator(fleets), addThousandSeparator(ships), @@ -137,9 +133,9 @@ def shipMovements(session, event, stdin_fd, predetermined_input): index = materials_names_tec.index(tradegood) tradegood = materials_names[index] total_load += int(amount.replace(",", "").replace(".", "")) - print(_("{} of {}").format(amount, tradegood)) + print("{} of {}".format(amount, tradegood)) ships = int(math.ceil((Decimal(total_load) / Decimal(500)))) - print(_("{:d} Ships").format(ships)) + print("{:d} Ships".format(ships)) enter() event.set() except KeyboardInterrupt: diff --git a/ikabot/function/stationArmy.py b/ikabot/function/stationArmy.py index e85a5dd2..8bb4602f 100644 --- a/ikabot/function/stationArmy.py +++ b/ikabot/function/stationArmy.py @@ -1,4 +1,3 @@ -import gettext import re from ikabot.config import * @@ -6,10 +5,6 @@ from ikabot.helpers.pedirInfo import * from ikabot.helpers.varios import addThousandSeparator -t = gettext.translation("buyResources", localedir, languages=languages, fallback=True) -_ = t.gettext - - def getCityMilitaryData(session, city_id): """ Parameters @@ -164,12 +159,12 @@ def stationArmy(session, event, stdin_fd, predetermined_input): ) print() - print(_("(0) Back")) - print(_("(1) Move troops")) - print(_("(2) Move ships")) - print(_("(3) Move all ground units to a city.")) - print(_("(4) Move all maritime units to a city.")) - print(_("(5) Move all units to a city.")) + print("(0) Back") + print("(1) Move troops") + print("(2) Move ships") + print("(3) Move all ground units to a city.") + print("(4) Move all maritime units to a city.") + print("(5) Move all units to a city.") selected = read(min=0, max=5, digit=True) if selected == 0: diff --git a/ikabot/function/trainArmy.py b/ikabot/function/trainArmy.py index 712af70c..26b35253 100644 --- a/ikabot/function/trainArmy.py +++ b/ikabot/function/trainArmy.py @@ -3,7 +3,6 @@ import asyncio import copy -import gettext import json import re import traceback @@ -19,9 +18,6 @@ from ikabot.helpers.varios import * from ikabot.helpers.varios import addThousandSeparator -t = gettext.translation("trainArmy", localedir, languages=languages, fallback=True) -_ = t.gettext - def getBuildingInfo(session, city, trainTroops): """ @@ -158,9 +154,8 @@ def planTrainings(session, city, trainings, trainTroops): # amount of units that will be trained total = sum([unit["train"] for unit in training]) if total == 0: - msg = _( - "It was not possible to finish the training due to lack of resources." - ) + msg = "It was not possible to finish the training due to lack of resources." + sendToBot(session, msg) return @@ -202,15 +197,15 @@ def trainArmy(session, event, stdin_fd, predetermined_input): try: banner() - print(_("Do you want to train troops (1) or ships (2)?")) + print("Do you want to train troops (1) or ships (2)?") rta = read(min=1, max=2) trainTroops = rta == 1 banner() if trainTroops: - print(_("In what city do you want to train the troops?")) + print("In what city do you want to train the troops?") else: - print(_("In what city do you want to train the fleet?")) + print("In what city do you want to train the fleet?") city = chooseCity(session) banner() @@ -221,9 +216,9 @@ def trainArmy(session, event, stdin_fd, predetermined_input): break else: if trainTroops: - print(_("Barracks not built.")) + print("Barracks not built.") else: - print(_("Shipyard not built.")) + print("Shipyard not built.") enter() event.set() return @@ -238,7 +233,7 @@ def trainArmy(session, event, stdin_fd, predetermined_input): tranings = [] while True: units = generateArmyData(units_info) - print(_("Train:")) + print("Train:") for unit in units: pad = " " * (maxSize - len(unit["local_name"])) amount = read( @@ -269,7 +264,7 @@ def trainArmy(session, event, stdin_fd, predetermined_input): unit["costs"]["completiontime"] * unit["cantidad"] ) - print(_("\nTotal cost:")) + print("\nTotal cost:") for i in range(len(materials_names_english)): if cost[i] > 0: print( @@ -279,24 +274,24 @@ def trainArmy(session, event, stdin_fd, predetermined_input): ) if cost[len(materials_names_english) + 0] > 0: print( - _("Citizens: {}").format( + "Citizens: {}".format( addThousandSeparator(cost[len(materials_names_english) + 0]) ) ) if cost[len(materials_names_english) + 1] > 0: print( - _("Maintenance: {}").format( + "Maintenance: {}".format( addThousandSeparator(cost[len(materials_names_english) + 1]) ) ) if cost[len(materials_names_english) + 2] > 0: print( - _("Duration: {}").format( + "Duration: {}".format( daysHoursMinutes(int(cost[len(materials_names_english) + 2])) ) ) - print(_("\nProceed? [Y/n]")) + print("\nProceed? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "n": event.set() @@ -305,40 +300,40 @@ def trainArmy(session, event, stdin_fd, predetermined_input): tranings.append(units) if trainTroops: - print(_("\nDo you want to train more troops when you finish? [y/N]")) + print("\nDo you want to train more troops when you finish? [y/N]") else: - print(_("\nDo you want to train more fleets when you finish? [y/N]")) + print("\nDo you want to train more fleets when you finish? [y/N]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "y": banner() if trainTroops: - print(_("Train new troops (1) or repeat (2)?")) + print("Train new troops (1) or repeat (2)?") else: - print(_("Train new fleets (1) or repeat (2)?")) + print("Train new fleets (1) or repeat (2)?") rta = read(min=1, max=2) if rta == 1: continue else: - print(_("\nRepeat how many times?")) + print("\nRepeat how many times?") countRepeat = read(min=1, default=0) break else: countRepeat = 0 break - print(_("Do you want to replicate the training to other cities? (y/N)")) + print("Do you want to replicate the training to other cities? (y/N)") replicate = read(values=["y", "Y", "n", "N", ""]) if replicate.lower() == "y": cityTrainings = [] ids, cities = getIdsOfCities(session) - print(_("(0) Back")) - print(_("(1) All the wine cities")) - print(_("(2) All the marble cities")) - print(_("(3) All the cristal cities")) - print(_("(4) All the sulfur cities")) - print(_("(5) Choose City")) - print(_("(6) All City")) + print("(0) Back") + print("(1) All the wine cities") + print("(2) All the marble cities") + print("(3) All the cristal cities") + print("(4) All the sulfur cities") + print("(5) Choose City") + print("(6) All City") selected = read(min=0, max=6, digit=True) if selected == 0: @@ -353,10 +348,10 @@ def trainArmy(session, event, stdin_fd, predetermined_input): while True: city = chooseCity(session) if city["id"] in cityTrainings: - print(_("\nYou have already selected this city!")) + print("\nYou have already selected this city!") continue cityTrainings.append(city["id"]) - print(_("\nDo you want to add another city? [y/N]")) + print("\nDo you want to add another city? [y/N]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "y": continue @@ -389,7 +384,7 @@ def trainArmy(session, event, stdin_fd, predetermined_input): not_enough = [elem for elem in resourcesAvailable if elem < 0] != [] if not_enough: - print(_("\nThere are not enough resources:")) + print("\nThere are not enough resources:") for i in range(len(materials_names_english)): if resourcesAvailable[i] < 0: print( @@ -401,23 +396,23 @@ def trainArmy(session, event, stdin_fd, predetermined_input): if resourcesAvailable[len(materials_names_english)] < 0: print( - _("Citizens:{}").format( + "Citizens:{}".format( addThousandSeparator( resourcesAvailable[len(materials_names_english)] * -1 ) ) ) - print(_("\nProceed anyway? [Y/n]")) + print("\nProceed anyway? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "n": event.set() return if trainTroops: - print(_("\nThe selected troops will be trained.")) + print("\nThe selected troops will be trained.") else: - print(_("\nThe selected fleet will be trained.")) + print("\nThe selected fleet will be trained.") enter() if replicate == "y": @@ -444,14 +439,14 @@ def trainArmy(session, event, stdin_fd, predetermined_input): break except Exception as e: if trainTroops: - info = _("\nI train troops in {}\n").format( + info = "\nI train troops in {}\n".format( city["cityName"] ) else: - info = _("\nI train fleets in {}\n").format( + info = "\nI train fleets in {}\n".format( city["cityName"] ) - msg = _("Error in:\n{}\nCause:\n{}").format( + msg = "Error in:\n{}\nCause:\n{}".format( info, traceback.format_exc() ) sendToBot(session, msg) @@ -459,14 +454,14 @@ def trainArmy(session, event, stdin_fd, predetermined_input): else: if trainTroops: - info = _("\nI train troops in {}\n").format(city["cityName"]) + info = "\nI train troops in {}\n".format(city["cityName"]) else: - info = _("\nI train fleets in {}\n").format(city["cityName"]) + info = "\nI train fleets in {}\n".format(city["cityName"]) setInfoSignal(session, info) try: planTrainings(session, city, tranings, trainTroops) except Exception as e: - msg = _("Error in:\n{}\nCause:\n{}").format( + msg = "Error in:\n{}\nCause:\n{}".format( info, traceback.format_exc() ) sendToBot(session, msg) diff --git a/ikabot/function/update.py b/ikabot/function/update.py index 4ab05e73..f051df46 100644 --- a/ikabot/function/update.py +++ b/ikabot/function/update.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import sys from ikabot.config import * @@ -9,9 +8,6 @@ from ikabot.helpers.pedirInfo import read from ikabot.helpers.process import run -t = gettext.translation("update", localedir, languages=languages, fallback=True) -_ = t.gettext - def update(session, event, stdin_fd, predetermined_input): """ @@ -25,7 +21,7 @@ def update(session, event, stdin_fd, predetermined_input): sys.stdin = os.fdopen(stdin_fd) config.predetermined_input = predetermined_input try: - print(_("To update ikabot run:")) + print("To update ikabot run:") print("python3 -m pip install --user --upgrade ikabot") enter() event.set() diff --git a/ikabot/function/vacationMode.py b/ikabot/function/vacationMode.py index b89c9d18..76eb1c63 100644 --- a/ikabot/function/vacationMode.py +++ b/ikabot/function/vacationMode.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import sys from ikabot.config import * @@ -9,9 +8,6 @@ from ikabot.helpers.gui import * from ikabot.helpers.pedirInfo import read -t = gettext.translation("vacationMode", localedir, languages=languages, fallback=True) -_ = t.gettext - def activateVacationMode(session): """ @@ -46,7 +42,7 @@ def vacationMode(session, event, stdin_fd, predetermined_input): config.predetermined_input = predetermined_input try: banner() - print(_("Activate vacation mode? [Y/n]")) + print("Activate vacation mode? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "n": event.set() @@ -54,7 +50,7 @@ def vacationMode(session, event, stdin_fd, predetermined_input): activateVacationMode(session) - print(_("Vacation mode has been activated.")) + print("Vacation mode has been activated.") enter() event.set() clear() diff --git a/ikabot/function/webServer.py b/ikabot/function/webServer.py index 54747f05..bae5a9ef 100644 --- a/ikabot/function/webServer.py +++ b/ikabot/function/webServer.py @@ -4,7 +4,6 @@ import logging from ikabot.helpers.logging import getLogger import base64 -import gettext import json import pickle import re @@ -36,10 +35,6 @@ class ResponseTypes: RED = 11 YELLOW = 12 - -t = gettext.translation("webServer", localedir, languages=languages, fallback=True) -_ = t.gettext - if isWindows: web_cache_file = os.getenv("temp") + "/ikabot.webcache" else: diff --git a/ikabot/helpers/aesCipher.py b/ikabot/helpers/aesCipher.py index 7d514686..2a1d03f7 100644 --- a/ikabot/helpers/aesCipher.py +++ b/ikabot/helpers/aesCipher.py @@ -11,9 +11,6 @@ from ikabot.config import * from ikabot.helpers.botComm import * -t = gettext.translation("aesCipher", localedir, languages=languages, fallback=True) -_ = t.gettext - class AESCipher: @@ -90,18 +87,13 @@ def getSessionData(self, session, all=False): try: plaintext = self.decrypt(ciphertext) except Exception: - msg = _( - "Error while decrypting session data.\nYou may have entered a wrong password." - ) + msg = "Error while decrypting session data.\nYou may have entered a wrong password." + if session.padre: print(msg) else: sendToBot(session, msg) - print( - _( - "\nWould you like to delete the ikabot session data associated with this email address? [y/N]" - ) - ) + print("\nWould you like to delete the ikabot session data associated with this email address? [y/N]") rta = read(values=["n", "N", "y", "Y"]) if rta.lower() == "n": os._exit(0) diff --git a/ikabot/helpers/botComm.py b/ikabot/helpers/botComm.py index 12d9b689..5c11dad5 100644 --- a/ikabot/helpers/botComm.py +++ b/ikabot/helpers/botComm.py @@ -3,7 +3,6 @@ from ikabot.helpers.logging import getLogger logger = getLogger(__name__) -import gettext import json import os import random @@ -16,9 +15,6 @@ from ikabot.helpers.gui import * from ikabot.helpers.pedirInfo import read -t = gettext.translation("botComm", localedir, languages=languages, fallback=True) -_ = t.gettext - def sendToBotDebug(session, msg, debugON): """This function will send the ``msg`` argument passed to it as a message to the user on Telegram, only if ``debugOn`` is ``True`` @@ -171,15 +167,12 @@ def checkTelegramData(session): if not session.padre: # stop asking people if process is detached return False banner() - print(_("You must provide valid credentials to communicate by telegram.")) - print(_("You require the token of the bot you are going to use.")) - print( - _( - "For more information about how to obtain them read the readme at https://github.com/physics-sp/ikabot" - ) + print("You must provide valid credentials to communicate by telegram.") + print("You require the token of the bot you are going to use.") + print("For more information about how to obtain them read the readme at https://github.com/Ikabot-Collective/ikabot" ) rta = read( - msg=_("Will you provide the credentials now? [y/N]"), + msg="Will you provide the credentials now? [y/N]", values=["y", "Y", "n", "N", ""], ) if rta.lower() != "y": @@ -210,19 +203,11 @@ def updateTelegramData(session, event=None, stdin_fd=None, predetermined_input=[ sys.stdin = os.fdopen(stdin_fd) # give process access to terminal config.predetermined_input = predetermined_input banner() - print( - _( - "To create your own Telegram bot, read this: https://core.telegram.org/bots#3-how-do-i-create-a-bot" - ) - ) - print( - _( - "1. Just talk to @botfather in Telegram, send /newbot and then choose the bot's name." - ) - ) - print(_("2. Obtain your new bot's token")) - print(_("3. Remember to keep the token secret!\n")) - botToken = read(msg=_("Bot's token: ")) + print("To create your own Telegram bot, read this: https://core.telegram.org/bots#3-how-do-i-create-a-bot") + print("1. Just talk to @botfather in Telegram, send /newbot and then choose the bot's name.") + print("2. Obtain your new bot's token") + print("3. Remember to keep the token secret!\n") + botToken = read(msg="Bot's token: ") updates = get( "https://api.telegram.org/bot{}/getUpdates".format(botToken) @@ -231,7 +216,7 @@ def updateTelegramData(session, event=None, stdin_fd=None, predetermined_input=[ "https://api.telegram.org/bot{}/getMe".format(botToken) ).json() if "ok" not in updates or updates["ok"] is False: - print(_("Invalid Telegram bot, try again.")) + print("Invalid Telegram bot, try again.") enter() if event is not None and stdin_fd is not None: event.set() diff --git a/ikabot/helpers/gui.py b/ikabot/helpers/gui.py index de0de720..e833c38b 100644 --- a/ikabot/helpers/gui.py +++ b/ikabot/helpers/gui.py @@ -2,16 +2,11 @@ # -*- coding: utf-8 -*- import getpass -import gettext import os from ikabot import config from ikabot.config import * -t = gettext.translation("gui", localedir, languages=languages, fallback=True) -_ = t.gettext - - def enter(): """Wait for the user to press Enter""" try: @@ -20,9 +15,9 @@ def enter(): except Exception: pass if isWindows: - input(_("\n[Enter]")) # TODO improve this + input("\n[Enter]") # TODO improve this else: - getpass.getpass(_("\n[Enter]")) + getpass.getpass("\n[Enter]") def clear(): diff --git a/ikabot/helpers/pedirInfo.py b/ikabot/helpers/pedirInfo.py index 85dfb195..916e66fd 100644 --- a/ikabot/helpers/pedirInfo.py +++ b/ikabot/helpers/pedirInfo.py @@ -1,7 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import json import os import re @@ -14,9 +13,6 @@ from ikabot.helpers.gui import * from ikabot.helpers.varios import decodeUnicodeEscape -t = gettext.translation("pedirInfo", localedir, languages=languages, fallback=True) -_ = t.gettext - getcontext().prec = 30 @@ -121,15 +117,15 @@ def pad(city_name): return " " * (longest_city_name_length - len(city_name) + 2) resources_abbreviations = { - "1": _("(W)"), - "2": _("(M)"), - "3": _("(C)"), - "4": _("(S)"), + "1": "(W)", + "2": "(M)", + "3": "(C)", + "4": "(S)", } i = 0 if foreign: - print(_(" 0: foreign city")) + print(" 0: foreign city") else: print("") for city_id in ids: @@ -142,7 +138,7 @@ def pad(city_name): ) menu_cities = menu_cities[:-1] if foreign: - print(_(" 0: foreign city")) + print(" 0: foreign city") print(menu_cities) if foreign: @@ -181,7 +177,7 @@ def chooseForeignCity(session): islands_json = json.loads(islands_json, strict=False) island_id = islands_json["data"][str(x)][str(y)][0] except Exception: - print(_("Incorrect coordinates")) + print("Incorrect coordinates") enter() banner() return chooseCity(session, foreign=True) @@ -208,7 +204,7 @@ def chooseForeignCity(session): ) city_options.append(city) if i == 0: - print(_("There are no cities where to send resources on this island")) + print("There are no cities where to send resources on this island") enter() return chooseCity(session, foreign=True) selected_city_index = read(min=1, max=i) diff --git a/ikabot/helpers/signals.py b/ikabot/helpers/signals.py index 9c3a3895..a4086764 100644 --- a/ikabot/helpers/signals.py +++ b/ikabot/helpers/signals.py @@ -1,16 +1,12 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -import gettext import os import signal from ikabot.config import * from ikabot.helpers.botComm import * -t = gettext.translation("signals", localedir, languages=languages, fallback=True) -_ = t.gettext - def do_nothing(signal, frame): pass @@ -22,7 +18,7 @@ def deactivate_sigint(): def create_handler(s): def _handler(signum, frame): - raise Exception(_("Signal number {:d} received").format(signum)) + raise Exception("Signal number {:d} received".format(signum)) return _handler @@ -43,7 +39,7 @@ def setInfoSignal(session, info): # send process info to bot session : ikabot.web.session.Session info : str """ - info = _("information of the process {}:\n{}").format(os.getpid(), info) + info = "information of the process {}:\n{}".format(os.getpid(), info) def _sendInfo(signum, frame): sendToBot(session, info) diff --git a/ikabot/web/session.py b/ikabot/web/session.py index 097eb63d..f87bf3a6 100644 --- a/ikabot/web/session.py +++ b/ikabot/web/session.py @@ -5,7 +5,6 @@ import base64 import datetime import getpass -import gettext import json import os import random @@ -28,9 +27,6 @@ from ikabot.helpers.varios import getDateTime, lastloginTimetoString from ikabot.helpers.apiComm import getInteractiveCaptchaSolution, getNewBlackBoxToken -t = gettext.translation("session", localedir, languages=languages, fallback=True) -_ = t.gettext - class Session: def __init__(self): @@ -203,12 +199,12 @@ def __login(self, retries=0): if not self.logged: banner() - self.mail = read(msg=_("Mail:")) + self.mail = read(msg="Mail:") if len(config.predetermined_input) != 0: self.password = config.predetermined_input.pop(0) else: - self.password = getpass.getpass(_("Password:")) + self.password = getpass.getpass("Password:") banner() @@ -528,7 +524,7 @@ def __login(self, retries=0): ) # Unholy way to clear a ListProxy object answer = read(values=["y", "Y", "n", "N"], default="y") if answer.lower() == "n": - sys.exit(_("Captcha error! (Interactive)")) + sys.exit("Captcha error! (Interactive)") sendToBot(self, "", Photo=text_image) sendToBot( @@ -536,11 +532,7 @@ def __login(self, retries=0): "Please send the number of the correct image (1, 2, 3 or 4)", Photo=drag_icons, ) - print( - _( - "Check your Telegram and do it fast. The captcha expires quickly" - ) - ) + print("Check your Telegram and do it fast. The captcha expires quickly") captcha_time = time.time() while True: response = getUserResponse(self, fullResponse=True) @@ -558,11 +550,7 @@ def __login(self, retries=0): data = {"answer": captcha} break except ValueError: - print( - _( - "You sent {}. Please send only a number (1, 2, 3 or 4)" - ).format(captcha) - ) + print("You sent {}. Please send only a number (1, 2, 3 or 4)".format(captcha)) time.sleep(5) continue time.sleep(5) @@ -638,7 +626,7 @@ def __login(self, retries=0): ) self.s.cookies.set_cookie(cookie_obj) if not self.__test_lobby_cookie(): - sys.exit(_("Wrong email or password\n")) + sys.exit("Wrong email or password\n") else: # get the authentication token and set the cookie ses_json = json.loads(r.text, strict=False) @@ -703,7 +691,7 @@ def __login(self, retries=0): account for account in accounts if account["blocked"] is False ][0] else: - print(_("With which account do you want to log in?\n")) + print("With which account do you want to log in?\n") max_name = max( [ @@ -750,9 +738,9 @@ def __login(self, retries=0): if srv["accountGroup"] == self.account_group ][0] - config.infoUser = _("Server:{}").format(self.servidor) - config.infoUser += _(", World:{}").format(self.word) - config.infoUser += _(", Player:{}").format(self.username) + config.infoUser = "Server:{}".format(self.servidor) + config.infoUser += ", World:{}".format(self.word) + config.infoUser += ", Player:{}".format(self.username) banner() self.host = "s{}-{}.ikariam.gameforge.com".format(self.mundo, self.servidor) @@ -932,7 +920,7 @@ def __login(self, retries=0): self.__proxy_error() if self.__isInVacation(html): - msg = _("The account went into vacation mode") + msg = "The account went into vacation mode" if self.padre: print(msg) else: @@ -942,7 +930,7 @@ def __login(self, retries=0): if retries > 0: return self.__login(retries - 1) if self.padre: - msg = _("Login error.") + msg = "Login error." print(msg) os._exit(0) raise Exception("Couldn't log in") @@ -982,19 +970,19 @@ def __proxy_error(self): if "proxy" not in sessionData or sessionData["proxy"]["set"] is False: sys.exit("network error") elif self.padre is True: - print(_("There seems to be a problem connecting to ikariam.")) - print(_("Do you want to disable the proxy? [Y/n]")) + print("There seems to be a problem connecting to ikariam.") + print("Do you want to disable the proxy? [Y/n]") rta = read(values=["y", "Y", "n", "N", ""]) if rta.lower() == "n": sys.exit() else: sessionData["proxy"]["set"] = False self.setSessionData(sessionData) - print(_("Proxy disabled, try again.")) + print("Proxy disabled, try again.") enter() sys.exit() else: - msg = _("Network error. Consider disabling the proxy.") + msg = "Network error. Consider disabling the proxy." sendToBot(self, msg) sys.exit() @@ -1243,4 +1231,4 @@ def normal_get(url, params={}): return requests.get(url, params=params) except requests.exceptions.ConnectionError: - sys.exit(_("Internet connection failed")) + sys.exit("Internet connection failed")