i18n: deferred translation and category annotation for targetProfile and damagePattern

* use deferred translation annotation, to annotate strings in eos.db and translate on the GUI side

  As @blitzmann said in #2222, we should not include wx as a dependency for eos module.

* category annotation _c for taking '[]' out of string literals
This commit is contained in:
zhaoweny
2020-07-11 16:07:42 +08:00
parent f9b3defd4b
commit 9868b219d7
5 changed files with 273 additions and 260 deletions

View File

@@ -45,9 +45,9 @@ class ChangeDamagePattern(ContextMenuUnconditional):
for pattern in self.patterns:
container = self.items
for categoryName in pattern.hierarchy:
categoryName = _t('[' + categoryName + ']')[1:-1] if pattern.isBuiltin else categoryName
categoryName = _t(categoryName) if pattern.builtin else categoryName
container = container[1].setdefault(categoryName, (OrderedDict(), OrderedDict()))
shortName = _t(pattern.shortName) if pattern.isBuiltin else pattern.shortName
shortName = _t(pattern.shortName) if pattern.builtin else pattern.shortName
container[0][shortName] = pattern
return list(self.items[0].keys()) + list(self.items[1].keys())

View File

@@ -59,8 +59,10 @@ class TargetProfileAdder(ContextMenuUnconditional):
for profile in profiles:
container = items
for categoryName in profile.hierarchy:
categoryName = _t(categoryName) if profile.builtin else categoryName
container = container[1].setdefault(categoryName, (OrderedDict(), OrderedDict()))
container[0][profile.shortName] = profile
shortName = _t(profile.shortName) if profile.builtin else profile.shortName
container[0][shortName] = profile
# Category as menu item - expands further
msw = "wxMSW" in wx.PlatformInfo

View File

@@ -71,8 +71,10 @@ class TargetProfileSwitcher(ContextMenuUnconditional):
for profile in profiles:
container = items
for categoryName in profile.hierarchy:
categoryName = _t(categoryName) if profile.builtin else categoryName
container = container[1].setdefault(categoryName, (OrderedDict(), OrderedDict()))
container[0][profile.shortName] = profile
shortName = _t(profile.shortName) if profile.builtin else profile.shortName
container[0][shortName] = profile
# Category as menu item - expands further
msw = "wxMSW" in wx.PlatformInfo