Skip to content

languageHandler.getAvailableLanguages: use globalVars.appDir rather than depending on the current directory - #11778

Merged
michaelDCurran merged 3 commits into
masterfrom
moreCwdFixes
Oct 21, 2020
Merged

languageHandler.getAvailableLanguages: use globalVars.appDir rather than depending on the current directory #11778
michaelDCurran merged 3 commits into
masterfrom
moreCwdFixes

Conversation

@michaelDCurran

Copy link
Copy Markdown
Member

Link to issue number:

Following on from pr #11650

Summary of the issue:

Pr #11650 aimed to remove all dependence on the current directory being set to NVDA's application directory.
However, another place where we depend on the current directory has been identified:
languageHandler.getAvailableLanguages assumes the 'locale' directory is in the current directory. This should be changed to use globalVars.appDir.
If the current directory is changed to something else, such as when running SAPI5 voices from harposoftware, it is impossible to open the NVDA settings dialog set to the General settings panel as it cannot populate the languages dropdown list. And once this fails, it is then impossible to open Settings ever again until restarting NVDA, as it thinks that the settings dialog is still open.

Description of how this pull request fixes the issue:

Changed languageHandler.getAvailableLanguages to use globalVars.appDir rather than the current directory when listing locales.

Testing performed:

Ran NvDA with the Ivona voice from Harposoftware, and opened the NVDA settings dialog set to the General settings panel by pressing NvDA+control+g. The panel correctly opens and the language list is populated.

Known issues with pull request:

None.

Change log entry:

None needed.

…han relying on the current working directory.
@michaelDCurran michaelDCurran changed the title languageHandler.getAvailableLanguages: use globalVars.appDir rather t… languageHandler.getAvailableLanguages: use globalVars.appDir rather than depending on the current directory Oct 21, 2020
feerrenrut
feerrenrut previously approved these changes Oct 21, 2020

@feerrenrut feerrenrut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Couple of minor things, but doesn't require a second a review.

Comment thread source/languageHandler.py Outdated
locales = [
x for x in os.listdir(localesDir) if (
not x.startswith('.')
and os.path.isfile(os.path.join(localesDir, x, 'lc_messages', 'nvda.mo'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note, that "lc_messages" was previously capitalized. Not that this really matters on Windows, but it doesn't hurt to be consistent with what is actually there.

Comment thread source/languageHandler.py Outdated
localesDir = os.path.join(globalVars.appDir, 'locale')
locales = [
x for x in os.listdir(localesDir) if (
not x.startswith('.')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any idea why this is here? So languages can be disabled? Or because there may have been "dot files" in this directory?

If you know a comment would be good.

@michaelDCurran

michaelDCurran commented Oct 21, 2020 via email

Copy link
Copy Markdown
Member Author

@michaelDCurran
michaelDCurran merged commit 111a0f0 into master Oct 21, 2020
@michaelDCurran
michaelDCurran deleted the moreCwdFixes branch October 21, 2020 22:54
@nvaccessAuto nvaccessAuto added this to the 2020.4 milestone Oct 21, 2020
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