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

Fix translatable string issue in Albatross driver #17116

Merged
merged 2 commits into from
Sep 5, 2024

Conversation

CyrilleB79
Copy link
Collaborator

@CyrilleB79 CyrilleB79 commented Sep 4, 2024

Link to issue number:

None

Summary of the issue:

In Albatross driver, a string consisting in the concatenation of normal strings ("...") and an f-string) is passed to the _ translation function.
As a consequence:

  • Only a part of the concatenated string appears in the .pot file instead of the full concatenation
  • In any case, f-strings cannot be used for translatable messages since the formatting should be applied only after the gettext function has been called

Thus, this message was not translated.

Description of user facing changes

The message of the Albatross driver is now translated.

Description of development approach

Do not use f-string. Instead used .format function, applied to the translated string.

Also checked that no other occurrence of translated f-string is found in NVDA: In Git bash:

  • Concatenate the content of all files in one single file:
    find source -name '*.py' -type f -exec cat {} \; > /c/users/Cyrille/out.txt
  • Open out.txt in my editor
  • Look for any translatable message that contains f-strings
    ((?<!_)_|ngettext)\s*\(( *\r\n)?(\s*[#"'][^\n]+\n)*[\s\t]*f['"]

Note: This regexp has some limitations. It only looks for the use of _ function as well as ngettext function; it does not check pgettext/npgettext usage. Moreover, for ngettext, it only checks the singular form. Though, it should already help capture the majority of cases.

Testing strategy:

  • Check in the .pot file that we have the full message
  • Test on a real device: not done (but the fix is quite simple so this test may not be necessary)

Known issues with pull request:

None

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Cc @burmancomp

Summary by CodeRabbit

  • New Features
    • Improved clarity of configuration messages for the Albatross braille display driver when used with NVDA.
  • Bug Fixes
    • Updated string formatting for better user understanding regarding the maximum number of status cells allowed.

@CyrilleB79
Copy link
Collaborator Author

@burmancomp would you help to test on a real device.
I can provide you with a build containing the test translation (Google translation if needed) for any language other than English. In which language other than English would you be able to test?
Thanks.

@burmancomp
Copy link
Contributor

Let's suppose it works.

@CyrilleB79 CyrilleB79 marked this pull request as ready for review September 4, 2024 21:45
@CyrilleB79 CyrilleB79 requested a review from a team as a code owner September 4, 2024 21:45
Copy link
Contributor

coderabbitai bot commented Sep 4, 2024

Walkthrough

The change involves modifying the _skipRedundantInitPackets method in the Albatross braille display driver. The update focuses on the string formatting of a user configuration message, replacing the variable MAX_STATUS_CELLS_ALLOWED with maxCells to align with a new formatting approach. The overall logic of the method remains unchanged, maintaining its functionality in handling redundant initialization packets.

Changes

File Path Change Summary
source/brailleDisplayDrivers/albatross/driver.py Updated string formatting in _skipRedundantInitPackets method to use maxCells instead of MAX_STATUS_CELLS_ALLOWED.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@SaschaCowley SaschaCowley changed the title Fix translatable string issue Fix translatable string issue in Albatross driver Sep 5, 2024
Copy link
Member

@SaschaCowley SaschaCowley left a comment

Choose a reason for hiding this comment

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

Please add a changes entry.

source/brailleDisplayDrivers/albatross/driver.py Outdated Show resolved Hide resolved
@SaschaCowley SaschaCowley marked this pull request as draft September 5, 2024 06:11
@CyrilleB79
Copy link
Collaborator Author

Why do you want a change entry?

What this PR is doing is:

  • before: one message was not translated
  • after: the message is translated

We do not put a new item in the change log when one more message is being translated...

@CyrilleB79 CyrilleB79 marked this pull request as ready for review September 5, 2024 06:37
@SaschaCowley
Copy link
Member

@CyrilleB79

We do not put a new item in the change log when one more message is being translated...

Sorry, my bad. My thinking was that users of this driver may appreciate that they may now be able to see this message in their preferred language. It is very minor, so we're happy to leave this out of the changes file.

Copy link
Member

@SaschaCowley SaschaCowley left a comment

Choose a reason for hiding this comment

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

Thanks @CyrilleB79, this is a nice quality of life fix

@SaschaCowley SaschaCowley merged commit dbdde44 into nvaccess:beta Sep 5, 2024
4 checks passed
@github-actions github-actions bot added this to the 2025.1 milestone Sep 5, 2024
@CyrilleB79 CyrilleB79 deleted the translatableString branch September 10, 2024 08:13
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