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

Set default input and translation tables according to NVDA's language #17222

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

nvdaes
Copy link
Sponsor Contributor

@nvdaes nvdaes commented Sep 26, 2024

Link to issue number:

Fixes #16390
Fixes #290

Summary of the issue:

By default, NVDA should set braille tables according to the current NVDA's language.

Description of user facing changes

When NVDA starts, if no default input and translation braille tables have been set, the default tables will be selected according to NVDA's languages.

Description of development approach

Modified the addTable function in the brailleTables module, to create dictionaries to associate languages with input and translation tables.
Changes should be done in config on this pr.

Testing strategy:

Check that dictionaries with translation and input tables work for Spanish, setting language to es or to Windows (es_ES).

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.

Summary by CodeRabbit

  • New Features

    • Introduced automatic selection of braille tables based on user language settings.
    • Added the ability to exit the initial window using the escape key or alt+f4.
    • Enhanced reporting of font formatting shortcuts in Word and Outlook.
    • Added a VS Code workspace configuration for NVDA.
  • Bug Fixes

    • Improved error messaging for Windows errors during COM re-registrations.
  • Documentation

    • Updated user documentation to reflect changes in braille table settings and new features.
  • Chores

    • Updated coding standards for compatibility with modern linting tools.

@nvdaes nvdaes changed the title Set SetSettab Set default input and translation tables according to NVDA's language Sep 26, 2024
@AppVeyorBot
Copy link

See test results for failed build of commit e673b3dfdb

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Sep 27, 2024

@CyrilleB79 and others, I think that this is ready for a first review. After that, I'll ask on the translators mailing list before requesting a review to NV Access.

@AppVeyorBot
Copy link

See test results for failed build of commit e56f5e5500

Copy link
Collaborator

@LeonarddeR LeonarddeR left a comment

Choose a reason for hiding this comment

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

While I have no time for an in depth review, here are some considerations:

  1. I wouldn't separate languages for input and for translation, only add the ability to provide the tables language. Then, in getDefaultTableForCurLang return the first thable that has that language and has output or input enabled, respectively.
  2. If there is an indention to use liblouis metadata somewhere in the future, It should be considered to retrieve the language from metadata as well.
  3. On a first glance, this pr doesn't deal properly with the input table set to auto, I couldn't faind changes in the brailleInput module. While at it, I'd consider having a getDefaultTableForCurLang function in braille that retrieves only output tables, and a similar function in brailleInput that retrieves input table. That way, the output and input systems are clearly separated.

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Sep 27, 2024

@LeonarddeR , thanks for your review. I guess you are in the right way with your comments.
Anyway, you wrote:

I wouldn't separate languages for input and for translation.

I think that they should be separated, since, for example, the input and translation table from German aren't the same.

On a first glance, this pr doesn't deal properly with the input table set to auto, I couldn't faind changes in the brailleInput module. While at it, I'd consider having a getDefaultTableForCurLang function in braille that retrieves only output tables, and a similar function in brailleInput that retrieves input table. That way, the output and input systems are clearly separated.

Probably I'm missing something here. But in practice, testing changes, when I run NVDA from source without configuring braille tables, in my system, Spanish grade1 is used for input and output.

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Sep 27, 2024

@coderabbitai, can you review this or provide suggestions?

@nvdaes nvdaes marked this pull request as ready for review September 27, 2024 12:18
@nvdaes nvdaes requested a review from a team as a code owner September 27, 2024 12:18
@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Sep 27, 2024

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

Walkthrough

The pull request introduces enhancements to the braille table management in NVDA, including a new enumeration for table types, updated methods for handling language-specific braille tables, and modifications to configuration settings for automatic selection of tables based on the system language. The changes aim to improve user experience by aligning braille table defaults with the user's language settings.

Changes

