Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 48 additions & 37 deletions EDMarketConnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
from journal_lock import JournalLock, JournalLockResult
from update import check_for_datafile_updates, check_for_fdev_updates
from common_utils import log_locale, SERVER_RETRY
from l10n import translations as tr

if __name__ == '__main__': # noqa: C901
# Command-line arguments
Expand Down Expand Up @@ -361,7 +362,10 @@ def enumwindowsproc(window_handle, l_param): # noqa: CCR001
def skip_journallock_popup():
"""Create the "skipping Journal Lock" popup."""
from tkinter import messagebox
lockmsg = "Ignoring failed Journal Lock. Continuing at your own risk.\nConsider also using a debug sender."
lockmsg = tr.tl(
"Ignoring failed Journal Lock. Continuing at your own risk."
"{CR}Consider also using a debug sender."
) # LANG: Popup message when user tries to start a second instance of the application with --skip-journallock, warning them of potential consequences
messagebox.showwarning(title=appname, message=lockmsg)

def already_running_popup():
Expand All @@ -371,7 +375,10 @@ def already_running_popup():
if args.suppress_dupe_process_popup:
sys.exit(0)

messagebox.showerror(title=appname, message="An EDMarketConnector process was already running, exiting.")
messagebox.showerror(
title=appname,
message=tr.tl("An EDMarketConnector process was already running, exiting.") # LANG: Popup message when user tries to start a second instance of the application
)
sys.exit(0)

journal_lock = JournalLock()
Expand Down Expand Up @@ -441,7 +448,6 @@ def already_running_popup():
from dashboard import dashboard
from edmc_data import ship_name_map
from hotkey import hotkeymgr
from l10n import translations as tr
from monitor import monitor
from theme import theme
from ttkHyperlinkLabel import HyperlinkLabel, SHIPYARD_HTML_TEMPLATE
Expand Down Expand Up @@ -946,16 +952,15 @@ def postprefs(self, dologin: bool = True, **postargs):
if track == "Stable":
# LANG: Inform the user the Update Track has changed
title = tr.tl('Update Track Changed to {TRACK}').format(TRACK=track)
update_msg = tr.tl( # LANG: Inform User of Beta -> Stable Transition Risks
update_msg = tr.tl( # LANG: Inform User of Beta -> Stable Transition Risks, EOL: End of Line
'Update track changed to Stable from Beta. '
'You will no longer receive Beta updates. You will stay on your current Beta '
r'version until the next Stable release.\r\n\r\n'
'version until the next Stable release.{EOL}{EOL}'
'You can manually revert to the latest Stable version. To do so, you must download and install '
'the latest Stable version manually. Note that this may introduce bugs or break completely'
r' if downgrading between major versions with significant changes.\r\n\r\n'
' if downgrading between major versions with significant changes.{EOL}{EOL}'
'Do you want to open GitHub to download the latest release?'
)
update_msg = update_msg.replace('\\n', '\n').replace('\\r', '\r')
).format(EOL="\r\n") # Carriage Return + Line Feed = End of Line
stable_popup = tk.messagebox.askyesno(title=title, message=update_msg)
if stable_popup:
webbrowser.open("https://github.com/EDCD/eDMarketConnector/releases/latest")
Expand Down Expand Up @@ -2139,17 +2144,17 @@ def show_killswitch_poppup(root=None):
if len(kills := killswitch.kills_for_version()) == 0:
return

text = (
"Some EDMC Features have been disabled due to known issues.\n"
"Please update EDMC as soon as possible to resolve any issues.\n"
)
text = tr.tl(
"Some EDMC Features have been disabled due to known issues.{CR}"
"Please update EDMC as soon as possible to resolve any issues.{CR}"
) # LANG: Body text of killswitch warning popup

tl = tk.Toplevel(root)
tl.wm_attributes('-topmost', True)
tl.geometry(f'+{root.winfo_rootx()}+{root.winfo_rooty()}')

tl.columnconfigure(1, weight=1)
tl.title("EDMC Features have been disabled")
tl.title(tr.tl("EDMC Features have been disabled")) # LANG: Title of killswitch warning popup

frame = tk.Frame(tl)
frame.grid()
Expand All @@ -2158,15 +2163,18 @@ def show_killswitch_poppup(root=None):
idx = 1

for version in kills:
tk.Label(frame, text=f'Version: {version.version}').grid(row=idx, sticky=tk.W)
tk.Label(frame, text=tr.tl(
"Version: {VERSION}" # LANG: Label prefix for killswitch version number
).format(VERSION=version.version)).grid(row=idx, sticky=tk.W)

idx += 1
for id, kill in version.kills.items():
tk.Label(frame, text=id).grid(column=0, row=idx, sticky=tk.W, padx=(10, 0))
tk.Label(frame, text=kill.reason).grid(column=1, row=idx, sticky=tk.E, padx=(0, 10))
idx += 1
idx += 1

ok_button = ttk.Button(frame, text="Ok", command=tl.destroy)
ok_button = ttk.Button(frame, text=tr.tl('OK'), command=tl.destroy) # LANG: Killswitch popup dismiss button
ok_button.grid(columnspan=2, sticky=tk.EW)


Expand Down Expand Up @@ -2197,17 +2205,21 @@ def validate_providers():
if not reset_providers:
return

# LANG: Popup-text about Reset Providers
popup_text = tr.tl(r'One or more of your URL Providers were invalid, and have been reset:\r\n\r\n')
# LANG: Popup-text about Reset Providers, EOL: End of Line
popup_text = tr.tl(
'One or more of your URL Providers were invalid, and have been reset:{EOL}{EOL}'
).format(EOL="\r\n") # Carriage Return + Line Feed = End of Line

