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

Initial l10n / multilanguage support #620

Draft
wants to merge 220 commits into
base: dev
Choose a base branch
from

Conversation

kdmukai
Copy link
Contributor

@kdmukai kdmukai commented Nov 3, 2024

Description

This is a MASSIVE refactor. Apologies to all!!

(this description is still a work-in-progress; more details will be added before this DRAFT PR is flipped to Ready for Review)

Review the new l10n/README.md to get the basics of how the translations are implemented. The biggest key is that we have to be a bit savvy about TWO distinct (yet often overlapping) translation-related tasks:

  1. Mark a string literal as needing translation. This gets it added to Transifex for translators to work on.
  2. Retrieving the translation for either an English string literal OR a string held in a variable.

New:

  • Submodule dependency on the new seedsigner-translations repo.

  • ButtonOption class to manage View.button_data entries. Allows us to preserve the existing approach of using class-level attrs to indicate user options in a View (e.g. MainMenuView.TOOLS vs MainMenuView.SCAN). It's wired up to mark the user-facing button labels as needing translation. But never translates those values based on locale (that happens later in the Screen classes; we need these class-level attrs to remain untranslated). Bonus: cleans up some sloppy tuple-based code in those attrs and enables some nicer handling (see its return_data field).

  • seedsigner.helpers.l10n.mark_for_translation: you'll see this imported as _mft and used for any class-level attr that isn't already covered by the ButtonOption above (e.g. a class-level display field like title that has an English literal string). As far as the translation handling goes, it behaves the same as ButtonOption: mark it for translation, but do not provide the translated version.

  • Screenshot generator made l10n aware, generates screenshots in each supported language.

    • Better integration with pytest: dynamically considers each locale as a separate test to report progress on.
    • Dynamically sets pytest.skip for deactivated locales when the optional --locale command line arg is present.
    • Added some screenshots that were previously missing, various screenshot generation tweaks.
  • TopNav scrollable titles via updated TextArea component. Autoscrolls if the title is too long to display.

    • ScrollableTextLine added as a convenience class that's really just a scrolling single line TextArea.
  • Simplified python-babel CLI commands via setup.py and setup.cfg.

    • python-babel does not have pyproject.toml integration, unfortunately. So setup.py is back in skeleton form to enable the CLI convenience; the simplicity of python setup.py extract_messages is worth some extra project file cruft.
    • setup.cfg contains all the configuration for the extract_messages and compile_catalog integrations we need.

misc:

  • Adds tests/run_full_coverage.sh convenience script to generate local code coverage reports that combine the results from the test suite and the screenshot generator.
  • Slightly expanded coverage file filtering in pyproject.toml to account for the additional GUI / Screen coverage provided by the screenshot generator.
  • CI update to recursively fetch submodules when setting up the test runner (has to pull in the seedsigner-translations repo as a submodule for the new l10n tests to pass).
  • CI update to combine coverage reports for both the test suite and the screenshot generator.
  • Some import refactoring to hide our module imports whenever possible (moves the imports to within their calling functions). Not really necessary, just trying to minimize imports at the top of each file.

This pull request is categorized as a:

  • New feature
  • Code refactor
  • Documentation
  • Ginormous whale

Checklist

  • I’ve run pytest and made sure all unit tests pass before sumbitting the PR

If you modified or added functionality/workflow, did you add new unit tests?

  • Yes

I have tested this PR on the following platforms/os:

kdmukai and others added 30 commits April 30, 2022 06:57
* Versions `Pillow` up to 9.1.0
…nshot generator screens

* Improved `SeedReviewPassphraseScreen` display
* Blue "Sign" icon replaces green paper airplane.
* New `SeedPassphraseWarningView` before adding passphrase, plus `Settings` option to disable.
* TextArea spacing bugfix
* Additional note on SeedBackupScreen
* Filter out LANCZOS deprecation warnings from pytest output
* Prevent ScreenshotRenderer from attempting to capture background task rendering jobs.
* Bugfix to stop loading screen spinner if PSBTParser fails.
*
* CS update
* PT update
* Screenshot generator bugfix
@jdlcdl
Copy link

jdlcdl commented Nov 10, 2024

Working on a new pi02w development board, have tried up to 80ea2cb but need to review code changes since last review.

* Scrolling enabled for TopNav titles, Button, LargeIconButton.
* Button label text can be different between Active and Inactive states.
* Syncing to latest updates in screenshots submodule.
* Update to how child Component threads get managed by parent Screen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants