Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization support #55

Merged
merged 9 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 68 additions & 35 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,68 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**

- OS: [e.g. iOS]
- Version: [e.g. 22]

**ArduPilot context**

- ArduPilot version
- Flight controller hardware
name: Bug report 🐛
description: Report a bug to help us improve
labels: ['bug']
assignees:
- amilcarlucas
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: checkboxes
id: new-bug
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for the bug you encountered.
options:
- label: I have searched the existing issues
required: true
- type: textarea
id: bug-description
attributes:
label: Description of the bug
description: Tell us what bug you encountered and what should have happened
validations:
required: true
- type: textarea
id: steps-to-reproduce
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
placeholder: |
Please tell us how to reproduce this bug, for example:
1. Build with '...' arguments
2. Run with '....' arguments
4. Use '...' configuration options
5. See the error
validations:
required: true
- type: textarea
id: expected-behavior
attributes:
label: Expected behavior
description: What should be the expected behavior.
placeholder: A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
id: screenshots
attributes:
label: Screenshots / Logs
description: If applicable, add screenshots to help explain your problem.
placeholder: Paste your screenshots here.
- type: textarea
id: software-info
attributes:
label: Software information
description: Please provide the following information about your environment.
value: |
- Operating system:
- arduPilot Methodic Configuration version:
validations:
required: true
- type: textarea
id: additional-context
attributes:
label: Additional context
description: Do you want to share any additional context about this bug?
placeholder: Add any other context about the problem here.
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
contact_links:
- name: Discord Chat
url: https://discord.com/channels/674039678562861068/859928885705965579
about: Ask questions and have discussions about ArduPilot Methodic Configurator on Discord
- name: Discuss Forum
url: https://discuss.ardupilot.org/t/new-ardupilot-methodic-configurator-gui/115038
about: Ask questions and have discussions about ArduPilot Methodic Configurator on Discord on ArduPilot's Discuss Forum
47 changes: 47 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Feature request ⛰️
description: Suggest an idea for this project
labels: ['feature/request']
assignees:
- amilcarlucas
body:
- type: markdown
attributes:
value: Thank you for suggesting this feature! The more information you provide, the more likely it is that it will be picked up.
- type: checkboxes
id: new-feature
attributes:
label: Is there an existing issue or pull request for this?
description: Please search to see if an issue or pull request already exists for the feature you desire.
options:
- label: I have searched the existing issues and pull requests
required: true
- type: textarea
id: feature-description
attributes:
label: Feature description
description: Is your feature request related to a problem? Please describe.
placeholder: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
validations:
required: true
- type: textarea
id: desired-solution
attributes:
label: Desired solution
description: Describe the solution you'd like
placeholder: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
id: alternatives-considered
attributes:
label: Alternatives considered
description: Describe alternatives you've considered
placeholder: A clear and concise description of any alternative solutions or features you've considered.
validations:
required: true
- type: textarea
id: additional-context
attributes:
label: Additional context
description: Do you want to share any additional context about this bug?
placeholder: Add any other context about the problem here.
4 changes: 2 additions & 2 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.12"]
python-version: ["3.8", "3.11"]
steps:

- name: Checkout
Expand All @@ -23,7 +23,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install 'pylint<=3.2.7'

- name: Analysing the code with pylint
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
cd windows
$env:VERSION=$(python return_version.py)
python return_version.py > version.txt
curl -L -o "c:\program files (x86)\inno setup 6\Languages\ChineseSimplified.isl" https://raw.githubusercontent.com/jrsoftware/issrc/refs/heads/main/Files/Languages/Unofficial/ChineseSimplified.isl
ISCC.exe /dMyAppVersion=$env:VERSION ardupilot_methodic_configurator.iss
ls Output

Expand Down
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
hooks:
- id: ruff
args: [ --fix ]
language: system
types: [python]
stages: [commit]
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args:
[
"-rn", # Only display messages
"-sn", # Don't display the score
"--rcfile=.pylintrc", # Link to your config file
]
stages: [push]
20 changes: 13 additions & 7 deletions MethodicConfigurator/ardupilot_methodic_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

