-
-
Notifications
You must be signed in to change notification settings - Fork 659
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
Report the language switched to #17685
base: master
Are you sure you want to change the base?
Conversation
source/globalCommands.py
Outdated
text = info.text | ||
repeats = scriptHandler.getLastScriptRepeatCount() | ||
if repeats == 0: | ||
ui.message(languageHandler.getLanguageDescription(curLanguage)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please handle the case where the language is not recognized. I.e. report something like f"Unknown language ({languageCode})"
or just f"{languageCode}"
.
source/speech/speech.py
Outdated
speechSequence.insert(1, languageHandler.getLanguageDescription(curLanguage)) | ||
SpeechState.lastReportedLanguage = curLanguage | ||
if not languageIsSupported(curLanguage): | ||
log.warn(f"{curLanguage} not supported in {getSynth().name}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that log.warn
is usually not used in NVDA's code base. Any specific reason to use it?
We usually have log.warning
(used even at info level), and log .debugWarning
, used at the same log level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a mistake from my side. My intention was to use log.debugWarning
if language is None: | ||
return True | ||
for lang in getSynth().availableLanguages: | ||
if language == lang or language == languageHandler.normalizeLanguage(lang).split("_")[0]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this piece of code depend on the "Automatic dialect switching (when supported)" option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better that this doesn't deppend on the automatic dialect switching option, since we can imagine a synthesizer with languages just in the form of dialects. Anyway I'm open to change my opinion.
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
Seems that, when pressing c to go to the combo box in the old add-ons website, the preferences word is in English but, if it's not spoken, the lastReportedLanguage is set to English, and this causes that the language of the word English in the combo box is not reported. I don't know if this may be fixed with the pre_speech extension point in some way. |
@nvdaes, regarding language translations I guess it would be interesting to list all the specific / corner cases. Then you will be able to determine if they should be handled separately or if they can be ignored. For example I have the following questions:
|
@CyrilleB79 , should the corner cases be addressed in languageHandler.getLanguageDescription? |
Maybe not; just mentioning in case everyone is aware of it so to decide what to do (accept as is or fix). |
Let's way for comments on this about corner cases, to see how to document it, or if saying that the language description would be reported is enough. |
I think that the experience when using this feature with quick navigation or moving the focus with tab is not good, when the language description is reported, then for example the text of a heading and a link, and then the link state like "visited link". In this case "visited link" is pronnounced with a bad entonation, tested with eSpeak-NG. And also, listening the language description for each element, since "visited link" is pronnounced in the default language, is too much. |
Now for me the user experience is acceptable, not perfect, since in say all NVDA can report the language for new paragraphs. See [In-Process 7th February 2025](https://www.nvaccess.org/post/in-process-7th-february-2025/ Copy control+shift+cClose). |
Link to issue number:
#17664
Summary of the issue:
Users may want to know the current language when the language detection is enabled.
Description of user facing changes
Description of development approach
In
speech.speech.py
, alastReportedLanguage
member has been added to theSpeechState
dataclass.In the
speak
function, the language description is inserted in the speechSequence when appropriate.In
speech.speech.py
, alanguageIsSupported
function has been added. It accept alanguage
parameter to check if it's available in the current synthesizer.In
globalCommands.py
, a script has been added to report the language of the carácter at caret.This is an API break change since the
speak
function is changed.Testing strategy:
Tested manually in webpages like addons.nvda-project.org, and navigating to nvda.fr, DuckDuckGo, etc, and in VS Code and other places of Windows.
Known issues with pull request:
This needs to be more tested to know if it Works appropriately. In say all, NVDA can report the language when a new paragraph starts.
Code Review Checklist:
@coderabbitai summary