i18n: unify FileDialog wildcard string annotations

This commit is contained in:
zhaoweny
2020-06-23 01:16:42 +08:00
parent 2d97f0952e
commit 85c3158e98
4 changed files with 75 additions and 75 deletions

View File

@@ -115,7 +115,7 @@ class ItemParams(wx.Panel):
with wx.FileDialog( with wx.FileDialog(
self, _t("Save CSV file"), "", exportFileName, self, _t("Save CSV file"), "", exportFileName,
_t("CSV files (*.csv)|*.csv"), wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT _t("CSV files") + " (*.csv)|*.csv", wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT
) as dlg: ) as dlg:
if dlg.ShowModal() == wx.ID_CANCEL: if dlg.ShowModal() == wx.ID_CANCEL:

View File

@@ -46,7 +46,7 @@ class PFHTMLExportPref(PreferenceView):
mainSizer.Add(self.PathLinkCtrl, 0, wx.ALL | wx.EXPAND, 5) mainSizer.Add(self.PathLinkCtrl, 0, wx.ALL | wx.EXPAND, 5)
self.fileSelectDialog = wx.FileDialog(None, _t("Save Fitting As..."), self.fileSelectDialog = wx.FileDialog(None, _t("Save Fitting As..."),
wildcard=_t("EVE IGB HTML fitting file (*.html)|*.html"), style=wx.FD_SAVE) wildcard=_t("EVE IGB HTML fitting file") + " (*.html)|*.html", style=wx.FD_SAVE)
self.fileSelectDialog.SetPath(self.HTMLExportSettings.getPath()) self.fileSelectDialog.SetPath(self.HTMLExportSettings.getPath())
self.fileSelectDialog.SetFilename(os.path.basename(self.HTMLExportSettings.getPath())) self.fileSelectDialog.SetFilename(os.path.basename(self.HTMLExportSettings.getPath()))

View File

