Skip to content

Add English and Chinese internationalization with persistent language selection - #27

Open
MiguelCaldasMS wants to merge 10 commits into
Babel36acl:mainfrom
MiguelCaldasMSOrg:feat/flutter-i18n-en-zh
Open

MiguelCaldasMS wants to merge 10 commits into
Babel36acl:mainfrom
MiguelCaldasMSOrg:feat/flutter-i18n-en-zh

Conversation

@MiguelCaldasMS

@MiguelCaldasMS MiguelCaldasMS commented Oct 22, 2026 •

Copy link
Copy Markdown

Summary

  • Introduce Flutter's standard ARB / gen-l10n localization pipeline with 701 messages in both Simplified Chinese and English.
  • Add immediate, persistent language selection: system default, Simplified Chinese, or English. Unsupported system languages fall back to English.
  • Localize navigation, all 30 operation pages and their tabs, dialogs, warnings, validation, framework widgets, command help, and dump analysis.
  • Store write-back status and per-block outcomes independently of the locale, so active, finished, cancelled, and connection-lost sequences follow language changes without losing results or restarting commands.
  • Distinguish DESFire Applications from Apply and HID reader brute-force from cryptographic key recovery. Preserve the active language during command-card imports and report language-storage failures in Settings without blocking startup or later save retries.
  • Keep standalone Dart tools framework-free by adapting Flutter localizations at the backend boundary.
  • Preserve PM3 command syntax, raw client output, serialized data formats, existing client settings, and in-progress UI data.
  • Update both READMEs, synchronized HTML snapshots, contributor guidance, localization/storage/tooling documentation, and clearly marked historical specifications. Add translation checks to CI and focused bilingual regression coverage.

Upstream compatibility

  • Based directly on upstream main (b7464cf), with no intervening fork-only commits.
  • Keep documentation upstream-neutral. Generated localization Dart files, build outputs, firmware, card data, and machine-specific SDK configuration are not included.

Validation

Latest follow-up validation on Windows:

  • Localization generation succeeded; the resource checker reports 701 complete messages per language.
  • Static analysis of the changed application and regression-test Dart files reported no issues.
  • 40 related localization, write-state, session, and UI tests passed. Coverage includes Chinese -> English -> Chinese switching through Settings with a loaded dump, retained mixed block results, active writes, cancellation, connection loss, dedicated HID labels, and unchanged command syntax.
  • git diff --check passed.

Commands:

flutter gen-l10n
dart run tools\check_localizations.dart
dart analyze lib\state\app_state.dart lib\ui\pages\dump_viewer_page.dart lib\ui\pages\lf_hid_page.dart test\state\write_progress_test.dart test\ui\lf_hid_page_test.dart test\l10n\localization_test.dart
flutter test --no-pub test\l10n test\state\write_progress_test.dart test\state\app_state_session_test.dart test\ui\lf_hid_page_test.dart test\ui\hf_mfdes_page_test.dart test\ui\page_output_test.dart

Earlier PR validation, before the latest HID/write-progress fixes:

  • All six standalone Dart tools compiled successfully; write-producing generators were compiled rather than executed.
  • A Windows release build completed using Flutter 3.47.7 / Dart 3.13.5; it has not been rebuilt for these latest follow-ups.
  • An earlier full-suite run had 80 passing tests. Subsequent runs exposed an intermittent existing Windows batch-handshake test; the same failure was reproduced using the unchanged upstream backend and fixture.

Linux builds and real-device operations were not run locally. The existing Windows/Linux CI workflow is retained. Widget-test viewports and limitations are documented in docs/localization.md.

Use Flutter ARB generation with persistent language selection, localized command help and dump analysis, bilingual UI coverage, and translation documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The process layer's new Flutter dependency breaks the documented standalone Dart catalog-sync tool, and localization defects remain.

3 open issues
What changed in this PR

Adds English and Simplified Chinese localization to the Flutter desktop client, with persistent language selection and integration across UI, command help, and application-generated messages.

Changes:

  • Introduces ARB generation, locale management, and separate language-preference storage.
  • Localizes pages, shared widgets, validation, and dump analysis while retaining command syntax and raw output.
  • Adds bilingual tests, translation checks in CI, and contributor documentation.
