Skip to content

Commit 4a72f93

Browse files
authored
Merge 0d08a08 into 8d6a860
2 parents 8d6a860 + 0d08a08 commit 4a72f93

6 files changed

Lines changed: 48 additions & 22 deletions

File tree

source/braille.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,18 +3132,19 @@ def handlePostConfigProfileSwitch(self):
31323132

31333133
if (configuredTether := config.conf["braille"]["tetherTo"]) != TetherTo.AUTO.value:
31343134
self._tether = configuredTether
3135-
if config.conf["braille"]["translationTable"] == "auto":
3136-
config.conf["braille"]["translationTable"] = brailleTables.getDefaultTableForCurLang(
3137-
brailleTables.TableType.OUTPUT,
3138-
)
3135+
31393136
tableName = config.conf["braille"]["translationTable"]
31403137
# #6140: Migrate to new table names as smoothly as possible.
31413138
newTableName = brailleTables.RENAMED_TABLES.get(tableName)
31423139
if newTableName:
31433140
tableName = config.conf["braille"]["translationTable"] = newTableName
3141+
if config.conf["braille"]["translationTable"] == "auto":
3142+
table = brailleTables.getDefaultTableForCurLang(brailleTables.TableType.OUTPUT)
3143+
else:
3144+
table = tableName
31443145
if tableName != self._table.fileName:
31453146
try:
3146-
self._table = brailleTables.getTable(tableName)
3147+
self._table = brailleTables.getTable(table)
31473148
except LookupError:
31483149
log.error(
31493150
f"Invalid translation table ({tableName}), "

source/brailleInput.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,19 +451,20 @@ def handleCaretMove(self, obj):
451451
self.flushBuffer()
452452

453453
def handlePostConfigProfileSwitch(self):
454-
if config.conf["braille"]["inputTable"] == "auto":
455-
config.conf["braille"]["inputTable"] = brailleTables.getDefaultTableForCurLang(
456-
brailleTables.TableType.INPUT,
457-
)
458454
# #6140: Migrate to new table names as smoothly as possible.
459455
tableName = config.conf["braille"]["inputTable"]
460456
newTableName = brailleTables.RENAMED_TABLES.get(tableName)
461457
if newTableName:
462458
tableName = config.conf["braille"]["inputTable"] = newTableName
463-
table = config.conf["braille"]["inputTable"]
459+
if config.conf["braille"]["inputTable"] == "auto":
460+
tableName = brailleTables.getDefaultTableForCurLang(
461+
brailleTables.TableType.INPUT,
462+
)
463+
else:
464+
table = config.conf["braille"]["inputTable"]
464465
if table != self._table.fileName:
465466
try:
466-
self._table = brailleTables.getTable(tableName)
467+
self._table = brailleTables.getTable(table)
467468
except LookupError:
468469
log.error(
469470
f"Invalid input table ({tableName}), " f"falling back to default ({FALLBACK_TABLE}).",

source/brailleTables.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,8 +897,6 @@ def initialize():
897897
"Error while applying custom braille tables config from scratchpad manifest: "
898898
f"{manifestPath}",
899899
)
900-
if config.conf["braille"]["translationTable"] == "auto":
901-
config.conf["braille"]["translationTable"] = getDefaultTableForCurLang(TableType.OUTPUT)
902900

903901

904902
def terminate():

source/gui/settingsDialogs.py

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4388,11 +4388,20 @@ def makeSettings(self, settingsSizer):
43884388
outputsLabelText = _("&Output table:")
43894389
self.outTables = [table for table in tables if table.output]
43904390
self.outTableNames = [table.fileName for table in self.outTables]
4391-
outTableChoices = [table.displayName for table in self.outTables]
4391+
outTableForCurLangIndex = self.outTableNames.index(
4392+
brailleTables.getDefaultTableForCurLang(brailleTables.TableType.OUTPUT),
4393+
)
4394+
self.outTableForCurLang = self.outTables[outTableForCurLangIndex]
4395+
# Translators: An option in Braille settings to select a braille table automatically, according to the current language.
4396+
outTableChoices = [_("Automatic ({name})").format(name=self.outTableForCurLang.displayName]
4397+
outTableChoices.extend([table.displayName for table in self.outTables])
43924398
self.outTableList = sHelper.addLabeledControl(outputsLabelText, wx.Choice, choices=outTableChoices)
43934399
self.bindHelpEvent("BrailleSettingsOutputTable", self.outTableList)
43944400
try:
4395-
selection = self.outTables.index(braille.handler.table)
4401+
if config.conf["braille"]["translationTable"] == "auto":
4402+
selection = 0
4403+
else:
4404+
selection = self.outTables.index(braille.handler.table) + 1
43964405
self.outTableList.SetSelection(selection)
43974406
except: # noqa: E722
43984407
log.exception()
@@ -4405,11 +4414,21 @@ def makeSettings(self, settingsSizer):
44054414
# Translators: The label for a setting in braille settings to select the input table (the braille table used to type braille characters on a braille keyboard).
44064415
inputLabelText = _("&Input table:")
44074416
self.inTables = [table for table in tables if table.input]
4408-
inTableChoices = [table.displayName for table in self.inTables]
4417+
self.inTableNames = [table.fileName for table in self.inTables]
4418+
inTableForCurLangIndex = self.inTableNames.index(
4419+
brailleTables.getDefaultTableForCurLang(brailleTables.TableType.INPUT),
4420+
)
4421+
self.inTableForCurLang = self.inTables[inTableForCurLangIndex]
4422+
# Translators: An option in Braille settings to select a braille table automatically, according to the current language.
4423+
inTableChoices = [_("Automatic (%s)" % self.inTableForCurLang.displayName)]
4424+
inTableChoices.extend([table.displayName for table in self.inTables])
44094425
self.inTableList = sHelper.addLabeledControl(inputLabelText, wx.Choice, choices=inTableChoices)
44104426
self.bindHelpEvent("BrailleSettingsInputTable", self.inTableList)
44114427
try:
4412-
selection = self.inTables.index(brailleInput.handler.table)
4428+
if config.conf["braille"]["inputTable"] == "auto":
4429+
selection = 0
4430+
else:
4431+
selection = self.inTables.index(brailleInput.handler.table) + 1
44134432
self.inTableList.SetSelection(selection)
44144433
except: # noqa: E722
44154434
log.exception()
@@ -4714,13 +4733,19 @@ def makeSettings(self, settingsSizer):
47144733

47154734
def onSave(self):
47164735
AutoSettingsMixin.onSave(self)
4717-
4718-
braille.handler.table = self.outTables[self.outTableList.GetSelection()]
4719-
brailleInput.handler.table = self.inTables[self.inTableList.GetSelection()]
4736+
if self.outTableList.GetSelection() > 0:
4737+
braille.handler.table = self.outTables[self.outTableList.GetSelection() - 1]
4738+
else:
4739+
braille.handler.table = self.outTableForCurLang
4740+
config.conf["braille"]["translationTable"] = "auto"
4741+
if self.inTableList.GetSelection():
4742+
brailleInput.handler.table = self.inTables[self.inTableList.GetSelection() - 1]
4743+
else:
4744+
brailleInput.handler.table = self.inTableForCurLang
4745+
config.conf["braille"]["inputTable"] = "auto"
47204746
mode = list(braille.BrailleMode)[self.brailleModes.GetSelection()]
47214747
config.conf["braille"]["mode"] = mode.value
47224748
braille.handler.mainBuffer.clear()
4723-
config.conf["braille"]["translationTable"] = self.outTableNames[self.outTableList.GetSelection()]
47244749
config.conf["braille"]["expandAtCursor"] = self.expandAtCursorCheckBox.GetValue()
47254750
config.conf["braille"]["showCursor"] = self.showCursorCheckBox.GetValue()
47264751
config.conf["braille"]["cursorBlink"] = self.cursorBlinkCheckBox.GetValue()

user_docs/en/changes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ To use this feature, "allow NVDA to control the volume of other applications" mu
3434
* The initial window can now be exited with `escape` or `alt+f4`. (#10799)
3535
* It will now show a message to the user, including the error, in the rare event of a Windows error while attempting COM re-registrations.
3636
* In Word and Outlook the result of more font formatting shortcuts is now reported. (#10271, @CyrilleB79)
37-
* Default input and output braille tables will now be determined based on the NVDA language. (#16390, #290, @nvdaes)
37+
* Default input and output braille tables can now be determined based on the NVDA language. (##17306, #16390, #290, @nvdaes)
3838

3939
### Bug Fixes
4040

user_docs/en/userGuide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,6 +2076,7 @@ The next option you will come to in this category is the braille output table co
20762076
In this combo box, you will find braille tables for different languages, braille standards and grades.
20772077
The chosen table will be used to translate text into braille to be presented on your braille display.
20782078
You can move from braille table to braille table in the list by using the arrow keys.
2079+
If you select "Automatic", the table will be selected according with NVDA's current language.
20792080

20802081
##### Input Table {#BrailleSettingsInputTable}
20812082

0 commit comments

Comments
 (0)