@@ -283,9 +283,10 @@ class MainFrame(wx.Frame):
def LoadMainFrameAttribs(self): def LoadMainFrameAttribs(self):
mainFrameDefaultAttribs = { mainFrameDefaultAttribs = {
"wnd_display": 0, "wnd_x": 0, "wnd_y": 0, "wnd_width": 1000, "wnd_height": 700, "wnd_maximized": False, "wnd_display": 0, "wnd_x": 0, "wnd_y": 0, "wnd_width": 1000, "wnd_height": 700, "wnd_maximized": False,
"browser_width": 300, "market_height": 0, "fitting_height": -200} "browser_width": 300, "market_height": 0, "fitting_height": -200
}
self.mainFrameAttribs = SettingsProvider.getInstance().getSettings( self.mainFrameAttribs = SettingsProvider.getInstance().getSettings(
"pyfaMainWindowAttribs", mainFrameDefaultAttribs) "pyfaMainWindowAttribs", mainFrameDefaultAttribs)
wndDisplay = self.mainFrameAttribs["wnd_display"] wndDisplay = self.mainFrameAttribs["wnd_display"]
displayData = self._getDisplayData() displayData = self._getDisplayData()
@@ -463,10 +464,10 @@ class MainFrame(wx.Frame):
defaultFile = "%s - %s.xml" % (fit.ship.item.name, fit.name) if fit else None defaultFile = "%s - %s.xml" % (fit.ship.item.name, fit.name) if fit else None
with wx.FileDialog( with wx.FileDialog(
self, _t("Save Fitting As..."), self, _t("Save Fitting As..."),
wildcard=_t("EVE XML fitting files (*.xml)|*.xml"), wildcard=_t("EVE XML fitting files") + " (*.xml)|*.xml",
style=wx.FD_SAVE, style=wx.FD_SAVE,
defaultFile=defaultFile defaultFile=defaultFile
) as dlg: ) as dlg:
if dlg.ShowModal() == wx.ID_OK: if dlg.ShowModal() == wx.ID_OK:
self.supress_left_up = True self.supress_left_up = True
@@ -643,15 +644,15 @@ class MainFrame(wx.Frame):
if not fit.ignoreRestrictions: if not fit.ignoreRestrictions:
with wx.MessageDialog( with wx.MessageDialog(
self, _t("Are you sure you wish to ignore fitting restrictions for the " self, _t("Are you sure you wish to ignore fitting restrictions for the "
"current fit? This could lead to wildly inaccurate results and possible errors."), "current fit? This could lead to wildly inaccurate results and possible errors."),
_t("Confirm"), wx.YES_NO | wx.ICON_QUESTION _t("Confirm"), wx.YES_NO | wx.ICON_QUESTION
) as dlg: ) as dlg:
result = dlg.ShowModal() == wx.ID_YES result = dlg.ShowModal() == wx.ID_YES
else: else:
with wx.MessageDialog( with wx.MessageDialog(
self, _t("Re-enabling fitting restrictions for this fit will also remove any illegal items " self, _t("Re-enabling fitting restrictions for this fit will also remove any illegal items "
"from the fit. Do you want to continue?"), _t("Confirm"), wx.YES_NO | wx.ICON_QUESTION "from the fit. Do you want to continue?"), _t("Confirm"), wx.YES_NO | wx.ICON_QUESTION
) as dlg: ) as dlg:
result = dlg.ShowModal() == wx.ID_YES result = dlg.ShowModal() == wx.ID_YES
if result: if result:
@@ -802,14 +803,14 @@ class MainFrame(wx.Frame):
""" Exports skills needed for active fit and active character """ """ Exports skills needed for active fit and active character """
sCharacter = Character.getInstance() sCharacter = Character.getInstance()
with wx.FileDialog( with wx.FileDialog(
self, self,
_t("Export Skills Needed As..."), _t("Export Skills Needed As..."),
wildcard=("|".join([ wildcard=("|".join([
_t("EVEMon skills training file") + " (*.emp)|*.emp", _t("EVEMon skills training file") + " (*.emp)|*.emp",
_t("EVEMon skills training XML file") + " (*.xml)|*.xml", _t("EVEMon skills training XML file") + " (*.xml)|*.xml",
_t("Text skills training file") + " (*.txt)|*.txt" _t("Text skills training file") + " (*.txt)|*.txt"
])), ])),
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT, style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
) as dlg: ) as dlg:
if dlg.ShowModal() == wx.ID_OK: if dlg.ShowModal() == wx.ID_OK:
saveFmtInt = dlg.GetFilterIndex() saveFmtInt = dlg.GetFilterIndex()
@@ -831,21 +832,21 @@ class MainFrame(wx.Frame):
def fileImportDialog(self, event): def fileImportDialog(self, event):
"""Handles importing single/multiple EVE XML / EFT cfg fit files""" """Handles importing single/multiple EVE XML / EFT cfg fit files"""
with wx.FileDialog( with wx.FileDialog(
self, self,
_t("Open One Or More Fitting Files"), _t("Open One Or More Fitting Files"),
wildcard=("|".join([ wildcard=("|".join([
_t("EVE XML fitting files") + " (*.xml)|*.xml", _t("EVE XML fitting files") + " (*.xml)|*.xml",
_t("EFT text fitting files") + " (*.cfg)|*.cfg", _t("EFT text fitting files") + " (*.cfg)|*.cfg",
_t("All Files") + "|*" _t("All Files") + "|*"
])), ])),
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE
) as dlg: ) as dlg:
if dlg.ShowModal() == wx.ID_OK: if dlg.ShowModal() == wx.ID_OK:
self.progressDialog = wx.ProgressDialog( self.progressDialog = wx.ProgressDialog(
_t("Importing fits"), _t("Importing fits"),
" " * 100, # set some arbitrary spacing to create width in window " " * 100, # set some arbitrary spacing to create width in window
parent=self, parent=self,
style=wx.PD_CAN_ABORT | wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_APP_MODAL style=wx.PD_CAN_ABORT | wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_APP_MODAL
) )
Port.importFitsThreaded(dlg.GetPaths(), self) Port.importFitsThreaded(dlg.GetPaths(), self)
self.progressDialog.ShowModal() self.progressDialog.ShowModal()
@@ -855,11 +856,11 @@ class MainFrame(wx.Frame):
defaultFile = "pyfa-fits-%s.xml" % strftime("%Y%m%d_%H%M%S", gmtime()) defaultFile = "pyfa-fits-%s.xml" % strftime("%Y%m%d_%H%M%S", gmtime())
with wx.FileDialog( with wx.FileDialog(
self, self,
_t("Save Backup As..."), _t("Save Backup As..."),
wildcard=_t("EVE XML fitting file") + " (*.xml)|*.xml", wildcard=_t("EVE XML fitting file") + " (*.xml)|*.xml",
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT, style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
defaultFile=defaultFile, defaultFile=defaultFile,
) as dlg: ) as dlg:
if dlg.ShowModal() == wx.ID_OK: if dlg.ShowModal() == wx.ID_OK:
filePath = dlg.GetPath() filePath = dlg.GetPath()
@@ -870,11 +871,11 @@ class MainFrame(wx.Frame):
max_ = sFit.countAllFits() max_ = sFit.countAllFits()
self.progressDialog = wx.ProgressDialog( self.progressDialog = wx.ProgressDialog(
_t("Backup fits"), _t("Backup fits"),
_t("Backing up {} fits to: {}").format(max_, filePath), _t("Backing up {} fits to: {}").format(max_, filePath),
maximum=max_, maximum=max_,
parent=self, parent=self,
style=wx.PD_CAN_ABORT | wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_APP_MODAL style=wx.PD_CAN_ABORT | wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_APP_MODAL
) )
Port.backupFits(filePath, self) Port.backupFits(filePath, self)
self.progressDialog.ShowModal() self.progressDialog.ShowModal()
@@ -889,22 +890,22 @@ class MainFrame(wx.Frame):
if not os.path.isdir(os.path.dirname(path)): if not os.path.isdir(os.path.dirname(path)):
with wx.MessageDialog( with wx.MessageDialog(
self, self,
_t("Invalid Path") + "\n\n" + _t("Invalid Path") + "\n\n" +
_t("The following path is invalid or does not exist:") + _t("The following path is invalid or does not exist:") +
f"\n{path}\n\n" + f"\n{path}\n\n" +
_t("Please verify path location pyfa's preferences."), _t("Please verify path location pyfa's preferences."),
_t("Error"), _t("Error"),
wx.OK | wx.ICON_ERROR wx.OK | wx.ICON_ERROR
) as dlg: ) as dlg:
if dlg.ShowModal() == wx.ID_OK: if dlg.ShowModal() == wx.ID_OK:
return return
self.progressDialog = wx.ProgressDialog( self.progressDialog = wx.ProgressDialog(
_t("Backup fits"), _t("Backup fits"),
_t("Generating HTML file at: {}").format(path), _t("Generating HTML file at: {}").format(path),
maximum=max_, parent=self, maximum=max_, parent=self,
style=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME) style=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME)
exportHtml.getInstance().refreshFittingHtml(True, self.backupCallback) exportHtml.getInstance().refreshFittingHtml(True, self.backupCallback)
self.progressDialog.ShowModal() self.progressDialog.ShowModal()
@@ -922,7 +923,7 @@ class MainFrame(wx.Frame):
def on_port_processing(self, action, data=None): def on_port_processing(self, action, data=None):
# 2017/03/29 NOTE: implementation like interface # 2017/03/29 NOTE: implementation like interface
wx.CallAfter( wx.CallAfter(
self._on_port_processing, action, data self._on_port_processing, action, data
) )
return self.__progress_flag return self.__progress_flag
@@ -946,11 +947,11 @@ class MainFrame(wx.Frame):
self.closeProgressDialog() self.closeProgressDialog()
_message = _t("Import Error") if action & IPortUser.PROCESS_IMPORT else _t("Export Error") _message = _t("Import Error") if action & IPortUser.PROCESS_IMPORT else _t("Export Error")
with wx.MessageDialog( with wx.MessageDialog(
self, self,
_t("The following error was generated") + _t("The following error was generated") +
f"\n\n{data}\n\n" + f"\n\n{data}\n\n" +
_t("Be aware that already processed fits were not saved"), _t("Be aware that already processed fits were not saved"),
_message, wx.OK | wx.ICON_ERROR _message, wx.OK | wx.ICON_ERROR
) as dlg: ) as dlg:
dlg.ShowModal() dlg.ShowModal()
return return
@@ -1007,13 +1008,13 @@ class MainFrame(wx.Frame):
def importCharacter(self, event): def importCharacter(self, event):
""" Imports character XML file from EVE API """ """ Imports character XML file from EVE API """
with wx.FileDialog( with wx.FileDialog(
self, self,
_t("Open One Or More Character Files"), _t("Open One Or More Character Files"),
wildcard="|".join([ wildcard="|".join([
_t("EVE API XML character files") + " (*.xml)|*.xml", _t("EVE API XML character files") + " (*.xml)|*.xml",
_t("All Files") + "|*" _t("All Files") + "|*"
]), ]),
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE
) as dlg: ) as dlg:
if dlg.ShowModal() == wx.ID_OK: if dlg.ShowModal() == wx.ID_OK:
self.supress_left_up = True self.supress_left_up = True