File Description
tools/​check_localizations.dart Checks translation completeness and metadata.
test/​ui/​settings_page_test.dart Uses the localized test wrapper.
test/​ui/​page_output_test.dart Runs output tests with localization delegates.
test/​ui/​command_card_editor_test.dart Provides localization for editor tests.
test/​support/​localized_test_app.dart Adds a localized wrapper and in-memory preferences.
test/​l10n/​localization_test.dart Covers bilingual rendering, switching, and analysis.
test/​l10n/​app_locale_controller_test.dart Tests preference persistence and error handling.
README.md Documents language selection and development setup.
README.en.md Adds English usage and development instructions.
pubspec.yaml Enables localization generation and dependencies.
pubspec.lock Records localization and updated dependency versions.
lib/​ui/​widgets/​command_card_editor.dart Localizes draft editing and export controls.
lib/​ui/​pages/​trace_page.dart Localizes trace controls.
lib/​ui/​pages/​terminal_page.dart Localizes controls and reloads language-specific help.
lib/​ui/​pages/​settings_page.dart Adds language selection and persistence feedback.
lib/​ui/​pages/​script_page.dart Localizes script controls.
lib/​ui/​pages/​nfc_page.dart Localizes NFC decoding controls.
lib/​ui/​pages/​mifare_page.dart Localizes MIFARE operations and warnings.
lib/​ui/​pages/​lf_pyramid_page.dart Localizes Pyramid operations.
lib/​ui/​pages/​lf_page.dart Localizes general low-frequency operations.
lib/​ui/​pages/​lf_keri_page.dart Localizes Keri operations.
lib/​ui/​pages/​lf_io_page.dart Localizes ioProx operations.
lib/​ui/​pages/​lf_indala_page.dart Localizes Indala operations.
lib/​ui/​pages/​lf_hitag_page.dart Localizes Hitag operations.
lib/​ui/​pages/​lf_hid_page.dart Localizes HID operations and tabs.
lib/​ui/​pages/​lf_fdxb_page.dart Localizes FDX-B operations.
lib/​ui/​pages/​lf_awid_page.dart Localizes AWID operations.
lib/​ui/​pages/​hf_sniff_page.dart Localizes capture and tuning controls.
lib/​ui/​pages/​hf_seos_page.dart Localizes SEOS operations.
lib/​ui/​pages/​hf_mfu_page.dart Localizes Ultralight/NTAG operations and confirmations.
lib/​ui/​pages/​hf_mfdes_page.dart Localizes DESFire operations and tabs.
lib/​ui/​pages/​hf_legic_page.dart Localizes Legic operations and confirmations.
lib/​ui/​pages/​hf_iclass_page.dart Localizes iCLASS operations.
lib/​ui/​pages/​hf_fido_page.dart Localizes FIDO operations.
lib/​ui/​pages/​hf_felica_page.dart Localizes FeliCa operations.
lib/​ui/​pages/​hf_emv_page.dart Localizes EMV operations.
lib/​ui/​pages/​hf_15_page.dart Localizes ISO 15693 operations.
lib/​ui/​pages/​hf_14b_page.dart Localizes ISO 14443-B operations.
lib/​ui/​pages/​dump_compare_page.dart Localizes comparison labels and errors.
lib/​ui/​pages/​data_page.dart Localizes data-processing controls.
lib/​ui/​pages/​connection_page.dart Localizes connection and file-management UI.
lib/​ui/​home_page.dart Localizes navigation and connection status.
lib/​ui/​components/​result_display.dart Localizes result controls without translating output.
lib/​ui/​components/​hex_input_field.dart Localizes input hints and limits.
lib/​ui/​components/​connection_guard.dart Localizes readiness warnings.
lib/​state/​hardware_state.dart Makes smartcard status locale-aware.
lib/​state/​file_state.dart Localizes scan-failure messages.
lib/​state/​connection_state.dart Propagates localization and formats settings errors.
lib/​state/​app_state.dart Propagates localization and translates write progress.
lib/​services/​pm3_command_catalog.dart Supports injected asset bundles and language-specific loading.
lib/​services/​locale_settings_store.dart Persists language preferences separately.
lib/​services/​dump_converter.dart Adds localized format labels and conversion messages.
lib/​parsers/​key_parser.dart Localizes key-text validation errors.
lib/​parsers/​dump_parser.dart Makes analysis caching locale-aware.
lib/​models/​dump_analysis.dart Localizes analysis descriptions.
lib/​models/​command_card.dart Localizes card validation and export errors.
lib/​main.dart Connects locale selection, delegates, and shutdown flushing.
lib/​l10n/​localized_messages.dart Adds shared localization support for non-UI objects.
lib/​l10n/​l10n.dart Adds the context localization accessor.
lib/​l10n/​app_locale_controller.dart Manages locale restoration and serialized saves.
lib/​core/​pm3/​pm3_controller.dart Propagates localization to the backend.
lib/​backend/​desktop_cli/​pm3_process.dart Localizes process diagnostics.
lib/​backend/​desktop_cli/​desktop_cli_backend.dart Forwards localization to the process wrapper.
l10n.yaml Configures ARB code generation.
docs/​localization.md Documents translation and preference-storage design.
CONTRIBUTING.md Adds translation contribution requirements.
CHANGELOG.md Records multilingual support.
.gitignore Excludes generated localization Dart files.
.github/​workflows/​build.yml Adds localization generation and checks.

