Skip to content
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

Add support for 2024.3 symbol dictionaries #43

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,12 @@ def _(arg):
# output (shown in output table list),
# input (shown in input table list).
brailleTables = {}

# Custom speech symbol dictionaries
# Symbol dictionary files reside in the locale folder, e.g. `locale\en`, and are named `symbols-<name>.dic`.
# If your add-on includes custom speech symbol dictionaries (most will not), fill out this dictionary.
# Each key is the name of the dictionary,
# with keys inside recording the following attributes:
# displayName (name of the speech dictionary shown to users and translatable),
# mandatory (True when always enabled, False when not.
symbolDictionaries = {}
14 changes: 13 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ In addition, the following information must be filled out (not used in the manif

##### Custom add-on information

In addition to the core manifest data, custom add-on information can be specified. As of 2024, the template supports generation of custom braille translation tables. Information on custom braille tables must be specified in buildVars under `braileTables` dictionary as follows:
In addition to the core manifest data, custom add-on information can be specified.

###### Braille translation tables
Information on custom braille tables must be specified in buildVars under `brailleTables` dictionary as follows:

* Table name (string key for a nested dictionary): each `brailleTables` entry is a filename for the included custom braille table placed in `brailleTables` folder inside `addon` folder. This nested dictionary should specify:
* displayName (string): the name of the table shown to users and is translatable.
Expand All @@ -115,6 +118,15 @@ In addition to the core manifest data, custom add-on information can be specifie

Note: you must fill out this dictionary if at least one custom braille table is included in the add-on. If not, leave the dictionary empty.

###### Speech symbol dictionaries
Information on custom symbol dictionaries must be specified in buildVars under `symbolDictionaries` dictionary as follows:

* Dictionary name (string key for a nested dictionary): each `symbolDictionaries` entry is a name for the included custom symbol dictionary placed in `locale\<language>` folder inside `addon` folder. The file is named `symbols-<dictionary_name>.dic`. This nested dictionary should specify:
* displayName (string): the name of the dictionary shown to users and is translatable.
* mandatory (True/False): Always enabled (True) or optional and visible in the GUI (False)

Note: you must fill out this dictionary if at least one custom symbol dictionary is included in the add-on. If not, leave the dictionary empty.

### To manage documentation files for your addon:

1. Copy the `readme.md` file for your add-on to the first created folder, where you copied `buildVars.py`. You can also copy `style.css` to improve the presentation of HTML documents.
Expand Down
22 changes: 21 additions & 1 deletion sconstruct
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ def generateManifest(source, dest):
for key, val in buildVars.brailleTables[table].items():
manifest_brailleTables.append(f"{key} = {val}")
manifest += "\n".join(manifest_brailleTables) + "\n"

# Custom speech symbol dictionaries
if getattr(buildVars, "symbolDictionaries", {}):
manifest_symbolDictionaries = ["\n[symbolDictionaries]"]
for dictionary in buildVars.symbolDictionaries.keys():
manifest_symbolDictionaries.append(f"[[{dictionary}]]")
for key, val in buildVars.symbolDictionaries[dictionary].items():
manifest_symbolDictionaries.append(f"{key} = {val}")
manifest += "\n".join(manifest_symbolDictionaries) + "\n"

with codecs.open(dest, "w", "utf-8") as f:
f.write(manifest)

Expand All @@ -204,8 +214,18 @@ def generateTranslatedManifest(source, language, out):
for table in buildVars.brailleTables.keys():
result_brailleTables.append(f"[[{table}]]")
# Fetch display name only.
result_brailleTables.append(f"displayName = {buildVars.brailleTables[table]['displayName']}")
result_brailleTables.append(f"displayName = {_(buildVars.brailleTables[table]['displayName'])}")
result += "\n".join(result_brailleTables) + "\n"

# Custom speech symbol dictionaries
if getattr(buildVars, "symbolDictionaries", {}):
result_symbolDictionaries = ["\n[symbolDictionaries]"]
for dictionary in buildVars.symbolDictionaries.keys():
result_symbolDictionaries.append(f"[[{dictionary}]]")
# Fetch display name only.
result_symbolDictionaries.append(f"displayName = {_(buildVars.symbolDictionaries[dictionary]['displayName'])}")
result += "\n".join(result_symbolDictionaries) + "\n"

with codecs.open(out, "w", "utf-8") as f:
f.write(result)

Expand Down
Loading