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

Merged
merged 241 commits into from
Dec 22, 2024

Conversation

kdmukai
Copy link
Contributor

@kdmukai kdmukai commented Nov 3, 2024

Description

This is a MASSIVE refactor. Apologies to all!!

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.

Note: Building the image also depends on: SeedSigner/seedsigner-os#79


Remaining tasks:

  • Code review, discussions, explanations
  • Updates after feedback

In parallel (but not necessarily required before merging this PR?):

  • Complete initial round of Spanish translations.
  • Native Spanish speakers do some hands-on testing with a preview image.
  • Ongoing translation iterations (e.g. alter messages so they fit better).
  • SeedSigner OS needs v0.8.5 integration w/l10n support seedsigner-os#79 merged.

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
* New `ScreenshotConfig` utility class.
* Proper reset & isolation when looping to generate screenshots for multiple locales.
* Bugfix for unpredictable race condition when rendering screenshots.
* Improved screenshots due to the above.
@jdlcdl
Copy link

jdlcdl commented Dec 19, 2024

In 60b23f3, I'm noticing a remnant of orange pixels at the right edge from active buttons that had scrolling text as soon as you move off the button. Easy to see when browsing addresses but also visible in settings menus (wait for scrolling to begin, then move off that menu item).

@kdmukai
Copy link
Contributor Author

kdmukai commented Dec 19, 2024

In 60b23f3, I'm noticing a remnant of orange pixels at the right edge from active buttons that had scrolling text as soon as you move off the button. Easy to see when browsing addresses but also visible in settings menus (wait for scrolling to begin, then move off that menu item).

Confirmed. Seeing how my TextArea text width workaround interacts with the scrollable buttons. This artifact is new since that change.

@kdmukai
Copy link
Contributor Author

kdmukai commented Dec 20, 2024

@jdlcdl 09f016b should resolve it.

@jdlcdl
Copy link

jdlcdl commented Dec 20, 2024

@jdlcdl 09f016b should resolve it.

I confirm that right-side artifacts left over from buttons that scroll is resolved. As well, that I can no longer provoke the scrolling-title lock-race issue that you fixed in the following commits -- up to fe2b579 -- all tested w/ seedsigner-os on a pi02w for now, also pi0 and raspi-os dev device.

@jdlcdl
Copy link

jdlcdl commented Dec 20, 2024

Up to date reviewing to commit 229151d

Will be testing on pi0 and pi02w with the following seedsigner-os images:

0a8dae47daef83910b00770d04b1d880cab3fa0cd8a59bf125814155486b53dc  seedsigner_os.initial_multilanguage_0.8.0.pi02w.img
19d85a014f67a4ab9db0c0c3476d90f554f87b98a30b6667862086c68626d1df  seedsigner_os.initial_multilanguage_0.8.0.pi0.img

@kdmukai
Copy link
Contributor Author

kdmukai commented Dec 20, 2024

Bug found by @jdlcdl in seed_views.py fixed in cf19a81

@jdlcdl
Copy link

jdlcdl commented Dec 21, 2024

Bug found by @jdlcdl in seed_views.py fixed in cf19a81

I confirm that this is resolved, was able to test on raspi-os dev setup at commit a2ffa7d.


I expect to respond here later today, Dec 21st 2024, with my final ACK on this pr. Todo: final testing at a2ffa7d.

  • on pi0 w/ seedsigner-os at f8a8497 I have a 25MB binary: 6a35bad23c8e569dcc87706ecf36d2109a14581b297e65a6ba009f1d8cafa0e5
  • on pi02w at same seedsigner-os, I have a 26MB binary: 958872eb59b6dccc3bee0efcdbdcdc043bbdc3b86c07acc837ff6af517138f5c
  • on a fresh manual-build raspi-os dev signer (w/ required changes for libzbar and systemd setup) on both boards above.

I've completed my testing. With the known "long text" in spanish for "Main menu" and "clear all" in IOtest:

ACK for candidate release at a2ffa7d

@newtonick
Copy link
Collaborator

ACK, reviewed and tested

Congratulations @kdmukai on this PR.

I can also confirm hash 6a35bad23c8e569dcc87706ecf36d2109a14581b297e65a6ba009f1d8cafa0e5 on the pi0 seedsigner-os build.

@jdlcdl thank you for all your hard work on this PR as well. Not sure it would have happened without your contributions!

@newtonick newtonick merged commit 3fbc863 into SeedSigner:dev Dec 22, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 8.5 RC1
Development

Successfully merging this pull request may close these issues.

5 participants