i18n: improve string literal annotations

1. annotate more strings for statsViews, itemStats
2. fix raw title and description for preferences
3. fix crash on opening AttributeEditor, characterEditor
This commit is contained in:
zhaoweny
2020-06-22 17:55:58 +08:00
parent 07696ce0ed
commit 889e901cbd
20 changed files with 69 additions and 67 deletions

View File

@@ -9,9 +9,9 @@ _t = wx.GetTranslation
class PFContextMenuPref(PreferenceView):
title = _t("Context Menus")
def populatePanel(self, panel):
self.title = _t("Context Menus")
self.settings = ContextMenuSettings.getInstance()
self.mainFrame = gui.mainFrame.MainFrame.getInstance()

View File

@@ -10,9 +10,9 @@ _t = wx.GetTranslation
class PFGeneralPref(PreferenceView):
title = _t("Database")
def populatePanel(self, panel):
self.title = _t("Database")
self.dirtySettings = False
mainSizer = wx.BoxSizer(wx.VERTICAL)

View File

@@ -16,8 +16,6 @@ _t = wx.GetTranslation
class PFFittingEnginePref(PreferenceView):
title = _t("Fitting Engine")
def __init__(self):
self.dirtySettings = False
@@ -26,6 +24,7 @@ class PFFittingEnginePref(PreferenceView):
# noinspection PyAttributeOutsideInit
def populatePanel(self, panel):
self.title = _t("Fitting Engine")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
mainSizer = wx.BoxSizer(wx.VERTICAL)

View File

@@ -11,10 +11,9 @@ _t = wx.GetTranslation
class PFEsiPref(PreferenceView):
title = _t("EVE SSO")
def populatePanel(self, panel):
self.title = _t("EVE SSO")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.settings = EsiSettings.getInstance()
self.dirtySettings = False

View File