Review effort: Balanced

Comment thread lib/models/command_card.dart Resolved
Comment thread lib/ui/pages/hf_mfdes_page.dart Resolved
Inject framework-independent process messages and adapt AppLocalizations only in the Flutter-facing backend. Preserve standalone Chinese defaults and cover the real Dart CLI entry points and live GUI language changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 12:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unhandled preference-directory exceptions can prevent startup and block subsequent language saves.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Convert directory lookup failures to handled storage errors

lib/​services/​locale_settings_store.dart:23

If getApplicationSupportDirectory() cannot resolve a directory, it throws MissingPlatformDirectoryException, not FileSystemException. This escapes the controller's handlers, and main() awaits initialization before runApp(), so the UI never starts instead of showing a Settings error. A directory-lookup failure during saving also leaves the save queue failed and blocks later saves. Convert directory-provider exceptions to a storage exception that the controller already handles.

1 resolved since last review

Review effort: Balanced

MiguelCaldasMS and others added 2 commits October 22, 2026 13:45
Copy active localizations to both staging cards before validating imported data. Add English regressions for invalid blocks, Key A and Key B in draft and card imports, including atomicity and retained language checks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a separate Applications tab resource in English and Chinese without changing the editor Apply action. Cover both locales with widget regressions and document distinct resources for different meanings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 12:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unhandled preference-directory exceptions can prevent startup and leave subsequent language saves unable to recover.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Handle missing application support directory during settings I/O

lib/​services/​locale_settings_store.dart:21

getApplicationSupportDirectory() can throw MissingPlatformDirectoryException, which is not caught by the controller's FileSystemException/FormatException handlers. During restore, this prevents startup because main() awaits initialization before runApp(). During saving, it leaves _queue failed; later selections fail at await previous, skip cleanup, and leave the saving indicator active. Normalize directory-provider exceptions here so both paths report a Settings error, startup can continue, and later saves can recover.

2 resolved since last review

Review effort: Balanced

Normalize path-provider directory failures to FileSystemException while preserving diagnostics and stack traces. Keep initialization and failed saves on the controller handled storage-error path, with coverage for startup, Settings errors, queued saves and successful retries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 13:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Existing write-progress messages remain in the previous language after switching, leaving live localization incomplete.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Refresh write progress and results when the locale changes

lib/​state/​app_state.dart:322

Write-progress status and per-block results are stored as translated strings, but updateLocalizations does not refresh them. Complete or cancel a write in Chinese, switch to English in Settings, and return to the write-back tab: DumpViewer still displays progress.currentStatus and r.message verbatim in Chinese. Store locale-independent status/result data and format it with the current locale when displayed, so switching languages updates existing progress without losing results.

Review effort: Balanced

MiguelCaldasMS and others added 2 commits October 22, 2026 14:31
Refresh user and contributor guidance, language storage and standalone-tool contracts, and generated HTML snapshots. Add a documentation index, distinguish historical designs from current implementation, and record the outstanding HID wording issue without modifying functional code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use dedicated HID reader brute-force resources and format stored write states and block outcomes with the current locale. Add bilingual regression coverage and refresh related documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cross-cutting locale propagation and desktop persistence need human validation, and retained connection errors still require a localization fix.

1 open issue

Review effort: Balanced

Store process error kinds and arguments and render them through the active framework-free message adapter. Cover Settings language switching after connection failure without reconnecting or rewriting terminal output, including startup and lifecycle diagnostics.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 15:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The cross-cutting language, persistence and backend changes need human confirmation of desktop CI results and live-switch behavior.

4 open issues

Review effort: Balanced

Comment thread README.en.md Resolved
Comment thread docs/lf_hid_page_spec.md Resolved
Comment thread lib/ui/widgets/command_card_editor.dart Resolved
Format retained save confirmations with the current locale while preserving cancellation, status clearing and error replacement. Add regression coverage and replace stale localization anchors and the outdated HID status note, including the synchronized README HTML snapshot.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Application-wide language switching, persistence, and device lifecycle changes warrant human review with Windows and Linux runtime validation.

1 open issue
3 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cross-cutting locale propagation, persistence, and active device-state changes need final human review supported by current Windows and Linux validation.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Add the parallel docs.en tree and English root-document counterparts. Use README.en.md and README.en.html for the full English guide, retain the shorter guide as README.quickstart.en.md, and synchronize README navigation, cross-references and HTML snapshots. Preserve Chinese document bodies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 22:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The cross-cutting UI, persistence, and backend integration needs final human review with current Windows and Linux validation evidence.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

No deployments
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.

2 participants