Skip to content

Commit

Permalink
Use symbolLevel=none only for English; for other languages, inherit i…
Browse files Browse the repository at this point in the history
…t from the level below. (#4)

Fixes nvaccess/nvda#14417

Summary of the issue:
Hindi has no symbol defined in its symbol file, only copyright header; seems that the file was prepared for translation but no actual symbol translation took place.
But there is a Hindi CLDR file. Thus the symbol level for symbols such as common punctuation (dot, question marke, etc.) is the one of CLDR, i.e. none.

This is not adapted and it would be better to take advantage of the symbol levels that are defined in the English symbol file.

Description of user facing changes
In NVDA, locale CLDR dic file inherits symbol levels from the files coming after, i.e. English symbols and English CLDR. In case the locale symbol file does not define a character's level, this allows to:

Use the level for this symbol if it is defined there
Use "none" (coming from English CLDR dic file) if the character is not defined in English symbol file but is defined in CLDR.
Description of development approach
For all languages except English ("en"), generate the cldr.dic file with "-" in the level field, meaning that the level is inherited from previous files.
For English cldr.dic file, use "none" for the symbol level, as it was already before this PR.
  • Loading branch information
CyrilleB79 committed Dec 18, 2022
1 parent f29c2b4 commit 8547a1b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

def createCLDRAnnotationsDict(
sources: Iterable[PathT],
dest: PathT
dest: PathT,
level: str,
) -> None:
"""Produce NVDA dict file based on CLDR annotations.
"""
Expand All @@ -47,10 +48,8 @@ def createCLDRAnnotationsDict(
with codecs.open(dest, "w", "utf_8_sig", errors="replace") as dictFile:
dictFile.write(u"symbols:\r\n")
for pattern, description in cldrDict.items():
# Punctuations are set to none for CLDR characters to be pronounced
# even if user set punctuation level to None
dictFile.write(
f"{pattern}\t{description}\tnone\r\n"
f"{pattern}\t{description}\t{level}\r\n"
)


Expand Down Expand Up @@ -174,7 +173,14 @@ def createLocalesFromCldr(outDir: PathT) -> None:
os.makedirs(localeOutDir)
assert os.path.isdir(localeOutDir), f"Locale output dir must exist: {localeOutDir}"
outFile = os.path.join(localeOutDir, "cldr.dic")
createCLDRAnnotationsDict(cldrSources, outFile)
if destLocale == "en":
# For English (the default fallback), punctuations are set to none for CLDR characters to be pronounced
# even if user set punctuation level to None
level = 'none'
else:
# For other languages the level is set to be inherited from English symbol file or English CLDR file.
level = '-'
createCLDRAnnotationsDict(cldrSources, outFile, level)


def main():
Expand Down

0 comments on commit 8547a1b

Please sign in to comment.