Skip to content

Commit

Permalink
FIX: translate more strings
Browse files Browse the repository at this point in the history
  • Loading branch information
amilcarlucas committed Nov 7, 2024
1 parent d9c8ecd commit 93fef81
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 21 deletions.
34 changes: 34 additions & 0 deletions MethodicConfigurator/frontend_tkinter_component_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,40 @@ def __init__(self, version, local_filesystem: LocalFilesystem = None):
self.can_ports = ["CAN1", "CAN2"]
self.i2c_ports = ["I2C1", "I2C2", "I2C3", "I2C4"]
ComponentEditorWindowBase.__init__(self, version, local_filesystem)
# these are just here so that pygettext extracts them, they have no function
_vehicle_components_strings = _("Flight Controller")
_vehicle_components_strings = _("Product")
_vehicle_components_strings = _("Manufacturer")
_vehicle_components_strings = _("Model")
_vehicle_components_strings = _("URL")
_vehicle_components_strings = _("Version")
_vehicle_components_strings = _("Firmware")
_vehicle_components_strings = _("Type")
_vehicle_components_strings = _("Notes")
_vehicle_components_strings = _("Frame")
_vehicle_components_strings = _("Specifications")
_vehicle_components_strings = _("TOW min Kg")
_vehicle_components_strings = _("TOW max Kg")
_vehicle_components_strings = _("RC Controller")
_vehicle_components_strings = _("RC Transmitter")
_vehicle_components_strings = _("RC Receiver")
_vehicle_components_strings = _("FC Connection")
_vehicle_components_strings = _("Protocol")
_vehicle_components_strings = _("Telemetry")
_vehicle_components_strings = _("Battery Monitor")
_vehicle_components_strings = _("Battery")
_vehicle_components_strings = _("Chemistry")
_vehicle_components_strings = _("Volt per cell max")
_vehicle_components_strings = _("Volt per cell low")
_vehicle_components_strings = _("Volt per cell crit")
_vehicle_components_strings = _("Number of cells")
_vehicle_components_strings = _("Capacity mAh")
_vehicle_components_strings = _("ESC")
_vehicle_components_strings = _("Motors")
_vehicle_components_strings = _("Poles")
_vehicle_components_strings = _("Propellers")
_vehicle_components_strings = _("Diameter_inches")
_vehicle_components_strings = _("GNSS Receiver")

def update_json_data(self):
super().update_json_data()
Expand Down
14 changes: 4 additions & 10 deletions MethodicConfigurator/frontend_tkinter_component_editor_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,8 @@ def __display_component_editor_usage_instructions(parent: tk.Tk):
instructions_text = RichText(
usage_popup_window.main_frame, wrap=tk.WORD, height=5, bd=0, background=style.lookup("TLabel", "background")
)
instructions_text.insert(tk.END, _("1. Describe "))
instructions_text.insert(tk.END, _("all"), "bold")
instructions_text.insert(tk.END, _(" vehicle component properties in the window below\n"))
instructions_text.insert(tk.END, _("2. Scroll "))
instructions_text.insert(tk.END, _("all the way down"), "bold")
instructions_text.insert(tk.END, _(" and make sure to edit "))
instructions_text.insert(tk.END, _("all"), "bold")
instructions_text.insert(tk.END, _(" fields\n"))
instructions_text.insert(tk.END, _("1. Describe all vehicle component properties in the window below\n"))
instructions_text.insert(tk.END, _("2. Scroll all the way down and make sure to edit all properties\n"))
instructions_text.insert(tk.END, _("3. Do not be lazy, collect the required information and enter it\n"))
instructions_text.insert(tk.END, _("4. Press the "))
instructions_text.insert(tk.END, _("Save data and start configuration"), "italic")
Expand Down Expand Up @@ -180,7 +174,7 @@ def __add_widget(self, parent, key, value, path):
path (list): The path to the current key in the JSON data.
"""
if isinstance(value, dict): # JSON non-leaf elements, add LabelFrame widget
frame = ttk.LabelFrame(parent, text=key)
frame = ttk.LabelFrame(parent, text=_(key))
is_toplevel = parent == self.scroll_frame.view_port
side = tk.TOP if is_toplevel else tk.LEFT
pady = 5 if is_toplevel else 3
Expand All @@ -193,7 +187,7 @@ def __add_widget(self, parent, key, value, path):
entry_frame = ttk.Frame(parent)
entry_frame.pack(side=tk.TOP, fill=tk.X, pady=(0, 5))

label = ttk.Label(entry_frame, text=key)
label = ttk.Label(entry_frame, text=_(key))
label.pack(side=tk.LEFT)

entry = self.add_entry_or_combobox(value, entry_frame, tuple([*path, key]))
Expand Down
2 changes: 1 addition & 1 deletion MethodicConfigurator/frontend_tkinter_template_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, parent: tk.Tk):
super().__init__(parent)
title = _("Amilcar Lucas's - ArduPilot methodic configurator {} - Template Overview and selection")
self.root.title(title.format(VERSION))
self.root.geometry("1200x300")
self.root.geometry("1200x600")

instruction_text = _("Please double-click the template below that most resembles your own vehicle components")
instruction_label = ttk.Label(self.main_frame, text=instruction_text, font=("Arial", 12))
Expand Down
22 changes: 12 additions & 10 deletions MethodicConfigurator/middleware_template_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
SPDX-License-Identifier: GPL-3.0-or-later
"""

from MethodicConfigurator import _


class TemplateOverview: # pylint: disable=too-many-instance-attributes
"""
Expand Down Expand Up @@ -35,16 +37,16 @@ def __init__(self, components_data: dict):
def columns():
# Must match the order in the __init__() function above
return (
"Template path",
"FC\nManufacturer",
"FC\nModel",
"TOW Max\n[KG]",
"Prop Diameter\n[inches]",
"RC\nProtocol",
"Telemetry\nModel",
"ESC\nProtocol",
"GNSS\nModel",
"GNSS\nConnection",
_("Template path"),
_("FC\nManufacturer"),
_("FC\nModel"),
_("TOW Max\n[Kg]"),
_("Prop Diameter\n[inches]"),
_("RC\nProtocol"),
_("Telemetry\nModel"),
_("ESC\nProtocol"),
_("GNSS\nModel"),
_("GNSS\nConnection"),
)

def attributes(self):
Expand Down

0 comments on commit 93fef81

Please sign in to comment.