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

enforces translation of GUI strings #1272

Merged
merged 9 commits into from
Aug 5, 2021
Merged

enforces translation of GUI strings #1272

merged 9 commits into from
Aug 5, 2021

Conversation

cfm
Copy link
Member

@cfm cfm commented Jul 22, 2021

Ready for review

Description

Closes #1265 by:

  1. adding a Semgrep rule untranslated-gui-string to catch common cases of GUI strings not marked with gettext's _() wrapper; and
  2. adding missing gettext wrappers to get the Semgrep rule to pass. :-)

Test Plan

  • The client runs.

Checklist

If these changes modify code paths involving cryptography, the opening of files in VMs or network (via the RPC service) traffic, Qubes testing in the staging environment is required. For fine tuning of the graphical user interface, testing in any environment in Qubes is required. Please check as applicable:

  • I have tested these changes in the appropriate Qubes environment
  • I do not have an appropriate Qubes OS workstation set up (the reviewer will need to test these changes)
  • These changes should not need testing in Qubes

If these changes add or remove files other than client code, the AppArmor profile may need to be updated. Please check as applicable:

  • I have updated the AppArmor profile
  • No update to the AppArmor profile is required for these changes
  • I don't know and would appreciate guidance

If these changes modify the database schema, you should include a database migration. Please check as applicable:

  • I have written a migration and upgraded a test database based on main and confirmed that the migration applies cleanly
  • I have written a migration but have not upgraded a test database based on main and would like the reviewer to do so
  • I need help writing a database migration
  • No database schema changes are needed

@cfm cfm force-pushed the 1265-string-review branch 2 times, most recently from f51fc31 to cc1e640 Compare July 28, 2021 23:20
@cfm cfm marked this pull request as ready for review July 28, 2021 23:45
@cfm cfm requested a review from a team as a code owner July 28, 2021 23:45
Copy link
Contributor

@rmol rmol left a comment

Choose a reason for hiding this comment

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

This looks good. We could go down a regex rabbit hole trying to catch cases like setText(stringvar + "...") but I think that effort would be better spent on developer guidelines.

I requested a couple of small changes on the very last commit.

securedrop_client/app.py Outdated Show resolved Hide resolved
securedrop_client/app.py Outdated Show resolved Hide resolved
sssoleileraaa
sssoleileraaa previously approved these changes Aug 3, 2021
Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

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

lgtm, test plan checks out

.semgrep/custom-rules.yml Show resolved Hide resolved
.semgrep/custom-rules.yml Show resolved Hide resolved
securedrop_client/gui/widgets.py Show resolved Hide resolved
cfm added 4 commits August 4, 2021 17:06
Catches Q{Action,Label,PushButton} constructors plus common Qt and
custom methods whose string arguments should be translated for
rendering in the GUI.
In these cases, the formatting arguments are string constants that are
already marked for gettext.
@cfm cfm force-pushed the 1265-string-review branch 3 times, most recently from 8f4e1bc to 465f330 Compare August 4, 2021 21:43
cfm added 5 commits August 4, 2021 17:54
Catches strings of the form---

    _("{foo} is a bar".format(foo=bar))

---that should take the form---

    _("{foo} is a bar").format(foo=bar)

---unless foo itself is expected to be translated.
@cfm cfm force-pushed the 1265-string-review branch from 465f330 to 1981284 Compare August 4, 2021 21:54
@cfm cfm requested a review from rmol August 4, 2021 22:03
@cfm
Copy link
Member Author

cfm commented Aug 4, 2021

test-buster is failing on safety; otherwise good for re-review.

@sssoleileraaa
Copy link
Contributor

sssoleileraaa commented Aug 5, 2021

looks like the only ci failure is due to a known safety issue:

-> coverage, installed 4.5.1, affected <6.0b1, id 41002

forcing merge based on @rmol's approval

@sssoleileraaa sssoleileraaa merged commit 03e3f3e into main Aug 5, 2021
@sssoleileraaa sssoleileraaa deleted the 1265-string-review branch August 5, 2021 21:24
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.

review codebase for UI strings to be translated
3 participants