1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-15 00:30:33 +03:00

Added comments

This commit is contained in:
A_D 2021-06-07 12:41:12 +02:00
parent 18c1bb1102
commit 2fb47377a3
No known key found for this signature in database
GPG Key ID: 4BE9EB7DF45076C4
2 changed files with 144 additions and 136 deletions

View File

@ -414,7 +414,7 @@ class AppWindow(object):
else: else:
appitem.grid(columnspan=2, sticky=tk.EW) appitem.grid(columnspan=2, sticky=tk.EW)
# Update button in main window # LANG: Update button in main window
self.button = ttk.Button(frame, text=_('Update'), width=28, default=tk.ACTIVE, state=tk.DISABLED) self.button = ttk.Button(frame, text=_('Update'), width=28, default=tk.ACTIVE, state=tk.DISABLED)
self.theme_button = tk.Label(frame, width=32 if platform == 'darwin' else 28, state=tk.DISABLED) self.theme_button = tk.Label(frame, width=32 if platform == 'darwin' else 28, state=tk.DISABLED)
self.status = tk.Label(frame, name='status', anchor=tk.W) self.status = tk.Label(frame, name='status', anchor=tk.W)
@ -626,7 +626,7 @@ class AppWindow(object):
return return
if (suit := monitor.state.get('SuitCurrent')) is None: if (suit := monitor.state.get('SuitCurrent')) is None:
self.suit['text'] = f'<{_("Unknown")}>' self.suit['text'] = f'<{_("Unknown")}>' # LANG: Unknown suit
return return
suitname = suit['edmcName'] suitname = suit['edmcName']
@ -701,48 +701,49 @@ class AppWindow(object):
def set_labels(self): def set_labels(self):
"""Set main window labels, e.g. after language change.""" """Set main window labels, e.g. after language change."""
self.cmdr_label['text'] = _('Cmdr') + ':' # Main window self.cmdr_label['text'] = _('Cmdr') + ':' # LANG: Main window
# Multicrew role label in main window # Multicrew role label in main window
self.ship_label['text'] = (monitor.state['Captain'] and _('Role') or _('Ship')) + ':' # Main window self.ship_label['text'] = (monitor.state['Captain'] and _('Role') or _('Ship')) + ':' # Main window
self.suit_label['text'] = _('Suit') + ':' # Main window self.suit_label['text'] = _('Suit') + ':' # LANG: Main window
self.system_label['text'] = _('System') + ':' # Main window self.system_label['text'] = _('System') + ':' # LANG: Main window
self.station_label['text'] = _('Station') + ':' # Main window self.station_label['text'] = _('Station') + ':' # LANG: Main window
self.button['text'] = self.theme_button['text'] = _('Update') # Update button in main window self.button['text'] = self.theme_button['text'] = _('Update') # LANG: Update button in main window
if platform == 'darwin': if platform == 'darwin':
self.menubar.entryconfigure(1, label=_('File')) # Menu title self.menubar.entryconfigure(1, label=_('File')) # LANG: Menu title on OSX
self.menubar.entryconfigure(2, label=_('Edit')) # Menu title self.menubar.entryconfigure(2, label=_('Edit')) # LANG: Menu title on OSX
self.menubar.entryconfigure(3, label=_('View')) # Menu title on OSX self.menubar.entryconfigure(3, label=_('View')) # LANG: Menu title on OSX
self.menubar.entryconfigure(4, label=_('Window')) # Menu title on OSX self.menubar.entryconfigure(4, label=_('Window')) # LANG: Menu title on OSX
self.menubar.entryconfigure(5, label=_('Help')) # Menu title self.menubar.entryconfigure(5, label=_('Help')) # LANG: Menu title on OSX
self.system_menu.entryconfigure(0, label=_("About {APP}").format(APP=applongname)) # App menu entry on OSX self.system_menu.entryconfigure(0, label=_("About {APP}").format(
self.system_menu.entryconfigure(1, label=_("Check for Updates...")) # Menu item APP=applongname)) # LANG: App menu entry on OSX
self.file_menu.entryconfigure(0, label=_('Save Raw Data...')) # Menu item self.system_menu.entryconfigure(1, label=_("Check for Updates...")) # LANG: Menu item
self.view_menu.entryconfigure(0, label=_('Status')) # Menu item self.file_menu.entryconfigure(0, label=_('Save Raw Data...')) # LANG: Menu item
self.help_menu.entryconfigure(1, label=_('Privacy Policy')) # Help menu item self.view_menu.entryconfigure(0, label=_('Status')) # LANG: Menu item
self.help_menu.entryconfigure(2, label=_('Release Notes')) # Help menu item self.help_menu.entryconfigure(1, label=_('Privacy Policy')) # LANG: Help menu item
self.help_menu.entryconfigure(2, label=_('Release Notes')) # LANG: Help menu item
else: else:
self.menubar.entryconfigure(1, label=_('File')) # Menu title self.menubar.entryconfigure(1, label=_('File')) # LANG: Menu title
self.menubar.entryconfigure(2, label=_('Edit')) # Menu title self.menubar.entryconfigure(2, label=_('Edit')) # LANG: Menu title
self.menubar.entryconfigure(3, label=_('Help')) # Menu title self.menubar.entryconfigure(3, label=_('Help')) # LANG: Menu title
self.theme_file_menu['text'] = _('File') # Menu title self.theme_file_menu['text'] = _('File') # LANG: Menu title
self.theme_edit_menu['text'] = _('Edit') # Menu title self.theme_edit_menu['text'] = _('Edit') # LANG: Menu title
self.theme_help_menu['text'] = _('Help') # Menu title self.theme_help_menu['text'] = _('Help') # LANG: Menu title
# File menu # File menu
self.file_menu.entryconfigure(0, label=_('Status')) # Menu item self.file_menu.entryconfigure(0, label=_('Status')) # LANG: Menu item
self.file_menu.entryconfigure(1, label=_('Save Raw Data...')) # Menu item self.file_menu.entryconfigure(1, label=_('Save Raw Data...')) # LANG: Menu item
self.file_menu.entryconfigure(2, label=_('Settings')) # Item in the File menu on Windows self.file_menu.entryconfigure(2, label=_('Settings')) # LANG: Item in the File menu on Windows
self.file_menu.entryconfigure(4, label=_('Exit')) # Item in the File menu on Windows self.file_menu.entryconfigure(4, label=_('Exit')) # LANG: Item in the File menu on Windows
# Help menu # Help menu
self.help_menu.entryconfigure(0, label=_('Documentation')) # Help menu item self.help_menu.entryconfigure(0, label=_('Documentation')) # LANG: Help menu item
self.help_menu.entryconfigure(1, label=_('Privacy Policy')) # Help menu item self.help_menu.entryconfigure(1, label=_('Privacy Policy')) # LANG: Help menu item
self.help_menu.entryconfigure(2, label=_('Release Notes')) # Help menu item self.help_menu.entryconfigure(2, label=_('Release Notes')) # LANG: Help menu item
self.help_menu.entryconfigure(3, label=_('Check for Updates...')) # Menu item self.help_menu.entryconfigure(3, label=_('Check for Updates...')) # LANG: Menu item
self.help_menu.entryconfigure(4, label=_("About {APP}").format(APP=applongname)) # App menu entry self.help_menu.entryconfigure(4, label=_("About {APP}").format(APP=applongname)) # LANG: App menu entry
# Edit menu # Edit menu
self.edit_menu.entryconfigure(0, label=_('Copy')) # As in Copy and Paste self.edit_menu.entryconfigure(0, label=_('Copy')) # LANG: As in Copy and Paste
def login(self): def login(self):
"""Initiate CAPI/Frontier login and set other necessary state.""" """Initiate CAPI/Frontier login and set other necessary state."""
@ -1004,9 +1005,9 @@ class AppWindow(object):
return { return {
None: '', None: '',
'Idle': '', 'Idle': '',
'FighterCon': _('Fighter'), # Multicrew role 'FighterCon': _('Fighter'), # LANG: Multicrew role
'FireCon': _('Gunner'), # Multicrew role 'FireCon': _('Gunner'), # LANG: Multicrew role
'FlightCon': _('Helm'), # Multicrew role 'FlightCon': _('Helm'), # LANG: Multicrew role
}.get(role, role) }.get(role, role)
if monitor.thread is None: if monitor.thread is None:
@ -1024,7 +1025,7 @@ class AppWindow(object):
self.cooldown() self.cooldown()
if monitor.cmdr and monitor.state['Captain']: if monitor.cmdr and monitor.state['Captain']:
self.cmdr['text'] = f'{monitor.cmdr} / {monitor.state["Captain"]}' self.cmdr['text'] = f'{monitor.cmdr} / {monitor.state["Captain"]}'
self.ship_label['text'] = _('Role') + ':' # Multicrew role label in main window self.ship_label['text'] = _('Role') + ':' # LANG: Multicrew role label in main window
self.ship.configure(state=tk.NORMAL, text=crewroletext(monitor.state['Role']), url=None) self.ship.configure(state=tk.NORMAL, text=crewroletext(monitor.state['Role']), url=None)
elif monitor.cmdr: elif monitor.cmdr:
@ -1034,7 +1035,7 @@ class AppWindow(object):
else: else:
self.cmdr['text'] = monitor.cmdr self.cmdr['text'] = monitor.cmdr
self.ship_label['text'] = _('Ship') + ':' # Main window self.ship_label['text'] = _('Ship') + ':' # LANG: Main window
# TODO: Show something else when on_foot # TODO: Show something else when on_foot
if monitor.state['ShipName']: if monitor.state['ShipName']:
@ -1057,7 +1058,7 @@ class AppWindow(object):
else: else:
self.cmdr['text'] = '' self.cmdr['text'] = ''
self.ship_label['text'] = _('Ship') + ':' # Main window self.ship_label['text'] = _('Ship') + ':' # LANG: Main window
self.ship['text'] = '' self.ship['text'] = ''
if monitor.cmdr and monitor.is_beta: if monitor.cmdr and monitor.is_beta:
@ -1166,7 +1167,7 @@ class AppWindow(object):
""" """
try: try:
companion.session.auth_callback() companion.session.auth_callback()
# Successfully authenticated with the Frontier website # LANG: Successfully authenticated with the Frontier website
self.status['text'] = _('Authentication successful') self.status['text'] = _('Authentication successful')
if platform == 'darwin': if platform == 'darwin':
self.view_menu.entryconfigure(0, state=tk.NORMAL) # Status self.view_menu.entryconfigure(0, state=tk.NORMAL) # Status
@ -1254,7 +1255,7 @@ class AppWindow(object):
self.w.after(1000, self.cooldown) self.w.after(1000, self.cooldown)
else: else:
self.button['text'] = self.theme_button['text'] = _('Update') # Update button in main window self.button['text'] = self.theme_button['text'] = _('Update') # LANG: Update button in main window
self.button['state'] = self.theme_button['state'] = (monitor.cmdr and self.button['state'] = self.theme_button['state'] = (monitor.cmdr and
monitor.mode and monitor.mode and
not monitor.state['Captain'] and not monitor.state['Captain'] and
@ -1730,6 +1731,7 @@ sys.path: {sys.path}'''
) )
# Substitute in the other words. # Substitute in the other words.
# LANG: words for use in python 2 plugin error
popup_text = popup_text.format(PLUGINS=_('Plugins'), FILE=_('File'), SETTINGS=_('Settings'), popup_text = popup_text.format(PLUGINS=_('Plugins'), FILE=_('File'), SETTINGS=_('Settings'),
DISABLED='.disabled') DISABLED='.disabled')
# And now we do need these to be actual \r\n # And now we do need these to be actual \r\n

194
stats.py
View File

@ -47,117 +47,117 @@ def status(data: Dict[str, Any]) -> List[List[str]]:
""" """
# StatsResults assumes these three things are first # StatsResults assumes these three things are first
res = [ res = [
[_('Cmdr'), data['commander']['name']], [_('Cmdr'), data['commander']['name']], # LANG: Cmdr stats
[_('Balance'), str(data['commander'].get('credits', 0))], # Cmdr stats [_('Balance'), str(data['commander'].get('credits', 0))], # LANG: Cmdr stats
[_('Loan'), str(data['commander'].get('debt', 0))], # Cmdr stats [_('Loan'), str(data['commander'].get('debt', 0))], # LANG: Cmdr stats
] ]
RANKS = [ # noqa: N806 # Its a constant, just needs to be updated at runtime RANKS = [ # noqa: N806 # Its a constant, just needs to be updated at runtime
# in output order # in output order
(_('Combat'), 'combat'), # Ranking (_('Combat'), 'combat'), # LANG: Ranking
(_('Trade'), 'trade'), # Ranking (_('Trade'), 'trade'), # LANG: Ranking
(_('Explorer'), 'explore'), # Ranking (_('Explorer'), 'explore'), # LANG: Ranking
(_('CQC'), 'cqc'), # Ranking (_('CQC'), 'cqc'), # LANG: Ranking
(_('Federation'), 'federation'), # Ranking (_('Federation'), 'federation'), # LANG: Ranking
(_('Empire'), 'empire'), # Ranking (_('Empire'), 'empire'), # LANG: Ranking
(_('Powerplay'), 'power'), # Ranking (_('Powerplay'), 'power'), # LANG: Ranking
# ??? , 'crime'), # Ranking # ??? , 'crime'), # LANG: Ranking
# ??? , 'service'), # Ranking # ??? , 'service'), # LANG: Ranking
] ]
RANK_NAMES = { # noqa: N806 # Its a constant, just needs to be updated at runtime RANK_NAMES = { # noqa: N806 # Its a constant, just needs to be updated at runtime
# http://elite-dangerous.wikia.com/wiki/Pilots_Federation#Ranks # http://elite-dangerous.wikia.com/wiki/Pilots_Federation#Ranks
'combat': [ 'combat': [
_('Harmless'), # Combat rank _('Harmless'), # LANG: Combat rank
_('Mostly Harmless'), # Combat rank _('Mostly Harmless'), # LANG: Combat rank
_('Novice'), # Combat rank _('Novice'), # LANG: Combat rank
_('Competent'), # Combat rank _('Competent'), # LANG: Combat rank
_('Expert'), # Combat rank _('Expert'), # LANG: Combat rank
_('Master'), # Combat rank _('Master'), # LANG: Combat rank
_('Dangerous'), # Combat rank _('Dangerous'), # LANG: Combat rank
_('Deadly'), # Combat rank _('Deadly'), # LANG: Combat rank
_('Elite'), # Top rank _('Elite'), # LANG: Top rank
], ],
'trade': [ 'trade': [
_('Penniless'), # Trade rank _('Penniless'), # LANG: Trade rank
_('Mostly Penniless'), # Trade rank _('Mostly Penniless'), # LANG: Trade rank
_('Peddler'), # Trade rank _('Peddler'), # LANG: Trade rank
_('Dealer'), # Trade rank _('Dealer'), # LANG: Trade rank
_('Merchant'), # Trade rank _('Merchant'), # LANG: Trade rank
_('Broker'), # Trade rank _('Broker'), # LANG: Trade rank
_('Entrepreneur'), # Trade rank _('Entrepreneur'), # LANG: Trade rank
_('Tycoon'), # Trade rank _('Tycoon'), # LANG: Trade rank
_('Elite') # Top rank _('Elite') # LANG: Top rank
], ],
'explore': [ 'explore': [
_('Aimless'), # Explorer rank _('Aimless'), # LANG: Explorer rank
_('Mostly Aimless'), # Explorer rank _('Mostly Aimless'), # LANG: Explorer rank
_('Scout'), # Explorer rank _('Scout'), # LANG: Explorer rank
_('Surveyor'), # Explorer rank _('Surveyor'), # LANG: Explorer rank
_('Trailblazer'), # Explorer rank _('Trailblazer'), # LANG: Explorer rank
_('Pathfinder'), # Explorer rank _('Pathfinder'), # LANG: Explorer rank
_('Ranger'), # Explorer rank _('Ranger'), # LANG: Explorer rank
_('Pioneer'), # Explorer rank _('Pioneer'), # LANG: Explorer rank
_('Elite') # Top rank _('Elite') # LANG: Top rank
], ],
'cqc': [ 'cqc': [
_('Helpless'), # CQC rank _('Helpless'), # LANG: CQC rank
_('Mostly Helpless'), # CQC rank _('Mostly Helpless'), # LANG: CQC rank
_('Amateur'), # CQC rank _('Amateur'), # LANG: CQC rank
_('Semi Professional'), # CQC rank _('Semi Professional'), # LANG: CQC rank
_('Professional'), # CQC rank _('Professional'), # LANG: CQC rank
_('Champion'), # CQC rank _('Champion'), # LANG: CQC rank
_('Hero'), # CQC rank _('Hero'), # LANG: CQC rank
_('Gladiator'), # CQC rank _('Gladiator'), # LANG: CQC rank
_('Elite') # Top rank _('Elite') # LANG: Top rank
], ],
# http://elite-dangerous.wikia.com/wiki/Federation#Ranks # http://elite-dangerous.wikia.com/wiki/Federation#Ranks
'federation': [ 'federation': [
_('None'), # No rank _('None'), # LANG: No rank
_('Recruit'), # Federation rank _('Recruit'), # LANG: Federation rank
_('Cadet'), # Federation rank _('Cadet'), # LANG: Federation rank
_('Midshipman'), # Federation rank _('Midshipman'), # LANG: Federation rank
_('Petty Officer'), # Federation rank _('Petty Officer'), # LANG: Federation rank
_('Chief Petty Officer'), # Federation rank _('Chief Petty Officer'), # LANG: Federation rank
_('Warrant Officer'), # Federation rank _('Warrant Officer'), # LANG: Federation rank
_('Ensign'), # Federation rank _('Ensign'), # LANG: Federation rank
_('Lieutenant'), # Federation rank _('Lieutenant'), # LANG: Federation rank
_('Lieutenant Commander'), # Federation rank _('Lieutenant Commander'), # LANG: Federation rank
_('Post Commander'), # Federation rank _('Post Commander'), # LANG: Federation rank
_('Post Captain'), # Federation rank _('Post Captain'), # LANG: Federation rank
_('Rear Admiral'), # Federation rank _('Rear Admiral'), # LANG: Federation rank
_('Vice Admiral'), # Federation rank _('Vice Admiral'), # LANG: Federation rank
_('Admiral') # Federation rank _('Admiral') # LANG: Federation rank
], ],
# http://elite-dangerous.wikia.com/wiki/Empire#Ranks # http://elite-dangerous.wikia.com/wiki/Empire#Ranks
'empire': [ 'empire': [
_('None'), # No rank _('None'), # LANG: No rank
_('Outsider'), # Empire rank _('Outsider'), # LANG: Empire rank
_('Serf'), # Empire rank _('Serf'), # LANG: Empire rank
_('Master'), # Empire rank _('Master'), # LANG: Empire rank
_('Squire'), # Empire rank _('Squire'), # LANG: Empire rank
_('Knight'), # Empire rank _('Knight'), # LANG: Empire rank
_('Lord'), # Empire rank _('Lord'), # LANG: Empire rank
_('Baron'), # Empire rank _('Baron'), # LANG: Empire rank
_('Viscount'), # Empire rank _('Viscount'), # LANG: Empire rank
_('Count'), # Empire rank _('Count'), # LANG: Empire rank
_('Earl'), # Empire rank _('Earl'), # LANG: Empire rank
_('Marquis'), # Empire rank _('Marquis'), # LANG: Empire rank
_('Duke'), # Empire rank _('Duke'), # LANG: Empire rank
_('Prince'), # Empire rank _('Prince'), # LANG: Empire rank
_('King') # Empire rank _('King') # LANG: Empire rank
], ],
# http://elite-dangerous.wikia.com/wiki/Ratings # http://elite-dangerous.wikia.com/wiki/Ratings
'power': [ 'power': [
_('None'), # No rank _('None'), # LANG: No rank
_('Rating 1'), # Power rank _('Rating 1'), # LANG: Power rank
_('Rating 2'), # Power rank _('Rating 2'), # LANG: Power rank
_('Rating 3'), # Power rank _('Rating 3'), # LANG: Power rank
_('Rating 4'), # Power rank _('Rating 4'), # LANG: Power rank
_('Rating 5') # Power rank _('Rating 5') # LANG: Power rank
], ],
} }
@ -169,7 +169,7 @@ def status(data: Dict[str, Any]) -> List[List[str]]:
res.append([title, names[rank] if rank < len(names) else f'Rank {rank}']) res.append([title, names[rank] if rank < len(names) else f'Rank {rank}'])
else: else:
res.append([title, _('None')]) # No rank res.append([title, _('None')]) # LANG: No rank
return res return res
@ -291,7 +291,9 @@ class StatsDialog():
return return
if not data.get('commander') or not data['commander'].get('name', '').strip(): if not data.get('commander') or not data['commander'].get('name', '').strip():
self.status['text'] = _("Who are you?!") # Shouldn't happen # Shouldn't happen
# LANG: Unknown commander
self.status['text'] = _("Who are you?!")
elif ( elif (
not data.get('lastSystem') not data.get('lastSystem')
@ -299,10 +301,14 @@ class StatsDialog():
or not data.get('lastStarport') or not data.get('lastStarport')
or not data['lastStarport'].get('name', '').strip() or not data['lastStarport'].get('name', '').strip()
): ):
self.status['text'] = _("Where are you?!") # Shouldn't happen # Shouldn't happen
# LANG: Unknown location
self.status['text'] = _("Where are you?!")
elif not data.get('ship') or not data['ship'].get('modules') or not data['ship'].get('name', '').strip(): elif not data.get('ship') or not data['ship'].get('modules') or not data['ship'].get('name', '').strip():
self.status['text'] = _("What are you flying?!") # Shouldn't happen # Shouldn't happen
# LANG: Unknown ship
self.status['text'] = _("What are you flying?!")
else: else:
self.status['text'] = '' self.status['text'] = ''
@ -350,14 +356,14 @@ class StatsResults(tk.Toplevel):
self.addpagerow(page, thing, with_copy=True) self.addpagerow(page, thing, with_copy=True)
ttk.Frame(page).grid(pady=5) # bottom spacer ttk.Frame(page).grid(pady=5) # bottom spacer
notebook.add(page, text=_('Status')) # Status dialog title notebook.add(page, text=_('Status')) # LANG: Status dialog title
page = self.addpage(notebook, [ page = self.addpage(notebook, [
_('Ship'), # Status dialog subtitle _('Ship'), # LANG: Status dialog subtitle
'', '',
_('System'), # Main window _('System'), # LANG: Main window
_('Station'), # Status dialog subtitle _('Station'), # LANG: Status dialog subtitle
_('Value'), # Status dialog subtitle - CR value of ship _('Value'), # LANG: Status dialog subtitle - CR value of ship
]) ])
shiplist = ships(data) shiplist = ships(data)
@ -366,7 +372,7 @@ class StatsResults(tk.Toplevel):
self.addpagerow(page, list(ship_data[1:-1]) + [self.credits(int(ship_data[-1]))], with_copy=True) self.addpagerow(page, list(ship_data[1:-1]) + [self.credits(int(ship_data[-1]))], with_copy=True)
ttk.Frame(page).grid(pady=5) # bottom spacer ttk.Frame(page).grid(pady=5) # bottom spacer
notebook.add(page, text=_('Ships')) # Status dialog title notebook.add(page, text=_('Ships')) # LANG: Status dialog title
if platform != 'darwin': if platform != 'darwin':
buttonframe = ttk.Frame(frame) buttonframe = ttk.Frame(frame)