Skip to content

More robust detection of language code with no description#15031

Merged
seanbudd merged 7 commits into
nvaccess:masterfrom
CyrilleB79:unknownLang
Jun 30, 2023
Merged

More robust detection of language code with no description#15031
seanbudd merged 7 commits into
nvaccess:masterfrom
CyrilleB79:unknownLang

Conversation

@CyrilleB79

@CyrilleB79 CyrilleB79 commented Jun 19, 2023

Copy link
Copy Markdown
Contributor

Link to issue number:

Closes #15017 (work-around)

Summary of the issue:

On a specific system (see #15017), Windows cannot get the language name from LCID. This cause an uncaught error preventing the OCR settings panel to be fully created (and the previous panel to be cleared).

Description of user facing changes

Displaying the OCR settings will not fail anymore on some systems where it is not possible to derive the language name from LCID.

Description of development approach

When listing OCR languages, we use languageHandler.getLanguageDescription to determine the name given the language code. However this function may return None in case it cannot find a language name.
This return value had not been taken into account when listing the OCR languages.

Thus this PR allows to add the language code instead of is name in the OCR list as a fallback if the name cannot be found.

A debugWarning is logged in the function languageHandler.getLanguageDescription if the language cannot be found; note that this function is used in some add-ons.

In the settings panel instead, I log an error so that the situations with unknown languages can be captured more easily.

Testing strategy:

  • Modified the code manually to add an unknown language code in the list of language codes and checked that it is listed as a language code in the combo box of the OCR settings panel; also checked the logged debugWarning and error messages.
  • Ask to @cary-rowen or @hwf1324 to test this PR on the system where the error was found and check that GUI issues of Loading Windows OCR settings panel results in cluttered UI #15017 do not occur anymore.

Known issues with pull request:

This PR fixes the GUI issue but do not convert the language code to a valid language name.

The issue described in #15017 seems to occur only on a specific system running a Windows version that is not supported anymore (Windows 10 1809). Moreover the user will not have access to this system in the future. Thus I prefer not to modify our language normalization or conversion functions since I am not confident on how these modifications would impact other systems.

An error is logged for language codes that cannot be converted to full language names; so if other people face this issue we will have the information in the log (and in the GUI featuring language code instead of name). We may think to a fix if this impact many people on up-to-date systems.

Change log entries:

Bug fixes
Displaying the OCR settings will not fail on some systems anymore. (#15017)

Code Review Checklist:

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

@CyrilleB79 CyrilleB79 marked this pull request as ready for review June 29, 2023 12:33
@CyrilleB79 CyrilleB79 requested a review from a team as a code owner June 29, 2023 12:33
@CyrilleB79 CyrilleB79 requested a review from seanbudd June 29, 2023 12:33

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks @CyrilleB79

Comment thread source/languageHandler.py Outdated
@seanbudd seanbudd merged commit 8accbfa into nvaccess:master Jun 30, 2023
@nvaccessAuto nvaccessAuto added this to the 2023.2 milestone Jun 30, 2023
@CyrilleB79 CyrilleB79 deleted the unknownLang branch June 30, 2023 13:45
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.

Loading Windows OCR settings panel results in cluttered UI

3 participants