i18n: fix crash on right clicking a Tactical Destroyer fit

This commit is contained in:
zhaoweny
2020-07-01 11:48:37 +08:00
parent 85e779469f
commit 8cc770467e

View File

@@ -14,6 +14,11 @@ class ChangeShipTacticalMode(ContextMenuUnconditional):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.modeMap = {
'Defense': _t('Defense'),
'Propulsion': _t('Propulsion'),
'Sharpshooter': _t('Sharpshooter')
}
def display(self, callingWindow, srcContext):
if self.mainFrame.getActiveFit() is None or srcContext != "fittingShip":
@@ -32,7 +37,12 @@ class ChangeShipTacticalMode(ContextMenuUnconditional):
return _t("Tactical Mode")
def addMode(self, menu, mode):
label = mode.item.name.rsplit()[-2]
label = None
for raw, locaized in self.modeMap.items():
if raw in mode.item.typeName:
label = locaized
break
id = ContextMenuUnconditional.nextID()
self.modeIds[id] = mode
menuItem = wx.MenuItem(menu, id, label, kind=wx.ITEM_RADIO)