Files Change Summary
source/brailleTables.py Introduced TableType enumeration, added dictionaries for mapping languages to braille tables, created getDefaultTableForCurLang and getDefaultTableForCurrentLang functions, and updated addTable and listTables methods.
source/config/configSpec.py Updated default values for translationTable and inputTable parameters from a specific file to auto.
user_docs/en/changes.md Documented enhancements including automatic table selection, improved exit options, and coding standards updates.

Assessment against linked issues

Objective Addressed Explanation
Input and output braille table should automatically be the system language (#16390)

Possibly related PRs

Suggested labels

component/liblouis, conceptApproved


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.

Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

Tip

For best results, initiate chat on the files or code changes.

@nvdaes: I've reviewed your changes. Great work on setting the default input and translation braille tables according to NVDA's language.

I noticed a few potential issues with the language codes used in the inputForLangs and translationForLangs parameters in the addTable function calls:

  • In the following line:

    addTable("ka-in-g1.utb", _("Kannada grade 1"), inputForLangs={"ka"}, translationForLangs={"ka"})

    The language code "ka" corresponds to Georgian. The correct ISO 639-1 code for Kannada is "kn". It should be:

    addTable("ka-in-g1.utb", _("Kannada grade 1"), inputForLangs={"kn"}, translationForLangs={"kn"})
  • Similarly, in:

    addTable("km-g1.utb", _("Khmer grade 1"), inputForLangs={"kmr"}, translationForLangs={"kmr"})

    The language code "kmr" corresponds to Northern Kurdish. The correct code for Khmer is "km". It should be:

    addTable("km-g1.utb", _("Khmer grade 1"), inputForLangs={"km"}, translationForLangs={"km"})

I recommend reviewing and updating the language codes to ensure they match the correct ISO codes for the respective languages.

Additionally, in some instances, the Translators comments are included inside the addTable function calls, which might not align with the project's coding standards. It may be better to place these comments outside the function calls to maintain readability and consistency.

Moreover, to enhance maintainability, consider adding unit tests to verify the mappings between languages and braille tables. This can help prevent similar issues in the future.

Let me know if you have any questions or need further assistance.

🔗 Analysis chain
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Fetch the diff of PR #17222
gh pr diff 17222

Length of output: 28876

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (3)
user_docs/en/changes.md (3)

Line range hint 6-10: Consider adding more context to the 2025.1 release notes

The 2025.1 release notes are quite brief compared to other releases. Consider adding more details about the significance of these changes, especially for users who may not be familiar with the technical aspects.


Line range hint 18-22: Consider elaborating on the changes

While the changes are clearly stated, it might be helpful to provide a brief explanation of why these changes were made or how they benefit users.


Line range hint 29-35: Consider adding more context to developer changes

The changes for developers section is quite technical. Consider adding brief explanations of why these changes were made or how they impact development.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1573904 and 8bbb65b.

📒 Files selected for processing (3)
  • source/brailleTables.py (37 hunks)
  • source/config/configSpec.py (1 hunks)
  • user_docs/en/changes.md (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
source/brailleTables.py (2)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious. When providing code suggestions, particularly when requested, ensure GitHub's suggestion format is used, i.e.: suggestion <code changes>


Pattern **/*.py: _, pgettext, ngettext, and ngettext are defined globally, errors for this being undefined can be ignored.

source/config/configSpec.py (2)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious. When providing code suggestions, particularly when requested, ensure GitHub's suggestion format is used, i.e.: suggestion <code changes>


Pattern **/*.py: _, pgettext, ngettext, and ngettext are defined globally, errors for this being undefined can be ignored.

user_docs/en/changes.md (3)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious. When providing code suggestions, particularly when requested, ensure GitHub's suggestion format is used, i.e.: suggestion <code changes>


Pattern **/*.md: Focus on grammar, spelling, and punctuation. Also consider readability and clarity of contents. Ensure that changes follow the style of one sentence per line, suggest changes if this is not met.


Pattern user_docs/en/changes.md: Ensure each change log entry references an issue or pull request number. Change log entries can also include a reference to a GitHub author. Examples of valid change log entries: * Item with sub-items (#123, @username): * sub-item * bar (#342) * Item with. Multiple lines. (#143)

🔇 Additional comments (9)
source/config/configSpec.py (1)

74-75: LGTM! Improved default configuration for braille tables.

The changes to set auto as the default value for both translationTable and inputTable are excellent improvements. They align perfectly with the PR objectives and address the issue of NVDA defaulting to English braille tables regardless of the system language. This modification will significantly enhance the user experience, especially for non-English users and beginners, by automatically selecting appropriate braille tables based on the current language setting of NVDA.

user_docs/en/changes.md (8)

Line range hint 1-4: LGTM: Clear and concise title and introduction

The title "What's New in NVDA" and the brief introduction are clear and appropriate for a changelog document.


Line range hint 12-16: LGTM: Clear and concise new features section

The new features are well-described and easy to understand.


Line range hint 24-27: LGTM: Clear bug fixes section

The bug fixes are well-described and easy to understand.


Line range hint 37-41: LGTM: Informative introduction to 2024.4 release

The introduction provides a good overview of the key features in this release.


Line range hint 43-56: LGTM: Comprehensive new features section

The new features are well-described with good detail. The use of bullet points makes it easy to read.


Line range hint 58-64: LGTM: Clear changes section

The changes are clearly described and easy to understand.


Line range hint 66-84: LGTM: Detailed bug fixes section

The bug fixes are well-described with good technical detail.


Line range hint 86-103: LGTM: Comprehensive developer changes section

The changes for developers are well-documented and provide good technical detail.

source/brailleTables.py Show resolved Hide resolved
source/brailleTables.py Show resolved Hide resolved
source/brailleTables.py Outdated Show resolved Hide resolved
source/brailleTables.py Outdated Show resolved Hide resolved
source/brailleTables.py Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@nvdaes nvdaes marked this pull request as draft September 27, 2024 12:45
@nvdaes nvdaes marked this pull request as ready for review September 28, 2024 03:26
@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Sep 28, 2024

@coderabbitai review

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8bbb65b and 8b2b3f1.

📒 Files selected for processing (1)
  • source/brailleTables.py (37 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
source/brailleTables.py (2)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious. When providing code suggestions, particularly when requested, ensure GitHub's suggestion format is used, i.e.: suggestion <code changes>


Pattern **/*.py: _, pgettext, ngettext, and ngettext are defined globally, errors for this being undefined can be ignored.

📓 Learnings (1)
source/brailleTables.py (2)
Learnt from: nvdaes
PR: nvaccess/nvda#17222
File: source/brailleTables.py:112-113
Timestamp: 2024-09-27T12:32:22.176Z
Learning: The project uses the `set[str] | None` type hint syntax, so it's acceptable to use it even though it requires Python 3.10 or newer.
Learnt from: nvdaes
PR: nvaccess/nvda#17222
File: source/brailleTables.py:33-37
Timestamp: 2024-09-27T12:28:02.907Z
Learning: In this project, `StrEnum` is used; it's acceptable to use `StrEnum` even though it requires Python 3.11.
🔇 Additional comments (9)
source/brailleTables.py (9)

Line range hint 20-37: LGTM: New import and TableType enum look good.

The addition of the languageHandler import and the new TableType enum are well-structured and provide clear categorization for table types. The use of StrEnum is consistent with the project's practices.


80-85: LGTM: New language mapping dictionaries added.

The addition of _inputTableForLangs and _translationTableForLangs dictionaries provides a clear structure for mapping languages to their respective braille table filenames. This change aligns well with the PR's objective of enhancing language-specific braille table management.


115-116: LGTM: New parameters for language-specific table assignment.

The addition of inputForLangs and translationForLangs parameters to the addTable function enhances its flexibility, allowing for language-specific table assignments. The type hint set[str] | None is correctly used and aligns with the project's practices.


126-127: LGTM: Clear documentation for new parameters.

The added documentation for the inputForLangs and translationForLangs parameters is clear and consistent with the existing documentation style. It provides sufficient information for developers using this function.


133-138: LGTM: Efficient implementation of language-specific table assignments.

The new logic for populating the _inputTableForLangs and _translationTableForLangs dictionaries is well-implemented. It efficiently handles both input and translation table assignments for multiple languages.


146-147: LGTM: Proper handling of "auto" table selection.

The addition of logic to handle the "auto" table selection is a good safeguard. It ensures that a default table is used when "auto" is specified, preventing potential errors in table lookup.


864-867: LGTM: Implemented automatic table selection based on current language.

The new logic for setting default input and translation tables based on the current language is well-implemented. It correctly uses the getDefaultTableForCurLang function for both translation and input tables, fulfilling the main objective of the PR to enhance language-specific braille table selection.


Line range hint 1-867: Overall assessment: Well-implemented enhancements to braille table management.

The changes in this file successfully implement the objectives of the PR, enhancing language-specific braille table management. The code is well-structured, consistent with existing patterns, and introduces clear improvements in functionality. A few minor points were raised for improvement, but overall, the implementation is solid and achieves its goals.

Key improvements:

  1. Introduction of TableType enum for clear categorization.
  2. New dictionaries for mapping languages to table filenames.
  3. Implementation of getDefaultTableForCurLang function.
  4. Enhanced addTable function with language-specific assignments.
  5. Comprehensive updates to table assignments for various languages.
  6. Automatic table selection based on the current language.

These changes should significantly improve the user experience for non-English NVDA users by providing more accurate and language-specific braille table selections.


197-197: LGTM: Comprehensive update of language-specific table assignments.

The updates to multiple addTable calls with the new inputForLangs and translationForLangs parameters are consistent and align well with the PR objectives. The changes cover a wide range of languages and seem to improve language-specific table selection.

To ensure the accuracy of these assignments, please run the following verification script:

This script will help identify any potential inconsistencies in language code usage and provide a list of all used language codes for manual review.

Also applies to: 212-212, 218-218, 239-239, 242-242, 245-245, 263-263, 273-273, 311-311, 315-315, 325-325, 364-364, 373-373, 379-379, 382-382, 405-405, 411-411, 426-426, 432-432, 438-438, 444-444, 450-450, 476-476, 485-485, 497-497, 515-515, 530-530, 539-539, 545-545, 557-557, 566-566, 590-590, 599-599, 608-608, 629-629, 635-635, 651-651, 683-683, 698-698, 701-701, 716-716, 725-725, 737-737, 746-746, 762-770, 775-784, 794-794

✅ Verification successful

Next Steps: Correcting the Shell Script for Verification

The previous verification script failed due to an unrecognized file type. Let's update the rg command to use the correct file type for Python.

Please run the following updated verification script:

This updated script uses the correct --type py for Python files, which should resolve the previous error and allow for proper verification of the language code assignments.


Action Required: Refine the Verification Script to Exclude Irrelevant Lines

The previous script included unintended entries due to lines not matching the expected pattern. Let's refine the script to ensure only relevant lines are processed.

Please run the following updated verification script:

Changes Made:

  • Added grep 'Langs={' to filter only lines containing the Langs parameter.
  • Updated the sed command to accurately capture content within Langs={...} by using ([^}]+) instead of (.+) to prevent overmatching.

This should eliminate the unintended source/brailleTables.py- entries and provide a clean list of language codes for verification.


Action Required: Update the Verification Script to Target Correct Language Parameters

The previous script incorrectly targeted Langs={ instead of the actual parameters inputForLangs={ and translationForLangs={. This caused unintended lines to be processed. Let's refine the script to accurately extract the language codes.

Please run the following updated verification script:

Changes Made:

  • Grep Pattern: Updated to search specifically for inputForLangs={ and translationForLangs={.
  • Separate Extraction: Handled inputForLangs and translationForLangs separately to ensure accurate parsing.
  • Output Clarity: Added separate sections in the output for inputForLangs and translationForLangs for better manual review.

This refined script should accurately extract and list all language codes used in the addTable calls without capturing unrelated lines.


Verification Successful: Language Code Assignments are Consistent

All addTable calls have been verified for consistency in their inputForLangs and translationForLangs parameters. No inconsistencies or unintended entries were found, and all language codes are correctly assigned as per the PR objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of language codes used in addTable calls

# Test: Check for any inconsistencies in language codes
rg --type python 'addTable\(' -A 10 | grep -E 'inputForLangs|translationForLangs' | \
  sed -E 's/.*Langs=\{(.+)\}.*/\1/' | tr ',' '\n' | sort | uniq -c | \
  awk '$1 == 1 {print "Unique language code:", $2}'

# Test: List all used language codes for manual review
echo "All used language codes:"
rg --type python 'addTable\(' -A 10 | grep -E 'inputForLangs|translationForLangs' | \
  sed -E 's/.*Langs=\{(.+)\}.*/\1/' | tr ',' '\n' | sort | uniq

Length of output: 467


Script:

# 
#!/bin/bash
# Description: Verify the consistency of language codes used in addTable calls

# Test: Check for any inconsistencies in language codes
rg --type py 'addTable\(' -A 10 | grep -E 'inputForLangs|translationForLangs' | \
  sed -E 's/.*Langs=\{(.+)\}.*/\1/' | tr ',' '\n' | sort | uniq -c | \
  awk '$1 == 1 {print "Unique language code:", $2}'

# Test: List all used language codes for manual review
echo "All used language codes:"
rg --type py 'addTable\(' -A 10 | grep -E 'inputForLangs|translationForLangs' | \
  sed -E 's/.*Langs=\{(.+)\}.*/\1/' | tr ',' '\n' | sort | uniq

Length of output: 2087


Script:

# 
#!/bin/bash
# Description: Verify the consistency of language codes used in addTable calls

# Test: Check for any inconsistencies in language codes
rg --type py 'addTable\(' -A 10 | grep -E 'inputForLangs|translationForLangs' | \
  grep 'Langs={' | sed -E 's/.*Langs=\{([^}]+)\}.*/\1/' | tr ',' '\n' | sort | uniq -c | \
  awk '$1 == 1 {print "Unique language code:", $2}'

# Test: List all used language codes for manual review
echo "All used language codes:"
rg --type py 'addTable\(' -A 10 | grep -E 'inputForLangs|translationForLangs' | \
  grep 'Langs={' | sed -E 's/.*Langs=\{([^}]+)\}.*/\1/' | tr ',' '\n' | sort | uniq

Length of output: 1900


Script:

# 
#!/bin/bash
# Description: Verify the consistency of language codes used in addTable calls

# Test: Check for any inconsistencies in language codes
rg --type py 'addTable\(' -A 10 | grep -E 'inputForLangs=\{' | \
  sed -E 's/.*inputForLangs=\{([^}]+)\}.*/\1/' | tr ',' '\n' | sort | uniq -c | \
  awk '$1 == 1 {print "Unique language code:", $2}'

rg --type py 'addTable\(' -A 10 | grep -E 'translationForLangs=\{' | \
  sed -E 's/.*translationForLangs=\{([^}]+)\}.*/\1/' | tr ',' '\n' | sort | uniq -c | \
  awk '$1 == 1 {print "Unique language code:", $2}'

# Test: List all used language codes for manual review
echo "All used language codes from inputForLangs:"
rg --type py 'addTable\(' -A 10 | grep -E 'inputForLangs=\{' | \
  sed -E 's/.*inputForLangs=\{([^}]+)\}.*/\1/' | tr ',' '\n' | sort | uniq

echo "All used language codes from translationForLangs:"
rg --type py 'addTable\(' -A 10 | grep -E 'translationForLangs=\{' | \
  sed -E 's/.*translationForLangs=\{([^}]+)\}.*/\1/' | tr ',' '\n' | sort | uniq

Length of output: 3951

source/brailleTables.py Outdated Show resolved Hide resolved
@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Sep 28, 2024

@coderabbitai review

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Sep 28, 2024

@coderabbitai resolve

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
source/brailleTables.py (3)

87-104: LGTM: Well-structured getDefaultTableForCurLang function.

The getDefaultTableForCurLang function is well-implemented, handling different table types and providing appropriate language fallback mechanisms. The error handling for unknown table types is a good practice.

Consider adding a docstring to explain the fallback behavior and the default "en-ueb-g1.ctb" table.


145-146: LGTM: Default table handling for "auto" selection.

The addition of a default table ("en-ueb-g1.ctb") when "auto" is specified ensures that a valid table is always returned, preventing potential errors.

Consider adding a comment explaining why "en-ueb-g1.ctb" was chosen as the default table for better maintainability.


761-769: LGTM: Chinese braille table assignments look good.

The addTable calls for Chinese braille tables are correctly updated with language-specific parameters, properly associating different Chinese variants with their respective language codes. The implementation is consistent with other language-specific table assignments.

Consider adding a comment explaining the differences between the Chinese variants and their corresponding language codes for better maintainability.

Also applies to: 775-783, 793-793

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8b2b3f1 and 23856c2.

📒 Files selected for processing (1)
  • source/brailleTables.py (37 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
source/brailleTables.py (2)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious. When providing code suggestions, particularly when requested, ensure GitHub's suggestion format is used, i.e.: suggestion <code changes>


Pattern **/*.py: _, pgettext, ngettext, and ngettext are defined globally, errors for this being undefined can be ignored.

📓 Learnings (1)
source/brailleTables.py (2)
Learnt from: nvdaes
PR: nvaccess/nvda#17222
File: source/brailleTables.py:112-113
Timestamp: 2024-09-27T12:32:22.176Z
Learning: The project uses the `set[str] | None` type hint syntax, so it's acceptable to use it even though it requires Python 3.10 or newer.
Learnt from: nvdaes
PR: nvaccess/nvda#17222
File: source/brailleTables.py:33-37
Timestamp: 2024-09-27T12:28:02.907Z
Learning: In this project, `StrEnum` is used; it's acceptable to use `StrEnum` even though it requires Python 3.11.
🔇 Additional comments (8)
source/brailleTables.py (8)

Line range hint 20-37: LGTM: New import and TableType enum look good.

The addition of the languageHandler import and the TableType enum are well-structured and provide clear distinctions between input and translation table types. The use of StrEnum is appropriate for this project.


80-84: LGTM: New dictionaries for language-specific tables.

The addition of _inputTableForLangs and _translationTableForLangs dictionaries provides a clear structure for mapping languages to their respective input and translation braille tables. The naming convention is consistent and self-explanatory.


114-115: LGTM: New parameters for language-specific table assignment.

The addition of inputForLangs and translationForLangs parameters to the addTable function allows for more granular control over which tables are used for specific languages. The type hint set[str] | None is appropriate and consistent with the project's conventions.

Also applies to: 125-126


132-137: LGTM: Proper population of language-specific table dictionaries.

The new logic correctly populates the _inputTableForLangs and _translationTableForLangs dictionaries with the table's filename for each specified language. This implementation enables efficient lookup of language-specific tables.


388-395: LGTM: French braille table assignment is correct.

The addTable call for the French braille table is correctly updated with inputForLangs and translationForLangs parameters. This change is consistent with other language-specific table assignments and ensures proper association of the French language with its corresponding braille table.


453-460: LGTM: Comprehensive language-specific table assignments.

The updates to multiple addTable calls with language-specific parameters are consistent and comprehensive. The changes appropriately associate various languages with their corresponding braille tables for both input and translation purposes.

To ensure consistency in language assignments, run the following script:

#!/bin/bash
# Description: Verify consistency in language assignments

# Test: Check for languages with only input or only translation assignments
echo "Languages with only input assignment:"
rg --type python -o '(?<=inputForLangs=\{")([^"}]+)' | sort > input_langs.txt
rg --type python -o '(?<=translationForLangs=\{")([^"}]+)' | sort > translation_langs.txt
comm -23 input_langs.txt translation_langs.txt

echo "Languages with only translation assignment:"
comm -13 input_langs.txt translation_langs.txt

# Clean up temporary files
rm input_langs.txt translation_langs.txt

Also applies to: 464-472, 475-475, 484-484, 496-496, 529-529, 538-538, 544-544, 556-556, 565-565, 589-589, 598-598, 607-607, 628-628, 634-634, 650-650, 682-682, 697-697, 700-700, 715-715, 724-724, 736-736, 745-745


863-866: LGTM: Proper initialization of default tables.

The updates to the initialize function correctly use the new getDefaultTableForCurLang function to set appropriate defaults for input and translation tables. This ensures that language-specific tables are used when "auto" is specified in the configuration.

To ensure the default table selection works as expected, run the following script:

#!/bin/bash
# Description: Verify default table selection for different languages

# Test: Simulate default table selection for various languages
echo "Simulating default table selection:"
for lang in en fr de es zh_CN ja; do
  echo "Language: $lang"
  rg --type python -A 10 "def getDefaultTableForCurLang" | sed "s/languageHandler.getLanguage()/'$lang'/" | python3 -c "
import sys
exec(sys.stdin.read())
print(f'Input table: {getDefaultTableForCurLang(TableType.INPUT)}')
print(f'Translation table: {getDefaultTableForCurLang(TableType.TRANSLATION)}')
"
  echo
done

196-196: LGTM: Language-specific table assignments look good.

The updates to addTable calls with inputForLangs and translationForLangs parameters correctly associate specific languages with their corresponding braille tables. The implementation is consistent across different languages.

To ensure all language codes are correct, run the following script:

Also applies to: 211-211, 217-217, 238-238, 241-241, 244-244, 262-262, 272-272, 310-310, 314-314, 324-324, 363-363, 372-372, 378-378, 381-381

@nvdaes nvdaes marked this pull request as draft September 28, 2024 03:43
@AppVeyorBot
Copy link

  • PASS: Translation comments check.
  • PASS: License check.
  • PASS: Unit tests.
  • PASS: Lint check.
  • Build execution time has reached the maximum allowed time for your plan (60 minutes).

See test results for failed build of commit c889661e71

@AppVeyorBot
Copy link

See test results for failed build of commit 110fa27bc6

user_docs/en/changes.md Outdated Show resolved Hide resolved
Co-authored-by: Cyrille Bougot <[email protected]>
@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Sep 30, 2024

Thanks for your review, @CyrilleB79 .

@CyrilleB79
Copy link
Collaborator

I have made a quick poll on the French mailing list.

100% of answerers use "French (unified) 8 dot computer braille". So I'd recommend to use it for French.

Also, an answerer has added the following valuable piece of information:

JAWS, Voiceover on mac iphone and iPad are by default with the 8-dot computer table.

If it's the same for all languages, it would be worth using 8-dot computer braille for all languages by default.

I am not for copying all what all other screen readers do without thinking. But here, if Jaws and VO have already default and if complain have been heard, I think that we'd better use the same defaults, unless our community says otherwise (if possible with a reason).

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Sep 30, 2024

I'll create surveys on Google forms in English and Spanish. I'll provide both links here, on the translations mailing list, on the international users mailing lists and on various mailing lists for spanish speakers.

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Sep 30, 2024

Finally, I think that a Google form with a survey for all languages is not practical, so I've just created a form for my language (Spanish).
I'll ask on the users mailing list.
In case, the form in Spanish is available at

https://docs.google.com/forms/d/e/1FAIpQLSdJoUBaOHNkW1fpsMsMBlUlcrbxw1orWDq0u2EvvUu0I6NUng/viewform?usp=sf_link

@nvdaes
Copy link
Sponsor Contributor Author

nvdaes commented Sep 30, 2024

@CyrilleB79 , I've changed tables for French. Please see commit bfa1974

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.
Projects
None yet
5 participants