diff --git a/source/brailleTables.py b/source/brailleTables.py index 834377a003..95e159e2dd 100644 --- a/source/brailleTables.py +++ b/source/brailleTables.py @@ -17,6 +17,7 @@ import config import globalVars from logHandler import log +import languageHandler TABLES_DIR = os.path.join(globalVars.appDir, "louis", "tables") """The directory in which liblouis braille tables are located.""" @@ -29,6 +30,13 @@ class TableSource(StrEnum): """The name of the scratchpad table source""" +class TableType(StrEnum): + INPUT = "input" + """The name of the input type for braille tables""" + TRANSLATION = "translation" + """The name of the translation type for braille tables""" + + _tablesDirs = collections.ChainMap( { TableSource.BUILTIN: TABLES_DIR, @@ -69,6 +77,32 @@ class BrailleTable(NamedTuple): and cleared when calling L{terminate}. """ +_inputTableForLangs = dict() +"""Maps languages to input L{BrailleTable.fileName}.""" + +_translationTableForLangs = dict() +"""Maps languages to translation L{BrailleTable.fileName}.""" + + +def getDefaultTableForCurLang(tableType: TableType) -> str: + """Gets the file name of the braille table for the current NVDA language. + :param tableType: input or translation. + :return: A L{BrailleTable} fileName. + """ + if tableType == TableType.INPUT: + langDict = _inputTableForLangs + elif tableType == TableType.TRANSLATION: + langDict = _translationTableForLangs + else: + raise ValueError(f"Unknown tableType: {tableType}") + lang = languageHandler.getLanguage() + table = langDict.get(lang) + if table is not None: + return table + if "_" in lang: + lang = lang.split("_")[0] + return langDict.get(lang, "en-ueb-g1.ctb") + def addTable( fileName: str, @@ -77,6 +111,8 @@ def addTable( output: bool = True, input: bool = True, source: str = TableSource.BUILTIN, + inputForLangs: set[str] | None = None, + translationForLangs: set[str] | None = None, ): """Register a braille translation table. At least one of C{input} or C{output} must be C{True}. @@ -86,11 +122,19 @@ def addTable( :param output: True if this table can be used for output, False if not. :param input: True if this table can be used for input, False if not. :param source: An identifier describing the source of the table. + :param inputForLangs: A set of languages available in NVDA or C{None}. + :param translationForLangs: A set of languages available in NVDA or C{None}. """ if not output and not input: raise ValueError("input and output cannot both be False") table = BrailleTable(fileName, displayName, contracted, output, input, source) _tables[fileName] = table + if inputForLangs is not None: + for lang in inputForLangs: + _inputTableForLangs[lang] = table.fileName + if translationForLangs is not None: + for lang in translationForLangs: + _translationTableForLangs[lang] = table.fileName def getTable(fileName: str) -> BrailleTable: @@ -98,6 +142,8 @@ def getTable(fileName: str) -> BrailleTable: @return: The table information. @raise LookupError: If there is no table registered with this file name. """ + if fileName == "auto": + fileName = "en-ueb-g1.ctb" return _tables[fileName] @@ -147,7 +193,7 @@ def listTables() -> list[BrailleTable]: # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("afr-za-g1.ctb", _("Afrikaans grade 1")) +addTable("afr-za-g1.ctb", _("Afrikaans grade 1"), inputForLangs={"af_ZA"}, translationForLangs={"af_ZA"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("afr-za-g2.ctb", _("Afrikaans grade 2"), contracted=True) @@ -162,13 +208,13 @@ def listTables() -> list[BrailleTable]: addTable("ar-ar-comp8.utb", _("Arabic 8 dot computer braille")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("ar-ar-g1.utb", _("Arabic grade 1")) +addTable("ar-ar-g1.utb", _("Arabic grade 1"), inputForLangs={"ar"}, translationForLangs={"ar"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("ar-ar-g2.ctb", _("Arabic grade 2"), contracted=True) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("as-in-g1.utb", _("Assamese grade 1")) +addTable("as-in-g1.utb", _("Assamese grade 1"), inputForLangs={"as"}, translationForLangs={"as"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("ba.utb", _("Bashkir grade 1"), input=False) @@ -186,16 +232,16 @@ def listTables() -> list[BrailleTable]: addTable("bel-detailed.utb", _("Belarusian literary braille (detailed)")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("bg.ctb", _("Bulgarian 8 dot computer braille")) +addTable("bg.ctb", _("Bulgarian 8 dot computer braille"), inputForLangs={"bg"}) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("bg.utb", _("Bulgarian grade 1")) +addTable("bg.utb", _("Bulgarian grade 1"), translationForLangs={"bg"}) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("ca-g1.ctb", _("Catalan grade 1")) +addTable("ca-g1.ctb", _("Catalan grade 1"), inputForLangs={"ca"}, translationForLangs={"ca"}) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("ckb-g1.ctb", _("Central Kurdish grade 1")) +addTable("ckb-g1.ctb", _("Central Kurdish grade 1"), inputForLangs={"ckb"}, translationForLangs={"ckb"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("cop-eg-comp8.utb", _("Coptic 8 dot computer braille"), input=False) @@ -213,7 +259,7 @@ def listTables() -> list[BrailleTable]: addTable("cs-comp8.utb", _("Czech 8 dot computer braille")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("cs-g1.ctb", _("Czech grade 1")) +addTable("cs-g1.ctb", _("Czech grade 1"), inputForLangs={"cs"}, translationForLangs={"cs"}) # Translators: The name of a braille table displayed in the # braille settings dialog. @@ -223,7 +269,7 @@ def listTables() -> list[BrailleTable]: addTable("da-dk-g08_1993.ctb", _("Danish 8 dot computer braille (1993)")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("da-dk-g16.ctb", _("Danish 6 dot grade 1")) +addTable("da-dk-g16.ctb", _("Danish 6 dot grade 1"), inputForLangs={"da"}, translationForLangs={"da"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("da-dk-g16_1993.ctb", _("Danish 6 dot grade 1 (1993)")) @@ -261,11 +307,11 @@ def listTables() -> list[BrailleTable]: addTable("de-g0-detailed.utb", _("German grade 0 (detailed)")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("de-g1.ctb", _("German grade 1"), input=False) +addTable("de-g1.ctb", _("German grade 1"), input=False, translationForLangs={"de"}) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("de-g1-detailed.ctb", _("German grade 1 (detailed)")) +addTable("de-g1-detailed.ctb", _("German grade 1 (detailed)"), inputForLangs={"de"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("de-g2.ctb", _("German grade 2"), contracted=True, input=False) @@ -275,7 +321,7 @@ def listTables() -> list[BrailleTable]: # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("el.ctb", _("Greek (Greece)")) +addTable("el.ctb", _("Greek (Greece)"), inputForLangs={"el"}, translationForLangs={"el"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("en-gb-comp8.ctb", _("English (U.K.) 8 dot computer braille")) @@ -314,7 +360,7 @@ def listTables() -> list[BrailleTable]: addTable("Es-Es-G0.utb", _("Spanish 8 dot computer braille")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("es-g1.ctb", _("Spanish grade 1")) +addTable("es-g1.ctb", _("Spanish grade 1"), inputForLangs={"es", "gl"}, translationForLangs={"es", "gl"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("es-g2.ctb", _("Spanish grade 2"), contracted=True) @@ -323,40 +369,50 @@ def listTables() -> list[BrailleTable]: addTable("et-g0.utb", _("Estonian grade 0")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("ethio-g1.ctb", _("Ethiopic grade 1")) +addTable("ethio-g1.ctb", _("Ethiopic grade 1"), inputForLangs={"am"}, translationForLangs={"am"}) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("fa-ir-comp8.ctb", _("Persian 8 dot computer braille")) +addTable("fa-ir-comp8.ctb", _("Persian 8 dot computer braille"), inputForLangs={"fa"}) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("fa-ir-g1.utb", _("Persian grade 1")) +addTable("fa-ir-g1.utb", _("Persian grade 1"), translationForLangs={"fa"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("fi.utb", _("Finnish 6 dot")) -# Translators: The name of a braille table displayed in the -# braille settings dialog. -addTable("fi-fi-8dot.ctb", _("Finnish 8 dot computer braille")) +addTable( + "fi-fi-8dot.ctb", + # Translators: The name of a braille table displayed in the + # braille settings dialog. + _("Finnish 8 dot computer braille"), + inputForLangs={"fi"}, + translationForLangs={"fi"}, +) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("fil-g2.ctb", _("Filipino grade 2"), contracted=True) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("fr-bfu-comp6.utb", _("French (unified) 6 dot computer braille")) -# Translators: The name of a braille table displayed in the -# braille settings dialog. -addTable("fr-bfu-comp8.utb", _("French (unified) 8 dot computer braille")) +addTable( + "fr-bfu-comp8.utb", + # Translators: The name of a braille table displayed in the + # braille settings dialog. + _("French (unified) 8 dot computer braille"), + inputForLangs={"fr"}, + translationForLangs={"fr"}, +) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("fr-bfu-g2.ctb", _("French (unified) grade 2"), contracted=True) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("ga-g1.utb", _("Irish grade 1")) +addTable("ga-g1.utb", _("Irish grade 1"), inputForLangs={"ga"}, translationForLangs={"ga"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("ga-g2.ctb", _("Irish grade 2"), contracted=True) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("gu-in-g1.utb", _("Gujarati grade 1")) +addTable("gu-in-g1.utb", _("Gujarati grade 1"), inputForLangs={"gu"}, translationForLangs={"gu"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("grc-international-en.utb", _("Greek international braille (2-cell accented letters)")) @@ -372,15 +428,25 @@ def listTables() -> list[BrailleTable]: # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("he-IL.utb", _("Israeli grade 1")) +addTable( + "he-IL-comp8.utb", + # Translators: The name of a braille table displayed in the + # braille settings dialog. + _("Hebrew computer braille"), + inputForLangs={"he"}, + translationForLangs={"he"}, +) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("he-IL-comp8.utb", _("Hebrew computer braille")) -# Translators: The name of a braille table displayed in the -# braille settings dialog. -addTable("hi-in-g1.utb", _("Hindi grade 1")) -# Translators: The name of a braille table displayed in the -# braille settings dialog. -addTable("hr-comp8.utb", _("Croatian 8 dot computer braille")) +addTable("hi-in-g1.utb", _("Hindi grade 1"), inputForLangs={"hi"}, translationForLangs={"hi"}) +addTable( + "hr-comp8.utb", + # Translators: The name of a braille table displayed in the + # braille settings dialog. + _("Croatian 8 dot computer braille"), + inputForLangs={"hr"}, + translationForLangs={"hr"}, +) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("hr-g1.ctb", _("Croatian grade 1")) @@ -389,28 +455,39 @@ def listTables() -> list[BrailleTable]: addTable("hu-hu-comp8.ctb", _("Hungarian 8 dot computer braille")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("hu-hu-g1.ctb", _("Hungarian grade 1")) +addTable("hu-hu-g1.ctb", _("Hungarian grade 1"), inputForLangs={"hu"}, translationForLangs={"hu"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("hu-hu-g2.ctb", _("Hungarian grade 2"), contracted=True) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("is.ctb", _("Icelandic 8 dot computer braille")) +addTable("is.ctb", _("Icelandic 8 dot computer braille"), inputForLangs={"is"}, translationForLangs={"is"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("IPA.utb", _("International Phonetic Alphabet"), input=False) -# Translators: The name of a braille table displayed in the -# braille settings dialog. -addTable("it-it-comp6.utb", _("Italian 6 dot computer braille")) +addTable( + "it-it-comp6.utb", + # Translators: The name of a braille table displayed in the + # braille settings dialog. + _("Italian 6 dot computer braille"), + inputForLangs={"it"}, + translationForLangs={"it"}, +) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("it-it-comp8.utb", _("Italian 8 dot computer braille")) + +addTable( + "ja-kantenji.utb", + # Translators: The name of a braille table displayed in the + # braille settings dialog. + _("Japanese (Kantenji) literary braille"), + input=False, + translationForLangs={"ja"}, +) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("ja-kantenji.utb", _("Japanese (Kantenji) literary braille"), input=False) -# Translators: The name of a braille table displayed in the -# braille settings dialog. -addTable("ka-in-g1.utb", _("Kannada grade 1")) +addTable("ka-in-g1.utb", _("Kannada grade 1"), inputForLangs={"kn"}, translationForLangs={"kn"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("ka.utb", _("Georgian literary braille")) @@ -419,7 +496,7 @@ def listTables() -> list[BrailleTable]: addTable("kk.utb", _("Kazakh grade 1"), input=False) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("km-g1.utb", _("Khmer grade 1")) +addTable("km-g1.utb", _("Khmer grade 1"), inputForLangs={"km"}, translationForLangs={"km"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("kmr.tbl", _("Northern Kurdish grade 0")) @@ -431,7 +508,7 @@ def listTables() -> list[BrailleTable]: addTable("ko-2006-g2.ctb", _("Korean grade 2 (2006)"), contracted=True) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("ko-g1.ctb", _("Korean grade 1")) +addTable("ko-g1.ctb", _("Korean grade 1"), inputForLangs={"ko"}, translationForLangs={"ko"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("ko-g2.ctb", _("Korean grade 2"), contracted=True) @@ -449,7 +526,7 @@ def listTables() -> list[BrailleTable]: addTable("lt.ctb", _("Lithuanian 8 dot")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("lt-6dot.utb", _("Lithuanian 6 dot")) +addTable("lt-6dot.utb", _("Lithuanian 6 dot"), inputForLangs={"lt"}, translationForLangs={"lt"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("Lv-Lv-g1.utb", _("Latvian grade 1")) @@ -464,7 +541,7 @@ def listTables() -> list[BrailleTable]: addTable("ms-my-g2.ctb", _("Malay grade 2"), contracted=True) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("mn-MN-g1.utb", _("Mongolian grade 1")) +addTable("mn-MN-g1.utb", _("Mongolian grade 1"), inputForLangs={"mn"}, translationForLangs={"mn"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("mn-MN-g2.ctb", _("Mongolian grade 2"), contracted=True) @@ -473,7 +550,7 @@ def listTables() -> list[BrailleTable]: addTable("mr-in-g1.utb", _("Marathi grade 1")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("my-g1.utb", _("Burmese grade 1")) +addTable("my-g1.utb", _("Burmese grade 1"), inputForLangs={"my"}, translationForLangs={"my"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("my-g2.ctb", _("Burmese grade 2"), contracted=True, input=False) @@ -482,7 +559,7 @@ def listTables() -> list[BrailleTable]: addTable("nl-NL-g0.utb", _("Dutch 6 dot")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("nl-comp8.utb", _("Dutch 8 dot")) +addTable("nl-comp8.utb", _("Dutch 8 dot"), inputForLangs={"nl"}, translationForLangs={"nl"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("no-no-8dot.utb", _("Norwegian 8 dot computer braille")) @@ -491,7 +568,7 @@ def listTables() -> list[BrailleTable]: addTable("No-No-g0.utb", _("Norwegian grade 0")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("No-No-g1.ctb", _("Norwegian grade 1")) +addTable("No-No-g1.ctb", _("Norwegian grade 1"), inputForLangs={"nb_NO"}, translationForLangs={"nb_NO"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("No-No-g2.ctb", _("Norwegian grade 2"), contracted=True) @@ -500,7 +577,7 @@ def listTables() -> list[BrailleTable]: addTable("No-No-g3.ctb", _("Norwegian grade 3"), contracted=True) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("np-in-g1.utb", _("Nepali grade 1")) +addTable("np-in-g1.utb", _("Nepali grade 1"), inputForLangs={"ne"}, translationForLangs={"ne"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("nso-za-g1.utb", _("Sepedi grade 1")) @@ -513,9 +590,14 @@ def listTables() -> list[BrailleTable]: # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("or-in-g1.utb", _("Oriya grade 1")) -# Translators: The name of a braille table displayed in the -# braille settings dialog. -addTable("pl-pl-comp8.ctb", _("Polish 8 dot computer braille")) +addTable( + "pl-pl-comp8.ctb", + # Translators: The name of a braille table displayed in the + # braille settings dialog. + _("Polish 8 dot computer braille"), + inputForLangs={"pl"}, + translationForLangs={"pl"}, +) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("Pl-Pl-g1.utb", _("Polish literary braille")) @@ -524,7 +606,7 @@ def listTables() -> list[BrailleTable]: addTable("pt-pt-comp8.ctb", _("Portuguese 8 dot computer braille")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("Pt-Pt-g1.utb", _("Portuguese grade 1")) +addTable("Pt-Pt-g1.utb", _("Portuguese grade 1"), inputForLangs={"pt"}, translationForLangs={"pt"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("Pt-Pt-g2.ctb", _("Portuguese grade 2"), contracted=True) @@ -533,7 +615,7 @@ def listTables() -> list[BrailleTable]: addTable("pu-in-g1.utb", _("Punjabi grade 1")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("ro-g0.utb", _("Romanian 6 dot")) +addTable("ro-g0.utb", _("Romanian 6 dot"), inputForLangs={"ro"}, translationForLangs={"ro"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("ro.ctb", _("Romanian")) @@ -542,7 +624,7 @@ def listTables() -> list[BrailleTable]: addTable("ru.ctb", _("Russian computer braille")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("ru-litbrl.ctb", _("Russian literary braille")) +addTable("ru-litbrl.ctb", _("Russian literary braille"), inputForLangs={"ru"}, translationForLangs={"ru"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("ru-litbrl-detailed.utb", _("Russian literary braille (detailed)")) @@ -563,13 +645,13 @@ def listTables() -> list[BrailleTable]: addTable("Se-Se.ctb", _("Swedish 8 dot computer braille")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("sk-g1.ctb", _("Slovak grade 1")) +addTable("sk-g1.ctb", _("Slovak grade 1"), inputForLangs={"sk"}, translationForLangs={"sk"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("sl-si-comp8.ctb", _("Slovenian 8 dot computer braille")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("sl-si-g1.utb", _("Slovenian grade 1")) +addTable("sl-si-g1.utb", _("Slovenian grade 1"), inputForLangs={"sl"}, translationForLangs={"sl"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("sot-za-g1.ctb", _("Sesotho grade 1")) @@ -585,7 +667,7 @@ def listTables() -> list[BrailleTable]: # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("sv-g0.utb", _("Swedish uncontracted braille"), input=False) +addTable("sv-g0.utb", _("Swedish uncontracted braille"), input=False, translationForLangs={"sv"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("sv-g1.ctb", _("Swedish partially contracted braille"), input=False) @@ -617,7 +699,7 @@ def listTables() -> list[BrailleTable]: # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("ta-ta-g1.ctb", _("Tamil grade 1")) +addTable("ta-ta-g1.ctb", _("Tamil grade 1"), inputForLangs={"ta"}, translationForLangs={"ta"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("tt.utb", _("Tatar grade 1"), input=False) @@ -632,10 +714,10 @@ def listTables() -> list[BrailleTable]: addTable("th-g0.utb", _("Thai grade 0"), input=False) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("th-g1.utb", _("Thai grade 1"), input=False, contracted=True) +addTable("th-g1.utb", _("Thai grade 1"), input=False, contracted=True, translationForLangs={"th"}) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("tr.ctb", _("Turkish grade 1")) +addTable("tr.ctb", _("Turkish grade 1"), inputForLangs={"tr"}, translationForLangs={"tr"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("tr-g2.ctb", _("Turkish grade 2"), contracted=True) @@ -650,7 +732,7 @@ def listTables() -> list[BrailleTable]: addTable("uga.utb", _("Ugaritic grade 1")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("uk.utb", _("Ukrainian grade 1")) +addTable("uk.utb", _("Ukrainian grade 1"), inputForLangs={"uk"}, translationForLangs={"uk"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("uk-detailed.utb", _("Ukrainian literary braille (detailed)")) @@ -659,7 +741,7 @@ def listTables() -> list[BrailleTable]: addTable("uk-comp.utb", _("Ukrainian computer braille")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("ur-pk-g1.utb", _("Urdu grade 1")) +addTable("ur-pk-g1.utb", _("Urdu grade 1"), inputForLangs={"ur"}, translationForLangs={"ur"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("ur-pk-g2.ctb", _("Urdu grade 2"), contracted=True) @@ -671,7 +753,7 @@ def listTables() -> list[BrailleTable]: addTable("unicode-braille.utb", _("Unicode braille"), output=False) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("vi-vn-g0.utb", _("Vietnamese grade 0")) +addTable("vi-vn-g0.utb", _("Vietnamese grade 0"), inputForLangs={"vi"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("ve-za-g1.utb", _("Tshivenda grade 1")) @@ -680,7 +762,7 @@ def listTables() -> list[BrailleTable]: addTable("ve-za-g2.ctb", _("Tshivenda grade 2"), contracted=True) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("vi-vn-g1.ctb", _("Vietnamese grade 1"), input=False) +addTable("vi-vn-g1.ctb", _("Vietnamese grade 1"), input=False, translationForLangs={"vi"}) # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("vi-vn-g2.ctb", _("Vietnamese grade 2"), contracted=True, input=False) @@ -696,19 +778,29 @@ def listTables() -> list[BrailleTable]: # Translators: The name of a braille table displayed in the # braille settings dialog. addTable("yi.utb", _("Yiddish grade 1")) - -# Translators: The name of a braille table displayed in the -# braille settings dialog. -# This should be translated to '中文中国汉语通用盲文' in Mandarin. -addTable("zhcn-cbs.ctb", _("Chinese common braille (simplified Chinese characters)"), input=False) +addTable( + "zhcn-cbs.ctb", + # Translators: The name of a braille table displayed in the + # braille settings dialog. + # This should be translated to '中文中国汉语通用盲文' in Mandarin. + _("Chinese common braille (simplified Chinese characters)"), + input=False, + translationForLangs={"zh_CN"}, +) # Translators: The name of a braille table displayed in the # braille settings dialog. # This should be translated to '中文中国汉语现行盲文(无声调)' in Mandarin. addTable("zh-chn.ctb", _("Chinese (China, Mandarin) Current Braille System (no tones)")) -# Translators: The name of a braille table displayed in the -# braille settings dialog. -# This should be translated to '中文中国汉语现行盲文' in Mandarin. -addTable("zhcn-g1.ctb", _("Chinese (China, Mandarin) Current Braille System")) + +addTable( + "zhcn-g1.ctb", + # Translators: The name of a braille table displayed in the + # braille settings dialog. + # This should be translated to '中文中国汉语现行盲文' in Mandarin. + _("Chinese (China, Mandarin) Current Braille System"), + inputForLangs={"zh_HK"}, + translationForLangs={"zh_HK"}, +) # Translators: The name of a braille table displayed in the # braille settings dialog. # This should be translated to '中文中国汉语双拼盲文' in Mandarin. @@ -718,7 +810,7 @@ def listTables() -> list[BrailleTable]: addTable("zh-hk.ctb", _("Chinese (Hong Kong, Cantonese)")) # Translators: The name of a braille table displayed in the # braille settings dialog. -addTable("zh-tw.ctb", _("Chinese (Taiwan, Mandarin)")) +addTable("zh-tw.ctb", _("Chinese (Taiwan, Mandarin)"), inputForLangs={"zh_TW"}, translationForLangs={"zh_TW"}) # Translators: The name of a braille table displayed in the # braille settings dialog. @@ -788,6 +880,10 @@ def initialize(): "Error while applying custom braille tables config from scratchpad manifest: " f"{manifestPath}", ) + if config.conf["braille"]["translationTable"] == "auto": + config.conf["braille"]["translationTable"] = getDefaultTableForCurLang(TableType.TRANSLATION) + if config.conf["braille"]["inputTable"] == "auto": + config.conf["braille"]["inputTable"] = getDefaultTableForCurLang(TableType.INPUT) def terminate(): diff --git a/source/config/configSpec.py b/source/config/configSpec.py index 9ca83af7d9..d8385c9a38 100644 --- a/source/config/configSpec.py +++ b/source/config/configSpec.py @@ -71,8 +71,8 @@ [braille] display = string(default=auto) mode = option("followCursors", "speechOutput", default="followCursors") - translationTable = string(default=en-ueb-g1.ctb) - inputTable = string(default=en-ueb-g1.ctb) + translationTable = string(default=auto) + inputTable = string(default=auto) expandAtCursor = boolean(default=true) showCursor = boolean(default=true) cursorBlink = boolean(default=true) diff --git a/user_docs/en/changes.md b/user_docs/en/changes.md index c3d0e198b6..fa372f2fe4 100644 --- a/user_docs/en/changes.md +++ b/user_docs/en/changes.md @@ -32,6 +32,7 @@ In order to use this feature, the application volume adjuster needs to be enable * The initial window can now be exited with `escape` or `alt+f4`. (#10799) * 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. * In Word and Outlook the result of more font formatting shortcuts is now reported. (#10271, @CyrilleB79) +* By default, translation and input braille tables will be set to `auto`, that is, according to NVDA's language when a table for the current language is available (#16390, #290, @nvdaes) ### Bug Fixes @@ -69,6 +70,7 @@ Add-ons will need to be re-tested and have their manifest updated. It can be used in scripts to report the result when a boolean is toggled in `config.conf` * Removed the requirement to indent function parameter lists by two tabs from NVDA's Coding Standards, to be compatible with modern automatic linting. (#17126, @XLTechie) * Added the [VS Code workspace configuration for NVDA](https://nvaccess.org/nvaccess/vscode-nvda) as a git submodule. (#17003) +* In the `brailleTables` module, a `getDefaultTableForCurrentLang` function has been added (#17222, @nvdaes) #### API Breaking Changes