from MethodicConfigurator.common_arguments import add_common_arguments_and_parse

from MethodicConfigurator.internationalization import _, load_translation

from MethodicConfigurator.version import VERSION


Expand All @@ -46,7 +48,7 @@ def argument_parser():
Returns:
argparse.Namespace: An object containing the parsed arguments.
"""
parser = argparse.ArgumentParser(description='ArduPilot methodic configurator is a simple GUI with a table that lists '
parser = argparse.ArgumentParser(description=_('ArduPilot methodic configurator is a simple GUI with a table that lists '
'parameters. The GUI reads intermediate parameter files from a directory and '
'displays their parameters in a table. Each row displays the parameter name, '
'its current value on the flight controller, its new value from the selected '
Expand All @@ -55,7 +57,7 @@ def argument_parser():
'When "Upload Selected to FC" is clicked, it uploads the selected parameters to the '
'flight controller. '
'When "Skip" is pressed, it skips to the next intermediate parameter file. '
'The process gets repeated for each intermediate parameter file.')
'The process gets repeated for each intermediate parameter file.'))
parser = FlightController.add_argparse_arguments(parser)
parser = LocalFilesystem.add_argparse_arguments(parser)
parser = ComponentEditorWindow.add_argparse_arguments(parser)
Expand All @@ -68,7 +70,7 @@ def connect_to_fc_and_read_parameters(args):

error_str = flight_controller.connect(args.device, log_errors=False)
if error_str:
if args.device and "No serial ports found" not in error_str:
if args.device and _("No serial ports found") not in error_str:
logging_error(error_str)
conn_sel_window = ConnectionSelectionWindow(flight_controller, error_str)
conn_sel_window.root.mainloop()
Expand All @@ -77,9 +79,9 @@ def connect_to_fc_and_read_parameters(args):
if vehicle_type == "": # not explicitly set, to try to guess it
if flight_controller.info.vehicle_type is not None:
vehicle_type = flight_controller.info.vehicle_type
logging_debug("Vehicle type not set explicitly, auto-detected %s.", vehicle_type)
logging_debug(_("Vehicle type not set explicitly, auto-detected %s."), vehicle_type)
else:
logging_info("Vehicle type explicitly set to %s.", vehicle_type)
logging_info(_("Vehicle type explicitly set to %s."), vehicle_type)

return flight_controller,vehicle_type

Expand Down Expand Up @@ -110,11 +112,15 @@ def component_editor(args, flight_controller, vehicle_type, local_filesystem, ve
flight_controller.fc_parameters)
if error_message:
logging_error(error_message)
show_error_message("Error in derived parameters", error_message)
show_error_message(_("Error in derived parameters"), error_message)
sys_exit(1)


def main():
# modify the global _() function
global _ # pylint: disable=global-statement

_ = load_translation() # done as soon as possible so that the correct language is used
args = argument_parser()

logging_basicConfig(level=logging_getLevelName(args.loglevel), format='%(asctime)s - %(levelname)s - %(message)s')
Expand All @@ -131,7 +137,7 @@ def main():
local_filesystem = LocalFilesystem(args.vehicle_dir, vehicle_type, flight_controller.info.flight_sw_version,
args.allow_editing_template_files)
except SystemExit as exp:
show_error_message("Fatal error reading parameter files", f"{exp}")
show_error_message(_("Fatal error reading parameter files"), f"{exp}")
raise

param_default_values_dirty = False
Expand Down
6 changes: 3 additions & 3 deletions MethodicConfigurator/argparse_check_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from operator import ge
from operator import lt
from operator import le

from MethodicConfigurator.internationalization import _

class CheckRange(Action):
'''
Expand All @@ -29,9 +29,9 @@ class CheckRange(Action):

def __init__(self, *args, **kwargs):
if "min" in kwargs and "inf" in kwargs:
raise ValueError("either min or inf, but not both")
raise ValueError(_("either min or inf, but not both"))
if "max" in kwargs and "sup" in kwargs:
raise ValueError("either max or sup, but not both")
raise ValueError(_("either max or sup, but not both"))

for name in self.ops:
if name in kwargs:
Expand Down
Loading