From 2fb47377a308f22caa7690f913a7a5af91039637 Mon Sep 17 00:00:00 2001 From: A_D Date: Mon, 7 Jun 2021 12:41:12 +0200 Subject: [PATCH] Added comments --- EDMarketConnector.py | 86 +++++++++---------- stats.py | 194 ++++++++++++++++++++++--------------------- 2 files changed, 144 insertions(+), 136 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index ff76113c..4fc058ff 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -414,7 +414,7 @@ class AppWindow(object): else: 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.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) @@ -626,7 +626,7 @@ class AppWindow(object): return if (suit := monitor.state.get('SuitCurrent')) is None: - self.suit['text'] = f'<{_("Unknown")}>' + self.suit['text'] = f'<{_("Unknown")}>' # LANG: Unknown suit return suitname = suit['edmcName'] @@ -701,48 +701,49 @@ class AppWindow(object): def set_labels(self): """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 self.ship_label['text'] = (monitor.state['Captain'] and _('Role') or _('Ship')) + ':' # Main window - self.suit_label['text'] = _('Suit') + ':' # Main window - self.system_label['text'] = _('System') + ':' # Main window - self.station_label['text'] = _('Station') + ':' # Main window - self.button['text'] = self.theme_button['text'] = _('Update') # Update button in main window + self.suit_label['text'] = _('Suit') + ':' # LANG: Main window + self.system_label['text'] = _('System') + ':' # LANG: Main window + self.station_label['text'] = _('Station') + ':' # LANG: Main window + self.button['text'] = self.theme_button['text'] = _('Update') # LANG: Update button in main window if platform == 'darwin': - self.menubar.entryconfigure(1, label=_('File')) # Menu title - self.menubar.entryconfigure(2, label=_('Edit')) # Menu title - self.menubar.entryconfigure(3, label=_('View')) # Menu title on OSX - self.menubar.entryconfigure(4, label=_('Window')) # Menu title on OSX - self.menubar.entryconfigure(5, label=_('Help')) # Menu title - self.system_menu.entryconfigure(0, label=_("About {APP}").format(APP=applongname)) # App menu entry on OSX - self.system_menu.entryconfigure(1, label=_("Check for Updates...")) # Menu item - self.file_menu.entryconfigure(0, label=_('Save Raw Data...')) # Menu item - self.view_menu.entryconfigure(0, label=_('Status')) # Menu item - self.help_menu.entryconfigure(1, label=_('Privacy Policy')) # Help menu item - self.help_menu.entryconfigure(2, label=_('Release Notes')) # Help menu item + self.menubar.entryconfigure(1, label=_('File')) # LANG: Menu title on OSX + self.menubar.entryconfigure(2, label=_('Edit')) # LANG: Menu title on OSX + self.menubar.entryconfigure(3, label=_('View')) # LANG: Menu title on OSX + self.menubar.entryconfigure(4, label=_('Window')) # LANG: Menu title on OSX + self.menubar.entryconfigure(5, label=_('Help')) # LANG: Menu title on OSX + self.system_menu.entryconfigure(0, label=_("About {APP}").format( + APP=applongname)) # LANG: App menu entry on OSX + self.system_menu.entryconfigure(1, label=_("Check for Updates...")) # LANG: Menu item + self.file_menu.entryconfigure(0, label=_('Save Raw Data...')) # LANG: Menu item + self.view_menu.entryconfigure(0, label=_('Status')) # LANG: 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: - self.menubar.entryconfigure(1, label=_('File')) # Menu title - self.menubar.entryconfigure(2, label=_('Edit')) # Menu title - self.menubar.entryconfigure(3, label=_('Help')) # Menu title - self.theme_file_menu['text'] = _('File') # Menu title - self.theme_edit_menu['text'] = _('Edit') # Menu title - self.theme_help_menu['text'] = _('Help') # Menu title + self.menubar.entryconfigure(1, label=_('File')) # LANG: Menu title + self.menubar.entryconfigure(2, label=_('Edit')) # LANG: Menu title + self.menubar.entryconfigure(3, label=_('Help')) # LANG: Menu title + self.theme_file_menu['text'] = _('File') # LANG: Menu title + self.theme_edit_menu['text'] = _('Edit') # LANG: Menu title + self.theme_help_menu['text'] = _('Help') # LANG: Menu title # File menu - self.file_menu.entryconfigure(0, label=_('Status')) # Menu item - self.file_menu.entryconfigure(1, label=_('Save Raw Data...')) # Menu item - self.file_menu.entryconfigure(2, label=_('Settings')) # 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(0, label=_('Status')) # LANG: Menu item + self.file_menu.entryconfigure(1, label=_('Save Raw Data...')) # LANG: Menu item + self.file_menu.entryconfigure(2, label=_('Settings')) # LANG: Item in the File menu on Windows + self.file_menu.entryconfigure(4, label=_('Exit')) # LANG: Item in the File menu on Windows # Help menu - self.help_menu.entryconfigure(0, label=_('Documentation')) # Help menu item - self.help_menu.entryconfigure(1, label=_('Privacy Policy')) # Help menu item - self.help_menu.entryconfigure(2, label=_('Release Notes')) # Help menu item - self.help_menu.entryconfigure(3, label=_('Check for Updates...')) # Menu item - self.help_menu.entryconfigure(4, label=_("About {APP}").format(APP=applongname)) # App menu entry + self.help_menu.entryconfigure(0, label=_('Documentation')) # LANG: 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 + self.help_menu.entryconfigure(3, label=_('Check for Updates...')) # LANG: Menu item + self.help_menu.entryconfigure(4, label=_("About {APP}").format(APP=applongname)) # LANG: App menu entry # 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): """Initiate CAPI/Frontier login and set other necessary state.""" @@ -1004,9 +1005,9 @@ class AppWindow(object): return { None: '', 'Idle': '', - 'FighterCon': _('Fighter'), # Multicrew role - 'FireCon': _('Gunner'), # Multicrew role - 'FlightCon': _('Helm'), # Multicrew role + 'FighterCon': _('Fighter'), # LANG: Multicrew role + 'FireCon': _('Gunner'), # LANG: Multicrew role + 'FlightCon': _('Helm'), # LANG: Multicrew role }.get(role, role) if monitor.thread is None: @@ -1024,7 +1025,7 @@ class AppWindow(object): self.cooldown() if monitor.cmdr and 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) elif monitor.cmdr: @@ -1034,7 +1035,7 @@ class AppWindow(object): else: 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 if monitor.state['ShipName']: @@ -1057,7 +1058,7 @@ class AppWindow(object): else: self.cmdr['text'] = '' - self.ship_label['text'] = _('Ship') + ':' # Main window + self.ship_label['text'] = _('Ship') + ':' # LANG: Main window self.ship['text'] = '' if monitor.cmdr and monitor.is_beta: @@ -1166,7 +1167,7 @@ class AppWindow(object): """ try: companion.session.auth_callback() - # Successfully authenticated with the Frontier website + # LANG: Successfully authenticated with the Frontier website self.status['text'] = _('Authentication successful') if platform == 'darwin': self.view_menu.entryconfigure(0, state=tk.NORMAL) # Status @@ -1254,7 +1255,7 @@ class AppWindow(object): self.w.after(1000, self.cooldown) 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 monitor.mode and not monitor.state['Captain'] and @@ -1730,6 +1731,7 @@ sys.path: {sys.path}''' ) # 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'), DISABLED='.disabled') # And now we do need these to be actual \r\n diff --git a/stats.py b/stats.py index 704e4703..2eab96f2 100644 --- a/stats.py +++ b/stats.py @@ -47,117 +47,117 @@ def status(data: Dict[str, Any]) -> List[List[str]]: """ # StatsResults assumes these three things are first res = [ - [_('Cmdr'), data['commander']['name']], - [_('Balance'), str(data['commander'].get('credits', 0))], # Cmdr stats - [_('Loan'), str(data['commander'].get('debt', 0))], # Cmdr stats + [_('Cmdr'), data['commander']['name']], # LANG: Cmdr stats + [_('Balance'), str(data['commander'].get('credits', 0))], # LANG: 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 # in output order - (_('Combat'), 'combat'), # Ranking - (_('Trade'), 'trade'), # Ranking - (_('Explorer'), 'explore'), # Ranking - (_('CQC'), 'cqc'), # Ranking - (_('Federation'), 'federation'), # Ranking - (_('Empire'), 'empire'), # Ranking - (_('Powerplay'), 'power'), # Ranking - # ??? , 'crime'), # Ranking - # ??? , 'service'), # Ranking + (_('Combat'), 'combat'), # LANG: Ranking + (_('Trade'), 'trade'), # LANG: Ranking + (_('Explorer'), 'explore'), # LANG: Ranking + (_('CQC'), 'cqc'), # LANG: Ranking + (_('Federation'), 'federation'), # LANG: Ranking + (_('Empire'), 'empire'), # LANG: Ranking + (_('Powerplay'), 'power'), # LANG: Ranking + # ??? , 'crime'), # LANG: Ranking + # ??? , 'service'), # LANG: Ranking ] RANK_NAMES = { # noqa: N806 # Its a constant, just needs to be updated at runtime # http://elite-dangerous.wikia.com/wiki/Pilots_Federation#Ranks 'combat': [ - _('Harmless'), # Combat rank - _('Mostly Harmless'), # Combat rank - _('Novice'), # Combat rank - _('Competent'), # Combat rank - _('Expert'), # Combat rank - _('Master'), # Combat rank - _('Dangerous'), # Combat rank - _('Deadly'), # Combat rank - _('Elite'), # Top rank + _('Harmless'), # LANG: Combat rank + _('Mostly Harmless'), # LANG: Combat rank + _('Novice'), # LANG: Combat rank + _('Competent'), # LANG: Combat rank + _('Expert'), # LANG: Combat rank + _('Master'), # LANG: Combat rank + _('Dangerous'), # LANG: Combat rank + _('Deadly'), # LANG: Combat rank + _('Elite'), # LANG: Top rank ], 'trade': [ - _('Penniless'), # Trade rank - _('Mostly Penniless'), # Trade rank - _('Peddler'), # Trade rank - _('Dealer'), # Trade rank - _('Merchant'), # Trade rank - _('Broker'), # Trade rank - _('Entrepreneur'), # Trade rank - _('Tycoon'), # Trade rank - _('Elite') # Top rank + _('Penniless'), # LANG: Trade rank + _('Mostly Penniless'), # LANG: Trade rank + _('Peddler'), # LANG: Trade rank + _('Dealer'), # LANG: Trade rank + _('Merchant'), # LANG: Trade rank + _('Broker'), # LANG: Trade rank + _('Entrepreneur'), # LANG: Trade rank + _('Tycoon'), # LANG: Trade rank + _('Elite') # LANG: Top rank ], 'explore': [ - _('Aimless'), # Explorer rank - _('Mostly Aimless'), # Explorer rank - _('Scout'), # Explorer rank - _('Surveyor'), # Explorer rank - _('Trailblazer'), # Explorer rank - _('Pathfinder'), # Explorer rank - _('Ranger'), # Explorer rank - _('Pioneer'), # Explorer rank - _('Elite') # Top rank + _('Aimless'), # LANG: Explorer rank + _('Mostly Aimless'), # LANG: Explorer rank + _('Scout'), # LANG: Explorer rank + _('Surveyor'), # LANG: Explorer rank + _('Trailblazer'), # LANG: Explorer rank + _('Pathfinder'), # LANG: Explorer rank + _('Ranger'), # LANG: Explorer rank + _('Pioneer'), # LANG: Explorer rank + _('Elite') # LANG: Top rank ], 'cqc': [ - _('Helpless'), # CQC rank - _('Mostly Helpless'), # CQC rank - _('Amateur'), # CQC rank - _('Semi Professional'), # CQC rank - _('Professional'), # CQC rank - _('Champion'), # CQC rank - _('Hero'), # CQC rank - _('Gladiator'), # CQC rank - _('Elite') # Top rank + _('Helpless'), # LANG: CQC rank + _('Mostly Helpless'), # LANG: CQC rank + _('Amateur'), # LANG: CQC rank + _('Semi Professional'), # LANG: CQC rank + _('Professional'), # LANG: CQC rank + _('Champion'), # LANG: CQC rank + _('Hero'), # LANG: CQC rank + _('Gladiator'), # LANG: CQC rank + _('Elite') # LANG: Top rank ], # http://elite-dangerous.wikia.com/wiki/Federation#Ranks 'federation': [ - _('None'), # No rank - _('Recruit'), # Federation rank - _('Cadet'), # Federation rank - _('Midshipman'), # Federation rank - _('Petty Officer'), # Federation rank - _('Chief Petty Officer'), # Federation rank - _('Warrant Officer'), # Federation rank - _('Ensign'), # Federation rank - _('Lieutenant'), # Federation rank - _('Lieutenant Commander'), # Federation rank - _('Post Commander'), # Federation rank - _('Post Captain'), # Federation rank - _('Rear Admiral'), # Federation rank - _('Vice Admiral'), # Federation rank - _('Admiral') # Federation rank + _('None'), # LANG: No rank + _('Recruit'), # LANG: Federation rank + _('Cadet'), # LANG: Federation rank + _('Midshipman'), # LANG: Federation rank + _('Petty Officer'), # LANG: Federation rank + _('Chief Petty Officer'), # LANG: Federation rank + _('Warrant Officer'), # LANG: Federation rank + _('Ensign'), # LANG: Federation rank + _('Lieutenant'), # LANG: Federation rank + _('Lieutenant Commander'), # LANG: Federation rank + _('Post Commander'), # LANG: Federation rank + _('Post Captain'), # LANG: Federation rank + _('Rear Admiral'), # LANG: Federation rank + _('Vice Admiral'), # LANG: Federation rank + _('Admiral') # LANG: Federation rank ], # http://elite-dangerous.wikia.com/wiki/Empire#Ranks 'empire': [ - _('None'), # No rank - _('Outsider'), # Empire rank - _('Serf'), # Empire rank - _('Master'), # Empire rank - _('Squire'), # Empire rank - _('Knight'), # Empire rank - _('Lord'), # Empire rank - _('Baron'), # Empire rank - _('Viscount'), # Empire rank - _('Count'), # Empire rank - _('Earl'), # Empire rank - _('Marquis'), # Empire rank - _('Duke'), # Empire rank - _('Prince'), # Empire rank - _('King') # Empire rank + _('None'), # LANG: No rank + _('Outsider'), # LANG: Empire rank + _('Serf'), # LANG: Empire rank + _('Master'), # LANG: Empire rank + _('Squire'), # LANG: Empire rank + _('Knight'), # LANG: Empire rank + _('Lord'), # LANG: Empire rank + _('Baron'), # LANG: Empire rank + _('Viscount'), # LANG: Empire rank + _('Count'), # LANG: Empire rank + _('Earl'), # LANG: Empire rank + _('Marquis'), # LANG: Empire rank + _('Duke'), # LANG: Empire rank + _('Prince'), # LANG: Empire rank + _('King') # LANG: Empire rank ], # http://elite-dangerous.wikia.com/wiki/Ratings 'power': [ - _('None'), # No rank - _('Rating 1'), # Power rank - _('Rating 2'), # Power rank - _('Rating 3'), # Power rank - _('Rating 4'), # Power rank - _('Rating 5') # Power rank + _('None'), # LANG: No rank + _('Rating 1'), # LANG: Power rank + _('Rating 2'), # LANG: Power rank + _('Rating 3'), # LANG: Power rank + _('Rating 4'), # LANG: 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}']) else: - res.append([title, _('None')]) # No rank + res.append([title, _('None')]) # LANG: No rank return res @@ -291,7 +291,9 @@ class StatsDialog(): return 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 ( not data.get('lastSystem') @@ -299,10 +301,14 @@ class StatsDialog(): or not data.get('lastStarport') 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(): - self.status['text'] = _("What are you flying?!") # Shouldn't happen + # Shouldn't happen + # LANG: Unknown ship + self.status['text'] = _("What are you flying?!") else: self.status['text'] = '' @@ -350,14 +356,14 @@ class StatsResults(tk.Toplevel): self.addpagerow(page, thing, with_copy=True) 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, [ - _('Ship'), # Status dialog subtitle + _('Ship'), # LANG: Status dialog subtitle '', - _('System'), # Main window - _('Station'), # Status dialog subtitle - _('Value'), # Status dialog subtitle - CR value of ship + _('System'), # LANG: Main window + _('Station'), # LANG: Status dialog subtitle + _('Value'), # LANG: Status dialog subtitle - CR value of ship ]) 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) 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': buttonframe = ttk.Frame(frame)