Start working through the files, adding translation strings

This commit is contained in:
blitzmann
2020-05-16 14:42:29 -04:00
parent fdd06ed3d6
commit 5177768962
5 changed files with 121 additions and 121 deletions

View File

@@ -45,6 +45,7 @@ from service.esi import Esi
from service.fit import Fit
from service.market import Market
_ = wx.GetTranslation
pyfalog = Logger(__name__)
@@ -72,43 +73,21 @@ class CharacterTextValidor(BaseValidator):
try:
if len(text) == 0:
raise ValueError("You must supply a name for the Character!")
raise ValueError(_("You must supply a name for the Character!"))
elif text in [x.name for x in sChar.getCharacterList()]:
raise ValueError("Character name already in use, please choose another.")
raise ValueError(_("Character name already in use, please choose another."))
return True
except ValueError as e:
pyfalog.error(e)
wx.MessageBox("{}".format(e), "Error")
wx.MessageBox("{}".format(e), _("Error"))
textCtrl.SetFocus()
return False
class PlaceholderTextCtrl(wx.TextCtrl):
def __init__(self, *args, **kwargs):
self.default_text = kwargs.pop("placeholder", "")
kwargs["value"] = self.default_text
wx.TextCtrl.__init__(self, *args, **kwargs)
self.Bind(wx.EVT_SET_FOCUS, self.OnFocus)
self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
def OnFocus(self, evt):
if self.GetValue() == self.default_text:
self.SetValue("")
evt.Skip()
def OnKillFocus(self, evt):
if self.GetValue().strip() == "":
self.SetValue(self.default_text)
evt.Skip()
def Reset(self):
self.SetValue(self.default_text)
class CharacterEntityEditor(EntityEditor):
def __init__(self, parent):
EntityEditor.__init__(self, parent, "Character")
EntityEditor.__init__(self, parent, _("Character"))
self.SetEditorValidator(CharacterTextValidor)
def getEntitiesFromContext(self):
@@ -155,7 +134,7 @@ class CharacterEditor(AuxiliaryFrame):
def __init__(self, parent):
super().__init__(
parent, id=wx.ID_ANY, title="Character Editor", resizeable=True, pos=wx.DefaultPosition,
parent, id=wx.ID_ANY, title=_("Character Editor"), resizeable=True, pos=wx.DefaultPosition,
size=wx.Size(950, 650) if "wxGTK" in wx.PlatformInfo else wx.Size(850, 600))
i = wx.Icon(BitmapLoader.getBitmap("character_small", "gui"))
@@ -178,17 +157,17 @@ class CharacterEditor(AuxiliaryFrame):
self.iview = ImplantEditorView(self.viewsNBContainer, self)
self.aview = APIView(self.viewsNBContainer)
self.viewsNBContainer.AddPage(self.sview, "Skills")
self.viewsNBContainer.AddPage(self.iview, "Implants")
self.viewsNBContainer.AddPage(self.aview, "EVE SSO")
self.viewsNBContainer.AddPage(self.sview, _("Skills"))
self.viewsNBContainer.AddPage(self.iview, _("Implants"))
self.viewsNBContainer.AddPage(self.aview, _("EVE SSO"))
mainSizer.Add(self.viewsNBContainer, 1, wx.EXPAND | wx.ALL, 5)
bSizerButtons = wx.BoxSizer(wx.HORIZONTAL)
self.btnSaveChar = wx.Button(self, wx.ID_ANY, "Save")
self.btnSaveAs = wx.Button(self, wx.ID_ANY, "Save As...")
self.btnRevert = wx.Button(self, wx.ID_ANY, "Revert")
self.btnSaveChar = wx.Button(self, wx.ID_SAVE)
self.btnSaveAs = wx.Button(self, wx.ID_SAVEAS)
self.btnRevert = wx.Button(self, wx.ID_REVERT_TO_SAVED)
self.btnOK = wx.Button(self, wx.ID_OK)
bSizerButtons.Add(self.btnSaveChar, 0, wx.ALL, 5)
@@ -299,10 +278,10 @@ class CharacterEditor(AuxiliaryFrame):
with TextEntryValidatedDialog(
parent, CharacterTextValidor,
"Enter a name for your new Character:",
"Save Character As..."
_("Enter a name for your new Character:"),
_("Save Character As...")
) as dlg:
dlg.SetValue("{} Copy".format(name))
dlg.SetValue(_("{} Copy").format(name))
dlg.txtctrl.SetInsertionPointEnd()
dlg.CenterOnParent()
@@ -327,7 +306,7 @@ class SkillTreeView(wx.Panel):
self.clonesChoice.SetSelection(i)
hSizer.Add(self.clonesChoice, 5, wx.ALL | wx.EXPAND, 5)
self.searchInput = PlaceholderTextCtrl(self, wx.ID_ANY, placeholder="Search...")
self.searchInput = wx.SearchCtrl(self, wx.ID_ANY)
hSizer.Add(self.searchInput, 1, wx.ALL | wx.EXPAND, 5)
self.searchInput.Bind(wx.EVT_TEXT, self.delaySearch)
@@ -343,7 +322,7 @@ class SkillTreeView(wx.Panel):
self.clonesChoice.Bind(wx.EVT_CHOICE, self.cloneChanged)
self.clonesChoice.SetToolTip(
wx.ToolTip("Setting an Alpha clone does not replace the character's skills, but rather caps them to Alpha levels."))
wx.ToolTip(_("Setting an Alpha clone does not replace the character's skills, but rather caps them to Alpha levels.")))
pmainSizer.Add(hSizer, 0, wx.EXPAND | wx.ALL, 5)
@@ -359,8 +338,8 @@ class SkillTreeView(wx.Panel):
self.skillBookImageId = self.imageList.Add(wx.Icon(BitmapLoader.getBitmap("skill_small", "gui")))
self.skillBookDirtyImageId = self.imageList.Add(wx.Icon(BitmapLoader.getBitmap("skill_small_red", "gui")))
tree.AppendColumn("Skill")
tree.AppendColumn("Level", align=wx.ALIGN_CENTER)
tree.AppendColumn(_("Skill"))
tree.AppendColumn(_("Level"), align=wx.ALIGN_CENTER)
# tree.SetMainColumn(0)
self.root = tree.GetRootItem()
@@ -373,7 +352,8 @@ class SkillTreeView(wx.Panel):
tree.SetColumnWidth(0, 525)
tree.SetColumnWidth(1, 100)
self.btnSecStatus = wx.Button(self, wx.ID_ANY, "Sec Status: {0:.2f}".format(char.secStatus or 0.0))
self.secStatusLabel = _("Sec Status: {0:.2f}")
self.btnSecStatus = wx.Button(self, wx.ID_ANY, self.secStatusLabel.format(char.secStatus or 0.0))
self.btnSecStatus.Bind(wx.EVT_BUTTON, self.onSecStatus)
self.populateSkillTree()
@@ -388,8 +368,8 @@ class SkillTreeView(wx.Panel):
bSizerButtons.AddStretchSpacer()
importExport = (("Import", wx.ART_FILE_OPEN, "from"),
("Export", wx.ART_FILE_SAVE_AS, "to"))
importExport = ((_("Import"), wx.ART_FILE_OPEN, _("from")),
(_("Export"), wx.ART_FILE_SAVE_AS, _("to")))
for name, art, direction in importExport:
bitmap = wx.ArtProvider.GetBitmap(art, wx.ART_BUTTON)
@@ -401,7 +381,7 @@ class SkillTreeView(wx.Panel):
btn.Layout()
setattr(self, "{}Btn".format(name.lower()), btn)
btn.Enable(True)
btn.SetToolTip("%s skills %s clipboard" % (name, direction))
btn.SetToolTip(_("%s skills %s clipboard") % (name, direction))
bSizerButtons.Add(btn, 0, wx.ALL, 5)
btn.Bind(wx.EVT_BUTTON, getattr(self, "{}Skills".format(name.lower())))
@@ -456,9 +436,9 @@ class SkillTreeView(wx.Panel):
def importSkills(self, evt):
with wx.MessageDialog(
self, ("Importing skills into this character will set the skill levels as pending. To save the skills "
"permanently, please click the Save button at the bottom of the window after importing"),
"Import Skills", wx.OK
self, (_("Importing skills into this character will set the skill levels as pending. To save the skills "
"permanently, please click the Save button at the bottom of the window after importing")),
_("Import Skills"), wx.OK
) as dlg:
dlg.ShowModal()
@@ -479,7 +459,7 @@ class SkillTreeView(wx.Panel):
raise
except Exception as e:
pyfalog.error(e)
with wx.MessageDialog(self, "There was an error importing skills, please see log file", "Error", wx.ICON_ERROR) as dlg:
with wx.MessageDialog(self, _("There was an error importing skills, please see log file"), _("Error"), wx.ICON_ERROR) as dlg:
dlg.ShowModal()
finally:
@@ -505,10 +485,10 @@ class SkillTreeView(wx.Panel):
if dlg.ShowModal() == wx.ID_OK:
value = dlg.floatSpin.GetValue()
sChar.setSecStatus(char, value)
self.btnSecStatus.SetLabel("Sec Status: {0:.2f}".format(value))
self.btnSecStatus.SetLabel(self.secStatusLabel.format(value))
def delaySearch(self, evt):
if self.searchInput.GetValue() == "" or self.searchInput.GetValue() == self.searchInput.default_text:
if self.searchInput.GetValue() == "":
self.populateSkillTree()
else:
self.searchTimer.Stop()
@@ -520,14 +500,14 @@ class SkillTreeView(wx.Panel):
self.populateSkillTree()
def charChanged(self, event=None):
self.searchInput.Reset()
self.searchInput.SetValue("")
char = self.charEditor.entityEditor.getActiveEntity()
for i in range(self.clonesChoice.GetCount()):
cloneID = self.clonesChoice.GetClientData(i)
if char.alphaCloneID == cloneID:
self.clonesChoice.SetSelection(i)
self.btnSecStatus.SetLabel("Sec Status: {0:.2f}".format(char.secStatus or 0.0))
self.btnSecStatus.SetLabel(self.secStatusLabel.format(char.secStatus or 0.0))
self.populateSkillTree(event)
@@ -548,7 +528,7 @@ class SkillTreeView(wx.Panel):
iconId = self.skillBookDirtyImageId
childId = tree.AppendItem(root, name, iconId, data=('skill', id))
tree.SetItemText(childId, 1, "Level %d" % int(level) if isinstance(level, float) else level)
tree.SetItemText(childId, 1, _("Level {}d").format(int(level) if isinstance(level, float) else level))
def populateSkillTree(self, event=None):
sChar = Character.getInstance()
@@ -607,7 +587,7 @@ class SkillTreeView(wx.Panel):
childId = tree.AppendItem(root, name, iconId, data=('skill', id))
tree.SetItemText(childId, 1, "Level %d" % int(level) if isinstance(level, float) else level)
tree.SetItemText(childId, 1, _("Level {}").format(int(level) if isinstance(level, float) else level))
def spawnMenu(self, event):
item = event.GetItem()
@@ -626,9 +606,9 @@ class SkillTreeView(wx.Panel):
char = self.charEditor.entityEditor.getActiveEntity()
if char.name not in ("All 0", "All 5"):
menu.AppendSeparator()
menu.Append(self.idUnlearned, "Unlearn")
menu.Append(self.idUnlearned, _("Unlearn"))
for level in range(6):
menu.Append(self.idLevels[level], "Level %d" % level)
menu.Append(self.idLevels[level], _("Level {}").format(level))
menu.Bind(wx.EVT_MENU, self.changeLevel)
self.PopupMenu(menu)
@@ -661,7 +641,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)
_("Level {}").format(int(lvl)) if not isinstance(lvl, str) else lvl)
if not dirty:
self.skillTreeListCtrl.SetItemImage(treeItem, self.skillBookImageId)
@@ -769,8 +749,8 @@ class APIView(wx.Panel):
hintSizer = wx.BoxSizer(wx.HORIZONTAL)
hintSizer.AddStretchSpacer()
self.stDisabledTip = wx.StaticText(self, wx.ID_ANY,
"You cannot link All 0 or All 5 characters to an EVE character.\n"
"Please select another character or make a new one.", style=wx.ALIGN_CENTER)
_("You cannot link All 0 or All 5 characters to an EVE character.") + "\n" +
_("Please select another character or make a new one."), style=wx.ALIGN_CENTER)
self.stDisabledTip.Wrap(-1)
hintSizer.Add(self.stDisabledTip, 0, wx.TOP | wx.BOTTOM, 10)
@@ -783,14 +763,14 @@ class APIView(wx.Panel):
fgSizerInput.SetFlexibleDirection(wx.BOTH)
fgSizerInput.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
self.m_staticCharText = wx.StaticText(self, wx.ID_ANY, "Character:", wx.DefaultPosition, wx.DefaultSize, 0)
self.m_staticCharText = wx.StaticText(self, wx.ID_ANY, _("Character:"), wx.DefaultPosition, wx.DefaultSize, 0)
self.m_staticCharText.Wrap(-1)
fgSizerInput.Add(self.m_staticCharText, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 10)
self.charChoice = wx.Choice(self, wx.ID_ANY, style=0)
fgSizerInput.Add(self.charChoice, 1, wx.TOP | wx.BOTTOM | wx.EXPAND, 10)
self.fetchButton = wx.Button(self, wx.ID_ANY, "Get Skills", wx.DefaultPosition, wx.DefaultSize, 0)
self.fetchButton = wx.Button(self, wx.ID_ANY, _("Get Skills"), wx.DefaultPosition, wx.DefaultSize, 0)
self.fetchButton.Bind(wx.EVT_BUTTON, self.fetchSkills)
fgSizerInput.Add(self.fetchButton, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 10)
@@ -801,12 +781,12 @@ class APIView(wx.Panel):
self.m_staticline1 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
pmainSizer.Add(self.m_staticline1, 0, wx.EXPAND | wx.ALL, 10)
self.noCharactersTip = wx.StaticText(self, wx.ID_ANY, "Don't see your EVE character in the list?", style=wx.ALIGN_CENTER)
self.noCharactersTip = wx.StaticText(self, wx.ID_ANY, _("Don't see your EVE character in the list?"), style=wx.ALIGN_CENTER)
self.noCharactersTip.Wrap(-1)
pmainSizer.Add(self.noCharactersTip, 0, wx.CENTER | wx.TOP | wx.BOTTOM, 0)
self.addButton = wx.Button(self, wx.ID_ANY, "Log In with EVE SSO", wx.DefaultPosition, wx.DefaultSize, 0)
self.addButton = wx.Button(self, wx.ID_ANY, _("Log In with EVE SSO"), wx.DefaultPosition, wx.DefaultSize, 0)
self.addButton.Bind(wx.EVT_BUTTON, self.addCharacter)
pmainSizer.Add(self.addButton, 0, wx.ALL | wx.ALIGN_CENTER, 10)
@@ -867,7 +847,7 @@ class APIView(wx.Panel):
self.charChoice.Clear()
noneID = self.charChoice.Append("None", None)
noneID = self.charChoice.Append(_("None"), None)
for char in ssoChars:
currId = self.charChoice.Append(char.characterName, char.ID)
@@ -909,24 +889,24 @@ class APIView(wx.Panel):
pyfalog.warn(exc_value)
wx.MessageBox(
"Error fetching skill information",
"Error", wx.ICON_ERROR | wx.STAY_ON_TOP)
_("Error fetching skill information"),
_("Error"), wx.ICON_ERROR | wx.STAY_ON_TOP)
else:
wx.MessageBox(
"Successfully fetched skills", "Success", wx.ICON_INFORMATION | wx.STAY_ON_TOP)
_("Successfully fetched skills"), _("Success"), wx.ICON_INFORMATION | wx.STAY_ON_TOP)
class SecStatusDialog(wx.Dialog):
def __init__(self, parent, sec):
super().__init__(parent, title="Set Security Status", size=(300, 175), style=wx.DEFAULT_DIALOG_STYLE)
super().__init__(parent, title=_("Set Security Status"), size=(300, 175), style=wx.DEFAULT_DIALOG_STYLE)
self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)
bSizer1 = wx.BoxSizer(wx.VERTICAL)
self.m_staticText1 = wx.StaticText(self, wx.ID_ANY,
"Security Status is used in some CONCORD hull calculations",
_("Security Status is used in some CONCORD hull calculations"),
wx.DefaultPosition, wx.DefaultSize, 0)
self.m_staticText1.Wrap(-1)
bSizer1.Add(self.m_staticText1, 1, wx.ALL | wx.EXPAND, 5)