From 93fef814fc28e4c3822af68398f4cedb914d03b8 Mon Sep 17 00:00:00 2001 From: "Dr.-Ing. Amilcar do Carmo Lucas" Date: Thu, 7 Nov 2024 20:57:12 +0100 Subject: [PATCH] FIX: translate more strings --- .../frontend_tkinter_component_editor.py | 34 +++++++++++++++++++ .../frontend_tkinter_component_editor_base.py | 14 +++----- .../frontend_tkinter_template_overview.py | 2 +- .../middleware_template_overview.py | 22 ++++++------ 4 files changed, 51 insertions(+), 21 deletions(-) diff --git a/MethodicConfigurator/frontend_tkinter_component_editor.py b/MethodicConfigurator/frontend_tkinter_component_editor.py index 0c1d744..b7d6cb7 100644 --- a/MethodicConfigurator/frontend_tkinter_component_editor.py +++ b/MethodicConfigurator/frontend_tkinter_component_editor.py @@ -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() diff --git a/MethodicConfigurator/frontend_tkinter_component_editor_base.py b/MethodicConfigurator/frontend_tkinter_component_editor_base.py index d44fb14..7b638c8 100644 --- a/MethodicConfigurator/frontend_tkinter_component_editor_base.py +++ b/MethodicConfigurator/frontend_tkinter_component_editor_base.py @@ -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") @@ -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 @@ -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])) diff --git a/MethodicConfigurator/frontend_tkinter_template_overview.py b/MethodicConfigurator/frontend_tkinter_template_overview.py index 9829ea2..6ca8012 100644 --- a/MethodicConfigurator/frontend_tkinter_template_overview.py +++ b/MethodicConfigurator/frontend_tkinter_template_overview.py @@ -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)) diff --git a/MethodicConfigurator/middleware_template_overview.py b/MethodicConfigurator/middleware_template_overview.py index 7b64c40..bd87de5 100644 --- a/MethodicConfigurator/middleware_template_overview.py +++ b/MethodicConfigurator/middleware_template_overview.py @@ -8,6 +8,8 @@ SPDX-License-Identifier: GPL-3.0-or-later """ +from MethodicConfigurator import _ + class TemplateOverview: # pylint: disable=too-many-instance-attributes """ @@ -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):