From 47bda45516ec46238000d5c49a4f5505c6049f23 Mon Sep 17 00:00:00 2001 From: zhaoweny Date: Wed, 22 Jul 2020 01:48:59 +0800 Subject: [PATCH] i18n: more Tooltip annotation --- eos/utils/stats.py | 6 +++++- gui/builtinStatsViews/capacitorViewFull.py | 11 +++++------ gui/builtinStatsViews/firepowerViewFull.py | 18 +++++++++--------- gui/builtinStatsViews/outgoingViewFull.py | 8 ++++---- gui/builtinStatsViews/outgoingViewMinimal.py | 8 ++++---- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/eos/utils/stats.py b/eos/utils/stats.py index 76ed3edeb..5b6329c16 100644 --- a/eos/utils/stats.py +++ b/eos/utils/stats.py @@ -22,6 +22,10 @@ from eos.utils.float import floatUnerr from utils.repr import makeReprStr +def _t(x): + return x + + class DmgTypes: """Container for damage data stats.""" @@ -116,7 +120,7 @@ class DmgTypes: @staticmethod def names(short=None, postProcessor=None): - value = ['em', 'th', 'kin', 'exp'] if short else ['em', 'thermal', 'kinetic', 'explosive'] + value = [_t('em'), _t('th'), _t('kin'), _t('exp')] if short else [_t('em'), _t('thermal'), _t('kinetic'), _t('explosive')] if postProcessor: value = [postProcessor(x) for x in value] diff --git a/gui/builtinStatsViews/capacitorViewFull.py b/gui/builtinStatsViews/capacitorViewFull.py index 9ba2a0cf5..dd89ed5b0 100644 --- a/gui/builtinStatsViews/capacitorViewFull.py +++ b/gui/builtinStatsViews/capacitorViewFull.py @@ -136,10 +136,9 @@ class CapacitorViewFull(StatsView): label.SetToolTip(wx.ToolTip("%.1f" % value)) if labelName == 'label%sCapacitorDelta' and (cap_recharge or cap_use): - lines = [] - lines.append('Capacitor delta:') - lines.append(' +{} GJ/s'.format(formatAmount(cap_recharge, 3, 0, 3))) - lines.append(' -{} GJ/s'.format(formatAmount(cap_use, 3, 0, 3))) + lines = [_t('Capacitor delta:'), + ' +{} GJ/s'.format(formatAmount(cap_recharge, 3, 0, 3)), + ' -{} GJ/s'.format(formatAmount(cap_use, 3, 0, 3))] delta = round(cap_recharge - cap_use, 3) if delta > 0 and 0 < round(neut_res, 4) < 1: lines.append('') @@ -147,9 +146,9 @@ class CapacitorViewFull(StatsView): lines.append(' +{} GJ/s'.format(formatAmount(delta / neut_res, 3, 0, 3))) label.SetToolTip(wx.ToolTip('\n'.join(lines))) if labelName == 'label%sCapacitorResist': - texts = ['Neutralizer resistance'] + texts = [_t('Neutralizer resistance')] if cap_amount > 0 and 0 < round(neut_res, 4) < 1: - texts.append('Effective capacity: {} GJ'.format(formatAmount(cap_amount / neut_res, 3, 0, 9))) + texts.append(_t('Effective capacity') + ': {} GJ'.format(formatAmount(cap_amount / neut_res, 3, 0, 9))) label.SetToolTip(wx.ToolTip('\n'.join(texts))) capState = fit.capState if fit is not None else 0 diff --git a/gui/builtinStatsViews/firepowerViewFull.py b/gui/builtinStatsViews/firepowerViewFull.py index 62ae6cc2a..8540accc6 100644 --- a/gui/builtinStatsViews/firepowerViewFull.py +++ b/gui/builtinStatsViews/firepowerViewFull.py @@ -166,20 +166,20 @@ class FirepowerViewFull(StatsView): hasSpool = hasSpoolUp(preSpool, fullSpool) lines = [] if hasSpool: - lines.append("Spool up: {}-{}".format( - formatAmount(preSpool.total, prec, lowest, highest), - formatAmount(fullSpool.total, prec, lowest, highest))) + lines.append(_t("Spool up") + ": {}-{}".format( + formatAmount(preSpool.total, prec, lowest, highest), + formatAmount(fullSpool.total, prec, lowest, highest))) if getattr(normal, 'total', None): if hasSpool: lines.append("") - lines.append("Current: {}".format(formatAmount(normal.total, prec, lowest, highest))) + lines.append(_t("Current") + ": {}".format(formatAmount(normal.total, prec, lowest, highest))) for dmgType in normal.names(): val = getattr(normal, dmgType, None) if val: lines.append("{}{}: {}%".format( - " " if hasSpool else "", - dmgType.capitalize(), - formatAmount(val / normal.total * 100, 3, 0, 0))) + " " if hasSpool else "", + _t(dmgType).capitalize(), + formatAmount(val / normal.total * 100, 3, 0, 0))) return "\n".join(lines) defaultSpoolValue = eos.config.settings['globalDefaultSpoolupPercentage'] @@ -218,8 +218,8 @@ class FirepowerViewFull(StatsView): if self._cachedValues[counter] != val: tooltipText = dpsToolTip(val, preSpoolVal, fullSpoolVal, prec, lowest, highest) label.SetLabel(valueFormat.format( - formatAmount(0 if val is None else val.total, prec, lowest, highest), - "\u02e2" if hasSpoolUp(preSpoolVal, fullSpoolVal) else "")) + formatAmount(0 if val is None else val.total, prec, lowest, highest), + "\u02e2" if hasSpoolUp(preSpoolVal, fullSpoolVal) else "")) label.SetToolTip(wx.ToolTip(tooltipText)) self._cachedValues[counter] = val counter += 1 diff --git a/gui/builtinStatsViews/outgoingViewFull.py b/gui/builtinStatsViews/outgoingViewFull.py index 8b214c052..655cee084 100644 --- a/gui/builtinStatsViews/outgoingViewFull.py +++ b/gui/builtinStatsViews/outgoingViewFull.py @@ -29,25 +29,25 @@ _t = wx.GetTranslation stats = [ ( - "labelRemoteCapacitor", "Capacitor:", "{}{} GJ/s", "capacitorInfo", "Capacitor restored", + "labelRemoteCapacitor", "Capacitor:", "{}{} GJ/s", "capacitorInfo", _t("Capacitor restored"), lambda fit, spool: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, spool, False)).capacitor, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 0, True)).capacitor, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 1, True)).capacitor, 3, 0, 0), ( - "labelRemoteShield", "Shield:", "{}{} HP/s", "shieldActive", "Shield restored", + "labelRemoteShield", "Shield:", "{}{} HP/s", "shieldActive", _t("Shield restored"), lambda fit, spool: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, spool, False)).shield, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 0, True)).shield, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 1, True)).shield, 3, 0, 0), ( - "labelRemoteArmor", "Armor:", "{}{} HP/s", "armorActive", "Armor restored", + "labelRemoteArmor", "Armor:", "{}{} HP/s", "armorActive", _t("Armor restored"), lambda fit, spool: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, spool, False)).armor, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 0, True)).armor, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 1, True)).armor, 3, 0, 0), ( - "labelRemoteHull", "Hull:", "{}{} HP/s", "hullActive", "Hull restored", + "labelRemoteHull", "Hull:", "{}{} HP/s", "hullActive", _t("Hull restored"), lambda fit, spool: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, spool, False)).hull, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 0, True)).hull, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 1, True)).hull, diff --git a/gui/builtinStatsViews/outgoingViewMinimal.py b/gui/builtinStatsViews/outgoingViewMinimal.py index 9ce5439a8..17f1b0a44 100644 --- a/gui/builtinStatsViews/outgoingViewMinimal.py +++ b/gui/builtinStatsViews/outgoingViewMinimal.py @@ -28,25 +28,25 @@ _t = wx.GetTranslation stats = [ ( - "labelRemoteCapacitor", "Capacitor:", "{}{} GJ/s", "capacitorInfo", "Capacitor restored", + "labelRemoteCapacitor", "Capacitor:", "{}{} GJ/s", "capacitorInfo", _t("Capacitor restored"), lambda fit, spool: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, spool, False)).capacitor, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 0, True)).capacitor, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 1, True)).capacitor, 3, 0, 0), ( - "labelRemoteShield", "Shield:", "{}{} HP/s", "shieldActive", "Shield restored", + "labelRemoteShield", "Shield:", "{}{} HP/s", "shieldActive", _t("Shield restored"), lambda fit, spool: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, spool, False)).shield, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 0, True)).shield, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 1, True)).shield, 3, 0, 0), ( - "labelRemoteArmor", "Armor:", "{}{} HP/s", "armorActive", "Armor restored", + "labelRemoteArmor", "Armor:", "{}{} HP/s", "armorActive", _t("Armor restored"), lambda fit, spool: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, spool, False)).armor, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 0, True)).armor, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 1, True)).armor, 3, 0, 0), ( - "labelRemoteHull", "Hull:", "{}{} HP/s", "hullActive", "Hull restored", + "labelRemoteHull", "Hull:", "{}{} HP/s", "hullActive", _t("Hull restored"), lambda fit, spool: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, spool, False)).hull, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 0, True)).hull, lambda fit: fit.getRemoteReps(spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 1, True)).hull,