View File

@@ -16,7 +16,6 @@ from gui.marketBrowser import SearchBox
from service.fit import Fit from service.fit import Fit
from service.market import Market from service.market import Market
pyfalog = Logger(__name__) pyfalog = Logger(__name__)
_t = wx.GetTranslation _t = wx.GetTranslation
@@ -26,8 +25,8 @@ class AttributeEditor(AuxiliaryFrame):
def __init__(self, parent): def __init__(self, parent):
super().__init__( super().__init__(
parent, wx.ID_ANY, title=_t("Attribute Editor"), pos=wx.DefaultPosition, parent, wx.ID_ANY, title=_t("Attribute Editor"), pos=wx.DefaultPosition,
size=wx.Size(650, 600), resizeable=True) size=wx.Size(650, 600), resizeable=True)
i = wx.Icon(BitmapLoader.getBitmap("fit_rename_small", "gui")) i = wx.Icon(BitmapLoader.getBitmap("fit_rename_small", "gui"))
self.SetIcon(i) self.SetIcon(i)
@@ -105,9 +104,9 @@ class AttributeEditor(AuxiliaryFrame):
def OnImport(self, event): def OnImport(self, event):
with wx.FileDialog( with wx.FileDialog(
self, _t("Import pyfa override file"), self, _t("Import pyfa override file"),
wildcard=_t("pyfa override file (*.csv)|*.csv"), wildcard=_t("pyfa override file") + " (*.csv)|*.csv",
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
) as dlg: ) as dlg:
if dlg.ShowModal() == wx.ID_OK: if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath() path = dlg.GetPath()
@@ -128,10 +127,10 @@ class AttributeEditor(AuxiliaryFrame):
defaultFile = "pyfa_overrides.csv" defaultFile = "pyfa_overrides.csv"
with wx.FileDialog( with wx.FileDialog(
self, _t("Save Overrides As..."), self, _t("Save Overrides As..."),
wildcard=_t("pyfa overrides (*.csv)|*.csv"), wildcard=_t("pyfa overrides") + " (*.csv)|*.csv",
style=wx.FD_SAVE, style=wx.FD_SAVE,
defaultFile=defaultFile defaultFile=defaultFile
) as dlg: ) as dlg:
if dlg.ShowModal() == wx.ID_OK: if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath() path = dlg.GetPath()
@@ -143,10 +142,10 @@ class AttributeEditor(AuxiliaryFrame):
def OnClear(self, event): def OnClear(self, event):
with wx.MessageDialog( with wx.MessageDialog(
self, self,
_t("Are you sure you want to delete all overrides?"), _t("Are you sure you want to delete all overrides?"),
_t("Confirm Delete"), _t("Confirm Delete"),
wx.YES | wx.NO | wx.ICON_EXCLAMATION wx.YES | wx.NO | wx.ICON_EXCLAMATION
) as dlg: ) as dlg:
if dlg.ShowModal() == wx.ID_YES: if dlg.ShowModal() == wx.ID_YES:
sMkt = Market.getInstance() sMkt = Market.getInstance()