for provider, (old_prov, new_prov) in reset_providers.items():
# LANG: Text About What Provider Was Reset
popup_text += tr.tl(r'{PROVIDER} was set to {OLDPROV}, and has been reset to {NEWPROV}\r\n').format(
# LANG: Text About What Provider Was Reset, EOL: End of Line
popup_text += tr.tl(
'{PROVIDER} was set to {OLDPROV}, and has been reset to {NEWPROV}{EOL}'
).format(
PROVIDER=provider,
OLDPROV=old_prov,
NEWPROV=new_prov
NEWPROV=new_prov,
EOL="\r\n" # Carriage Return + Line Feed = End of Line
)
# And now we do need these to be actual \r\n
popup_text = popup_text.replace('\\n', '\n').replace('\\r', '\r')

tk.messagebox.showinfo(
# LANG: Popup window title for Reset Providers
Expand Down Expand Up @@ -2373,13 +2385,14 @@ def test_prop(self):
logger.exception(f"EDMC Critical Error: {err}")
title = tr.tl("Error") # LANG: Generic error prefix
message = tr.tl( # LANG: EDMC Critical Error Notification
"EDMC encountered a critical error, and cannot recover. EDMC is shutting down for its own protection!"
"EDMC encountered a critical error, and cannot recover. "
"EDMC is shutting down for its own protection!"
)
err = f"{err.__class__.__name__}: {err}" # type: ignore # hijacking the existing exception detection
detail = tr.tl( # LANG: EDMC Critical Error Details
r"Here's what EDMC Detected:\r\n\r\n{ERR}\r\n\r\nDo you want to file a Bug Report on GitHub?"
).format(ERR=err)
detail = detail.replace('\\n', '\n').replace('\\r', '\r')
detail = tr.tl( # LANG: EDMC Critical Error Details, EOL: End of Line
"Here's what EDMC Detected:{EOL}{EOL}"
"{ERR}{EOL}{EOL}Do you want to file a Bug Report on GitHub?"
).format(ERR=err, EOL="\r\n") # Carriage Return + Line Feed = End of Line
msg = tk.messagebox.askyesno(
title=title, message=message, detail=detail, icon=tkinter.messagebox.ERROR, type=tkinter.messagebox.YESNO,
parent=root
Expand All @@ -2394,11 +2407,11 @@ def test_prop(self):
def messagebox_broken_plugins():
"""Display message about 'broken' plugins that failed to load."""
if plug.PLUGINS_broken:
# LANG: Popup-text about 'broken' plugins that failed to load
# LANG: Popup-text about 'broken' plugins that failed to load, EOL: End of Line
popup_text = tr.tl(
"One or more of your enabled plugins failed to load. Please see the list on the '{PLUGINS}' "
"tab of '{FILE}' > '{SETTINGS}'. This could be caused by a wrong folder structure. The load.py "
r"file should be located under plugins/PLUGIN_NAME/load.py.\r\n\r\nYou can disable a plugin by "
"file should be located under plugins/PLUGIN_NAME/load.py.{EOL}{EOL}You can disable a plugin by "
"renaming its folder to have '{DISABLED}' on the end of the name."
)

Expand All @@ -2407,10 +2420,9 @@ def messagebox_broken_plugins():
PLUGINS=tr.tl('Plugins'), # LANG: Settings > Plugins tab
FILE=tr.tl('File'), # LANG: 'File' menu
SETTINGS=tr.tl('Settings'), # LANG: File > Settings
DISABLED='.disabled'
DISABLED='.disabled',
EOL="\r\n" # Carriage Return + Line Feed = End of Line
)
# And now we do need these to be actual \r\n
popup_text = popup_text.replace('\\n', '\n').replace('\\r', '\r')

tk.messagebox.showinfo(
# LANG: Popup window title for list of 'broken' plugins that failed to load
Expand All @@ -2423,12 +2435,12 @@ def messagebox_not_py3():
"""Display message about plugins not updated for Python 3.x."""
plugins_not_py3_last = config.get_int('plugins_not_py3_last', default=0)
if (plugins_not_py3_last + 86400) < int(time()) and plug.PLUGINS_not_py3:
# LANG: Popup-text about 'active' plugins without Python 3.x support
# LANG: Popup-text about 'active' plugins without Python 3.x support, EOL: End of Line
popup_text = tr.tl(
"One or more of your enabled plugins do not yet have support for Python 3.x. Please see the "
"list on the '{PLUGINS}' tab of '{FILE}' > '{SETTINGS}'. You should check if there is an "
"updated version available, else alert the developer that they need to update the code for "
r"Python 3.x.\r\n\r\nYou can disable a plugin by renaming its folder to have '{DISABLED}' on "
"Python 3.x.{EOL}{EOL}You can disable a plugin by renaming its folder to have '{DISABLED}' on "
"the end of the name."
)

Expand All @@ -2437,10 +2449,9 @@ def messagebox_not_py3():
PLUGINS=tr.tl('Plugins'), # LANG: Settings > Plugins tab
FILE=tr.tl('File'), # LANG: 'File' menu
SETTINGS=tr.tl('Settings'), # LANG: File > Settings
DISABLED='.disabled'
DISABLED='.disabled',
EOL="\r\n" # Carriage Return + Line Feed = End of Line
)
# And now we do need these to be actual \r\n
popup_text = popup_text.replace('\\n', '\n').replace('\\r', '\r')

tk.messagebox.showinfo(
# LANG: Popup window title for list of 'enabled' plugins that don't work with Python 3.x
Expand Down
Loading