Localised the Minecraft object widget labels

This commit is contained in:
gentlegiantJGC 2021-10-13 17:17:57 +01:00
parent 0502c305c9
commit 6bf37440e0
9 changed files with 70 additions and 21 deletions

View File

@ -1,6 +1,7 @@
import wx
import PyMCTranslate
from amulet_map_editor import lang
from amulet_map_editor.api.image import COLOUR_PICKER
from amulet_map_editor.api.wx.ui.mc.state import BaseResourceIDState, StateHolder, State
from .events import (
@ -33,7 +34,9 @@ class BaseIdentifierSelect(wx.Panel, StateHolder):
sizer = wx.BoxSizer(wx.HORIZONTAL)
self._sizer.Add(sizer, 0, wx.EXPAND | wx.ALL, 5)
text = wx.StaticText(self, label="Namespace:", style=wx.ALIGN_CENTER)
text = wx.StaticText(
self, label=lang.get("widget.mc.namespace"), style=wx.ALIGN_CENTER
)
sizer.Add(text, 1, wx.ALIGN_CENTER_VERTICAL)
self._namespace_combo = wx.ComboBox(self)
sizer.Add(self._namespace_combo, 2)
@ -51,7 +54,7 @@ class BaseIdentifierSelect(wx.Panel, StateHolder):
header_sizer.Add(
wx.StaticText(
self,
label=f"{self.type_name.capitalize()} name:",
label=self.base_name_label,
style=wx.ALIGN_CENTER,
),
1,
@ -86,7 +89,7 @@ class BaseIdentifierSelect(wx.Panel, StateHolder):
raise NotImplementedError
@property
def type_name(self) -> str:
def base_name_label(self) -> str:
raise NotImplementedError
def _post_event(

View File

@ -1,6 +1,7 @@
import wx
import PyMCTranslate
from amulet_map_editor import lang
from amulet_map_editor.api.wx.ui.mc.state import BiomeResourceIDState
from amulet_map_editor.api.wx.ui.mc.base.base_identifier_select import (
BaseIdentifierSelect,
@ -17,8 +18,8 @@ class BiomeIdentifierSelect(BaseIdentifierSelect):
"""
@property
def type_name(self) -> str:
return "Biome"
def base_name_label(self) -> str:
return lang.get("widget.mc.biome.base_name")
@classmethod
def from_data(

View File

@ -1,6 +1,7 @@
import wx
import PyMCTranslate
from amulet_map_editor import lang
from amulet_map_editor.api.wx.ui.mc.base.base_identifier_select import (
BaseIdentifierSelect,
)
@ -17,8 +18,8 @@ class BlockIdentifierSelect(BaseIdentifierSelect):
"""
@property
def type_name(self) -> str:
return "Block"
def base_name_label(self) -> str:
return lang.get("widget.mc.block.base_name")
@classmethod
def from_data(

View File

@ -3,6 +3,7 @@ from typing import Dict, Tuple
import amulet_nbt
from amulet.api.block import PropertyTypeMultiple, PropertyValueType
from amulet_map_editor import lang
from amulet_map_editor.api.wx.ui.mc.state import BlockState
from ..base import BaseMultipleProperty
from .popup import PropertyValueComboPopup
@ -22,10 +23,14 @@ class BaseVanillaMultipleProperty(BaseMultipleProperty):
header_sizer = wx.BoxSizer(wx.HORIZONTAL)
self._sizer.Add(header_sizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5)
label = wx.StaticText(self, label="Property Name", style=wx.ALIGN_CENTER)
label = wx.StaticText(
self, label=lang.get("widget.mc.block.property.name"), style=wx.ALIGN_CENTER
)
header_sizer.Add(label, 1)
label = wx.StaticText(
self, label="Property Value (SNBT)", style=wx.ALIGN_CENTER
self,
label=lang.get("widget.mc.block.property.value"),
style=wx.ALIGN_CENTER,
)
header_sizer.Add(label, 1, wx.LEFT, 5)
self._property_sizer = wx.GridSizer(2, 5, 5)

View File

@ -5,6 +5,7 @@ from collections import namedtuple
import amulet_nbt
from amulet_nbt import SNBTType
from amulet.api.block import PropertyDataTypes, PropertyType
from amulet_map_editor import lang
from amulet_map_editor.api.image import ADD_ICON, SUBTRACT_ICON
from amulet_map_editor.api.wx.ui.mc.state import BlockState
from amulet_map_editor.api.wx.ui.events import ChildSizeEvent
@ -33,10 +34,14 @@ class BaseModdedSingleProperty(BaseSingleProperty):
)
header_sizer.Add(add_button)
self._sizer.Add(header_sizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5)
label = wx.StaticText(self, label="Property Name", style=wx.ALIGN_CENTER)
label = wx.StaticText(
self, label=lang.get("widget.mc.block.property.name"), style=wx.ALIGN_CENTER
)
header_sizer.Add(label, 1, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
label = wx.StaticText(
self, label="Property Value (SNBT)", style=wx.ALIGN_CENTER
self,
label=lang.get("widget.mc.block.property.value"),
style=wx.ALIGN_CENTER,
)
header_sizer.Add(label, 1, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
header_sizer.AddStretchSpacer(1)
@ -136,14 +141,18 @@ class BaseModdedSingleProperty(BaseSingleProperty):
try:
nbt = amulet_nbt.from_snbt(snbt)
except:
snbt_text.SetLabel("Invalid SNBT")
snbt_text.SetLabel(lang.get("widget.mc.block.property.invalid_snbt"))
snbt_text.SetBackgroundColour((255, 200, 200))
else:
if isinstance(nbt, PropertyDataTypes):
snbt_text.SetLabel(nbt.to_snbt())
snbt_text.SetBackgroundColour(wx.NullColour)
else:
snbt_text.SetLabel(f"{nbt.__class__.__name__} not valid")
snbt_text.SetLabel(
lang.get("widget.mc.block.property.invalid_value_fstring").format(
val=nbt.__class__.__name__
)
)
snbt_text.SetBackgroundColour((255, 200, 200))
self.Layout()

View File

@ -2,6 +2,7 @@ import wx
from typing import Dict, Tuple
from amulet.api.block import PropertyType, PropertyValueType
from amulet_map_editor import lang
from amulet_map_editor.api.wx.ui.mc.state import BlockState
from amulet_map_editor.api.wx.ui.simple import ChoiceRaw
from .base import BaseSingleProperty
@ -20,10 +21,14 @@ class BaseVanillaSingleProperty(BaseSingleProperty):
super().__init__(parent, state)
self._property_sizer = wx.FlexGridSizer(2, 5, 5)
label = wx.StaticText(self, label="Property Name", style=wx.ALIGN_CENTER)
label = wx.StaticText(
self, label=lang.get("widget.mc.block.property.name"), style=wx.ALIGN_CENTER
)
self._property_sizer.Add(label, 1, wx.ALIGN_CENTER)
label = wx.StaticText(
self, label="Property Value (SNBT)", style=wx.ALIGN_CENTER
self,
label=lang.get("widget.mc.block.property.value"),
style=wx.ALIGN_CENTER,
)
self._property_sizer.Add(label, 1, wx.ALIGN_CENTER)

View File

@ -3,8 +3,9 @@ import wx
import PyMCTranslate
from typing import Type, Any
from .events import PlatformChangeEvent, EVT_PLATFORM_CHANGE
from amulet_map_editor import lang
from amulet_map_editor.api.wx.ui.mc.state import PlatformState, StateHolder, State
from .events import PlatformChangeEvent, EVT_PLATFORM_CHANGE
class PlatformSelect(wx.Panel, StateHolder):
@ -40,7 +41,7 @@ class PlatformSelect(wx.Panel, StateHolder):
self._sizer.AddGrowableCol(1)
self._platform_choice: SimpleChoice = self._add_ui_element(
"Platform:", SimpleChoice
lang.get("widget.mc.platform"), SimpleChoice
)
self._update_platform()
self._platform_choice.Bind(

View File

@ -4,8 +4,9 @@ import PyMCTranslate
from typing import Optional
from amulet.api.data_types import VersionNumberTuple, PlatformType
from .platform_select import PlatformSelect
from amulet_map_editor import lang
from amulet_map_editor.api.wx.ui.mc.state import VersionState, State
from .platform_select import PlatformSelect
from .events import VersionChangeEvent, EVT_VERSION_CHANGE
@ -33,7 +34,7 @@ class VersionSelect(PlatformSelect):
super().__init__(parent, state, **kwargs)
self._version_choice: Optional[ChoiceRaw] = self._add_ui_element(
"Version:", ChoiceRaw, reverse=True, sort=True
lang.get("widget.mc.version"), ChoiceRaw, reverse=True, sort=True
)
self._update_version_number()
self._version_choice.Bind(
@ -42,9 +43,16 @@ class VersionSelect(PlatformSelect):
)
self._blockstate_choice: Optional[SimpleChoice] = self._add_ui_element(
"Format:", SimpleChoice, shown=show_force_blockstate
lang.get("widget.mc.block_format"),
SimpleChoice,
shown=show_force_blockstate,
)
self._blockstate_choice.SetItems(
[
lang.get("widget.mc.block_format.native"),
lang.get("widget.mc.block_format.blockstate"),
]
)
self._blockstate_choice.SetItems(["native", "blockstate"])
self._update_force_blockstate()
self._blockstate_choice.Bind(wx.EVT_CHOICE, self._on_blockstate_change)

View File

@ -69,6 +69,22 @@ select_world.recent_worlds=Recently Opened Worlds
select_world.no_loader_found=Could not find a loader for this world.
select_world.loading_world_failed=Error loading world.
# Minecraft object widget labels
widget.mc.platform=Platform:
widget.mc.version=Version:
widget.mc.block_format=Format:
widget.mc.block_format.native=native
widget.mc.block_format.blockstate=blockstate
widget.mc.namespace=Namespace:
widget.mc.block.base_name=Block Name:
widget.mc.biome.base_name=Biome Name:
widget.mc.block.property.name=Property Name
widget.mc.block.property.value=Property Value (SNBT)
widget.mc.block.property.invalid_snbt=Invalid SNBT
widget.mc.block.property.invalid_value_fstring={val} not valid
# About
## The default program when a world is opened
program_about.tab_name=About