@@ -12,9 +12,9 @@ _t = wx.GetTranslation
class PFGeneralPref(PreferenceView):
title = _t("General")
def populatePanel(self, panel):
self.title = _t("General")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.dirtySettings = False
self.openFitsSettings = SettingsProvider.getInstance().getSettings("pyfaPrevOpenFits",
@@ -93,7 +93,7 @@ class PFGeneralPref(PreferenceView):
langSizer = wx.BoxSizer(wx.HORIZONTAL)
self.stLangLabel = wx.StaticText(panel, wx.ID_ANY, _t("Language (restart required): "), wx.DefaultPosition, wx.DefaultSize, 0)
self.stLangLabel = wx.StaticText(panel, wx.ID_ANY, _t("Language (restart required):"), wx.DefaultPosition, wx.DefaultSize, 0)
self.stLangLabel.Wrap(-1)
langSizer.Add(self.stLangLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)

View File

@@ -14,14 +14,14 @@ _t = wx.GetTranslation
class PFHTMLExportPref(PreferenceView):
title = _t("HTML Export")
desc = _t("HTML Export (File > Export HTML) allows you to export your entire fitting "
"database into an HTML file at the specified location. This file can be "
"used to easily open your fits in a web-based fitting program")
desc4 = _t("Export Fittings in a minimal HTML Version, just containing the fittings links "
"without any visual styling")
def populatePanel(self, panel):
self.title = _t("HTML Export")
self.desc = _t("HTML Export (File > Export HTML) allows you to export your entire fitting "
"database into an HTML file at the specified location. This file can be "
"used to easily open your fits in a web-based fitting program")
self.desc4 = _t("Export Fittings in a minimal HTML Version, just containing the fittings links "
"without any visual styling")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.HTMLExportSettings = HTMLExportSettings.getInstance()
self.dirtySettings = False

View File

@@ -14,9 +14,9 @@ def OnDumpLogs(event):
class PFGeneralPref(PreferenceView):
title = _t("Logging")
def populatePanel(self, panel):
self.title = _t("Logging")
self.dirtySettings = False
mainSizer = wx.BoxSizer(wx.VERTICAL)

View File

@@ -15,12 +15,12 @@ _t = wx.GetTranslation
class PFMarketPref(PreferenceView):
title = _t("Market & Prices")
def __init__(self):
self.priceSettings = MarketPriceSettings.getInstance()
def populatePanel(self, panel):
self.title = _t("Market & Prices")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.sFit = Fit.getInstance()

View File

@@ -12,10 +12,9 @@ _t = wx.GetTranslation
class PFNetworkPref(PreferenceView):
title = _t("Network")
def populatePanel(self, panel):
self.title = _t("Network")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.settings = NetworkSettings.getInstance()
self.network = Network.getInstance()

View File

@@ -9,7 +9,6 @@ _t = wx.GetTranslation
class PFStatViewPref(PreferenceView):
title = _t("Statistics Panel")
def __init__(self):
self.dirtySettings = False
@@ -20,6 +19,7 @@ class PFStatViewPref(PreferenceView):
# noinspection PyAttributeOutsideInit
def populatePanel(self, panel):
self.title = _t("Statistics Panel")
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.stTitle = wx.StaticText(panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0)
@@ -96,12 +96,12 @@ class PFStatViewPref(PreferenceView):
# Row 3
rbSizerRow3 = wx.BoxSizer(wx.HORIZONTAL)
self.rbPrice = wx.RadioBox(panel, -1, _t("Price"), wx.DefaultPosition, wx.DefaultSize, ['None', 'Minimal', 'Full'], 1, wx.RA_SPECIFY_COLS)
self.rbPrice = wx.RadioBox(panel, -1, _t("Price"), wx.DefaultPosition, wx.DefaultSize, [_t('None'), _t('Minimal'), _t('Full')], 1, wx.RA_SPECIFY_COLS)
self.rbPrice.SetSelection(self.settings.get('price'))
rbSizerRow3.Add(self.rbPrice, 1, wx.TOP | wx.RIGHT, 5)
self.rbPrice.Bind(wx.EVT_RADIOBOX, self.OnPriceChange)
self.rbOutgoing = wx.RadioBox(panel, -1, _t("Remote Reps"), wx.DefaultPosition, wx.DefaultSize, ['None', 'Minimal', 'Full'], 1, wx.RA_SPECIFY_COLS)
self.rbOutgoing = wx.RadioBox(panel, -1, _t("Remote Reps"), wx.DefaultPosition, wx.DefaultSize, [_t('None'), _t('Minimal'), _t('Full')], 1, wx.RA_SPECIFY_COLS)
self.rbOutgoing.SetSelection(self.settings.get('outgoing'))
rbSizerRow3.Add(self.rbOutgoing, 1, wx.TOP | wx.RIGHT, 5)
self.rbOutgoing.Bind(wx.EVT_RADIOBOX, self.OnOutgoingChange)

View File

@@ -9,13 +9,13 @@ _t = wx.GetTranslation
class PFUpdatePref(PreferenceView):
title = _t("Updates")
desc = _t("Pyfa can automatically check and notify you of new releases. "
"This feature is toggled in the Network settings. "
"Here, you may allow pre-release notifications and view "
"suppressed release notifications, if any.")
def populatePanel(self, panel):
self.title = _t("Updates")
self.desc = _t("Pyfa can automatically check and notify you of new releases. "
"This feature is toggled in the Network settings. "
"Here, you may allow pre-release notifications and view "
"suppressed release notifications, if any.")
self.UpdateSettings = UpdateSettings.getInstance()
self.dirtySettings = False

View File

@@ -64,7 +64,7 @@ class FirepowerViewFull(StatsView):
counter = 0
for damageType, image in (("weapon", "turret"), ("drone", "droneDPS")):
for label, image, attr in ((_t("Weapon"), "turret", "Weapon"), (_t("Drone"), "droneDPS", "Drone")):
baseBox = wx.BoxSizer(wx.HORIZONTAL)
sizerFirepower.Add(baseBox, 1, wx.ALIGN_LEFT if counter == 0 else wx.ALIGN_CENTER_HORIZONTAL)
@@ -73,13 +73,13 @@ class FirepowerViewFull(StatsView):
box = wx.BoxSizer(wx.VERTICAL)
baseBox.Add(box, 0, wx.ALIGN_CENTER)
box.Add(wx.StaticText(parent, wx.ID_ANY, _t(damageType).capitalize()), 0, wx.ALIGN_LEFT)
box.Add(wx.StaticText(parent, wx.ID_ANY, label), 0, wx.ALIGN_LEFT)
hbox = wx.BoxSizer(wx.HORIZONTAL)
box.Add(hbox, 1, wx.ALIGN_CENTER)
lbl = wx.StaticText(parent, wx.ID_ANY, "0.0 DPS")
setattr(self, "label%sDps%s" % (panel.capitalize(), damageType.capitalize()), lbl)
setattr(self, "label%sDps%s" % (panel.capitalize(), attr), lbl)
hbox.Add(lbl, 0, wx.ALIGN_CENTER)
self._cachedValues.append(0)
@@ -112,7 +112,7 @@ class FirepowerViewFull(StatsView):
image = BitmapLoader.getBitmap("mining_small", "gui")
self.miningyield = wx.BitmapButton(contentPanel, -1, image)
self.miningyield.SetToolTip(wx.ToolTip(_t("Click to toggle to Mining Yield ")))
self.miningyield.SetToolTip(wx.ToolTip(_t("Click to toggle to Mining Yield")))
self.miningyield.Bind(wx.EVT_BUTTON, self.switchToMiningYieldView)
sizerFirepower.Add(self.miningyield, 0, wx.ALIGN_LEFT)

View File

@@ -53,7 +53,10 @@ class PriceViewFull(StatsView):
gridPrice = wx.GridSizer(2, 3, 0, 0)
contentSizer.Add(gridPrice, 0, wx.EXPAND | wx.ALL, 0)
for _type in ("ship", "fittings", "character", "drones", "cargoBay", "total"):
for _type, label in (
("ship", _t("Ship")), ("fittings", _t("Fittings")), ("character", _t("Character")),
("drones", _t("Drones")), ("cargoBay", _t("Cargo bay")), ("total", _t("Total"))
):
if _type in "ship":
image = "ship_big"
elif _type in ("fittings", "total"):
@@ -69,7 +72,7 @@ class PriceViewFull(StatsView):
vbox = wx.BoxSizer(wx.VERTICAL)
box.Add(vbox, 1, wx.EXPAND)
vbox.Add(wx.StaticText(contentPanel, wx.ID_ANY, _t(_type).capitalize()), 0, wx.ALIGN_LEFT)
vbox.Add(wx.StaticText(contentPanel, wx.ID_ANY, label.capitalize()), 0, wx.ALIGN_LEFT)
hbox = wx.BoxSizer(wx.HORIZONTAL)
vbox.Add(hbox)

View File

@@ -53,7 +53,9 @@ class PriceViewMinimal(StatsView):
gridPrice = wx.GridSizer(1, 3, 0, 0)
contentSizer.Add(gridPrice, 0, wx.EXPAND | wx.ALL, 0)
for _type in ("ship", "fittings", "total"):
for _type, label in (
("ship", _t("Ship")), ("fittings", _t("Fittings")), ("total", _t("Total"))
):
image = "%sPrice_big" % _type if _type != "ship" else "ship_big"
box = wx.BoxSizer(wx.HORIZONTAL)
gridPrice.Add(box, 0, wx.ALIGN_TOP)
@@ -63,7 +65,7 @@ class PriceViewMinimal(StatsView):
vbox = wx.BoxSizer(wx.VERTICAL)
box.Add(vbox, 1, wx.EXPAND)
vbox.Add(wx.StaticText(contentPanel, wx.ID_ANY, _t(_type).capitalize()), 0, wx.ALIGN_LEFT)
vbox.Add(wx.StaticText(contentPanel, wx.ID_ANY, label), 0, wx.ALIGN_LEFT)
hbox = wx.BoxSizer(wx.HORIZONTAL)
vbox.Add(hbox)

View File

@@ -58,7 +58,7 @@ class ResistancesViewFull(StatsView):
# Custom header EHP
headerContentSizer = self.headerPanel.Parent.GetHeaderContentSizer()
self.stEff = wx.StaticText(headerPanel, wx.ID_ANY, "(" + _t("Effective HP") + ": ")
self.stEff = wx.StaticText(headerPanel, wx.ID_ANY, "(" + _t("Effective HP: "))
headerContentSizer.Add(self.stEff)
headerPanel.GetParent().AddToggleItem(self.stEff)
@@ -93,7 +93,7 @@ class ResistancesViewFull(StatsView):
bitmap.SetToolTip(tooltip)
sizerResistances.Add(bitmap, wx.GBPosition(row, col), wx.GBSpan(1, 1), wx.ALIGN_CENTER)
col += 1
self.stEHPs = wx.Button(contentPanel, style=wx.BU_EXACTFIT, label="EHP")
self.stEHPs = wx.Button(contentPanel, style=wx.BU_EXACTFIT, label=_t("EHP"))
self.stEHPs.SetToolTip(wx.ToolTip(_t("Click to toggle between effective HP and raw HP")))
self.stEHPs.Bind(wx.EVT_BUTTON, self.toggleEHP)
@@ -184,7 +184,7 @@ class ResistancesViewFull(StatsView):
wx.PostEvent(self.mainFrame, GE.EffectiveHpToggled(effective=True))
return
self.stEHPs.SetLabel("EHP" if self.showEffective else "HP")
self.stEHPs.SetLabel(_t("EHP") if self.showEffective else _t("HP"))
self.activeFit = fit.ID if fit is not None else None
for tankType in ("shield", "armor", "hull"):
@@ -203,24 +203,24 @@ class ResistancesViewFull(StatsView):
ehp = (fit.ehp if self.showEffective else fit.hp) if fit is not None else None
total = 0
for tankType in ("shield", "armor", "hull"):
for tankType, tooltip in (("shield", _t("Shield: ")), ("armor", _t("Armor: ")), ("hull", _t("Hull: "))):
lbl = getattr(self, "labelResistance%sEhp" % tankType.capitalize())
if ehp is not None:
total += ehp[tankType]
rrFactor = fit.ehp[tankType] / fit.hp[tankType]
lbl.SetLabel(formatAmount(ehp[tankType], 3, 0, 9))
lbl.SetToolTip(
wx.ToolTip("%s: %d\nResist Multiplier: x%.2f" % (tankType.capitalize(), ehp[tankType], rrFactor)))
wx.ToolTip(tooltip + "%d\n" % ehp[tankType] + _t("Resist Multiplier: ") + "%.2fx" % rrFactor))
else:
lbl.SetLabel("0")
self.labelEhp.SetLabel("%s" % formatAmount(total, 3, 0, 9))
if self.showEffective:
self.stEff.SetLabel("( Effective HP: ")
self.labelEhp.SetToolTip(wx.ToolTip("Effective: %d HP" % total))
self.stEff.SetLabel("(" + _t("Effective HP: "))
self.labelEhp.SetToolTip(wx.ToolTip(_t("Effective: %d HP") % total))
else:
self.stEff.SetLabel("( Raw HP: ")
self.labelEhp.SetToolTip(wx.ToolTip("Raw: %d HP" % total))
self.stEff.SetLabel("(" + _t("Raw HP: "))
self.labelEhp.SetToolTip(wx.ToolTip(_t("Raw: %d HP") % total))
damagePattern = fit.damagePattern if fit is not None and self.showEffective else None
total = sum((damagePattern.emAmount, damagePattern.thermalAmount,

View File

@@ -646,7 +646,7 @@ class SkillTreeView(wx.Panel):
lvl, dirty = sChar.getSkillLevel(char.ID, skillID)
self.skillTreeListCtrl.SetItemText(treeItem,
1,
_("Level {}").format(int(lvl)) if not isinstance(lvl, str) else lvl)
_t("Level {}").format(int(lvl)) if not isinstance(lvl, str) else lvl)
if not dirty:
self.skillTreeListCtrl.SetItemImage(treeItem, self.skillBookImageId)

View File

@@ -197,7 +197,7 @@ class ItemStatsContainer(wx.Panel):
if config.debug:
self.properties = ItemProperties(self.nbContainer, stuff, item, context)
self.nbContainer.AddPage(self.properties, "Properties")
self.nbContainer.AddPage(self.properties, _t("Properties"))
self.nbContainer.Bind(wx.EVT_LEFT_DOWN, self.mouseHit)
self.SetSizer(mainSizer)

View File

@@ -26,7 +26,7 @@ class AttributeEditor(AuxiliaryFrame):
def __init__(self, parent):
super().__init__(
parent, wx.ID_ANY, title=_("Attribute Editor"), pos=wx.DefaultPosition,
parent, wx.ID_ANY, title=_t("Attribute Editor"), pos=wx.DefaultPosition,
size=wx.Size(650, 600), resizeable=True)
i = wx.Icon(BitmapLoader.getBitmap("fit_rename_small", "gui"))
@@ -36,11 +36,11 @@ class AttributeEditor(AuxiliaryFrame):
menubar = wx.MenuBar()
fileMenu = wx.Menu()
fileImport = fileMenu.Append(wx.ID_ANY, _('Import'), _('Import overrides'))
fileExport = fileMenu.Append(wx.ID_ANY, _('Export'), _('Import overrides'))
fileClear = fileMenu.Append(wx.ID_ANY, _('Clear All'), _('Clear all overrides'))
fileImport = fileMenu.Append(wx.ID_ANY, _t('Import'), _t('Import overrides'))
fileExport = fileMenu.Append(wx.ID_ANY, _t('Export'), _t('Import overrides'))
fileClear = fileMenu.Append(wx.ID_ANY, _t('Clear All'), _t('Clear all overrides'))
menubar.Append(fileMenu, '&File')
menubar.Append(fileMenu, _t('&File'))
self.SetMenuBar(menubar)
self.Bind(wx.EVT_MENU, self.OnImport, fileImport)
@@ -69,7 +69,7 @@ class AttributeEditor(AuxiliaryFrame):
mainSizer.Add(leftPanel, 1, wx.ALL | wx.EXPAND, 5)
rightSizer = wx.BoxSizer(wx.VERTICAL)
self.btnRemoveOverrides = wx.Button(panel, wx.ID_ANY, _("Remove Overides for Item"), wx.DefaultPosition,
self.btnRemoveOverrides = wx.Button(panel, wx.ID_ANY, _t("Remove Overides for Item"), wx.DefaultPosition,
wx.DefaultSize, 0)
self.pg = AttributeGrid(panel)
rightSizer.Add(self.pg, 1, wx.ALL | wx.EXPAND, 5)
@@ -105,8 +105,8 @@ class AttributeEditor(AuxiliaryFrame):
def OnImport(self, event):
with wx.FileDialog(
self, _("Import pyfa override file"),
wildcard="pyfa override file (*.csv)|*.csv",
self, _t("Import pyfa override file"),
wildcard=_t("pyfa override file (*.csv)|*.csv"),
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
) as dlg:
if dlg.ShowModal() == wx.ID_OK:
@@ -128,8 +128,8 @@ class AttributeEditor(AuxiliaryFrame):
defaultFile = "pyfa_overrides.csv"
with wx.FileDialog(
self, _("Save Overrides As..."),
wildcard="pyfa overrides (*.csv)|*.csv",
self, _t("Save Overrides As..."),
wildcard=_t("pyfa overrides (*.csv)|*.csv"),
style=wx.FD_SAVE,
defaultFile=defaultFile
) as dlg:
@@ -269,7 +269,7 @@ class AttributeGrid(wxpg.PropertyGrid):
prop = wxpg.FloatProperty(key, value=default)
prop.SetClientData(item.attributes[key]) # set this so that we may access it later
prop.SetHelpString("%s\n%s" % (item.attributes[key].displayName or key, _("Default Value: %0.3f") % default))
prop.SetHelpString("%s\n%s" % (item.attributes[key].displayName or key, _t("Default Value: %0.3f") % default))
self.Append(prop)
def removeOverrides(self, event):

View File

@@ -145,10 +145,10 @@ class ImplantSetEditor(AuxiliaryFrame):
self.stNotice.Wrap(-1)
footerSizer.Add(self.stNotice, 1, wx.BOTTOM | wx.TOP | wx.LEFT, 5)
importExport = (("Import", wx.ART_FILE_OPEN, _t("from")),
("Export", wx.ART_FILE_SAVE_AS, _t("to")))
importExport = ((_t("Import implant sets from clipboard"), wx.ART_FILE_OPEN, "Import"),
(_t("Export implant sets to clipboard"), wx.ART_FILE_SAVE_AS, "Export"))
for name, art, direction in importExport:
for tooltip, art, attr in importExport:
bitmap = wx.ArtProvider.GetBitmap(art, wx.ART_BUTTON)
btn = wx.BitmapButton(self, wx.ID_ANY, bitmap)
@@ -156,9 +156,9 @@ class ImplantSetEditor(AuxiliaryFrame):
btn.SetMaxSize(btn.GetSize())
btn.Layout()
setattr(self, name, btn)
setattr(self, attr, btn)
btn.Enable(True)
btn.SetToolTip(_t("{} implant sets {} clipboard").format(name, direction))
btn.SetToolTip(tooltip)
footerSizer.Add(btn, 0)
mainSizer.Add(footerSizer, 0, wx.ALL | wx.EXPAND, 5)

View File

@@ -218,10 +218,10 @@ class TargetProfileEditor(AuxiliaryFrame):
self.SetSizer(mainSizer)
importExport = (("Import", wx.ART_FILE_OPEN, _t("from")),
("Export", wx.ART_FILE_SAVE_AS, _t("to")))
importExport = ((_t("Import profiles from clipboard"), wx.ART_FILE_OPEN, "import"),
(_t("Export profiles to clipboard"), wx.ART_FILE_SAVE_AS, "export"))
for name, art, direction in importExport:
for tooltip, art, attr in importExport:
bitmap = wx.ArtProvider.GetBitmap(art, wx.ART_BUTTON)
btn = wx.BitmapButton(self, wx.ID_ANY, bitmap)
@@ -229,11 +229,11 @@ class TargetProfileEditor(AuxiliaryFrame):
btn.SetMaxSize(btn.GetSize())
btn.Layout()
setattr(self, name, btn)
setattr(self, attr, btn)
btn.Enable(True)
btn.SetToolTip(_t("{} profiles {} clipboard").format(name, direction))
btn.SetToolTip(tooltip)
footerSizer.Add(btn, 0)
btn.Bind(wx.EVT_BUTTON, getattr(self, "{}Patterns".format(name.lower())))
btn.Bind(wx.EVT_BUTTON, getattr(self, "{}Patterns".format(attr)))
if not self.entityEditor.checkEntitiesExist():
self.Close()