Skip to content

Commit

Permalink
Add German alphabet and fix French numbers
Browse files Browse the repository at this point in the history
- Add German alphabet.
- Fix French numbers being rendered by their ordinal Braille codes.
  • Loading branch information
mondeja authored Sep 4, 2021
1 parent 4914d5d commit 32a3e4c
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 39 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ each locale is stored.
1. Create the expected file for the locale in `tests/{locale}.expect.txt`.
1. Add the language to README [Supported alphabets][supported-alphabets-table]
table.
1. Add a note with details about the implementation for that language in
1. Add a section with details about the implementation for that language in
[NOTES.md][notes]. This is specially useful if the implementation contains
singularities and will help future developers to maintain the code.

Expand Down
22 changes: 22 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Implementation of [North American Braille ASCII code][en-wiki].

Implementation of [CBE guide][es-cbe-guide].

### Numbers treatment

- According to the guide, numbers with 10 or more digits and telephone numbers
must be preceded by a numeric prefix `` in the first number only. But
this implementation currently precede the numerical prefix before any number.
Expand All @@ -19,6 +21,24 @@ Implementation of [CBE guide][es-cbe-guide].

Implementation of [Code Braille Français Uniformisé (CBFU)][fr-cbfu].

## German - Das System der deutschen Brailleschrift

Implementation of [Das System der deutschen Brailleschrift][de-system] (created
by [BSKDL][bskdl]).

### Capital letters treatment

The handling of capital letters has been simplified in this implementation.
The [guide][de-system] indicates that:

1. Individual capital letters and sequences of capital letters are identified
by placing the character‌ `` in front of them (capital letter ad symbol).
1. Lowercase letters are marked by prefixing them with the character ``
(lowercase advertisement character).

However, these rules don't apply. For each capital letter, only the character
`` is prepended regardless of its context.

## Galician - Braille español (Grado 1)

Uses same implementation as Spanish.
Expand All @@ -35,4 +55,6 @@ Uses same implementation as Spanish.
[en-wiki]: https://en.wikipedia.org/wiki/Braille_ASCII
[es-cbe-guide]: https://sid.usal.es/idocs/F8/FDO12069/signografiabasica.pdf
[fr-cbfu]: https://www.avh.asso.fr/sites/default/files/cbfu_edition_internationale_1.pdf
[de-system]: http://bskdl.org/textschrift.html
[bskdl]: http://bskdl.org
[world-braille-usage]: https://1kru3o1eyt4f2w3qy21ds14w-wpengine.netdna-ssl.com/wp-content/uploads/2021/07/world-braille-usage-third-edition.pdf
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ Text-to-Braille Inkscape extension with multiple localized alphabets.
| English | [North American Braille ASCII code][en-wiki] |
| Spanish | [Braille español (Grado 1)][es-cbe-guide] by [CBE][cbe-once] |
| French | [Code Braille Français Uniformisé (CBFU)][fr-cbfu] |
| German | [Das System der deutschen Brailleschrift][de-system] by [BSKDL][bskdl]|
| Galician | [Braille español (Grado 1)][es-cbe-guide] by [CBE][cbe-once] |
| Euskera | [Braille español (Grado 1)][es-cbe-guide] by [CBE][cbe-once] |
| Catalan/Valencian | [Braille español (Grado 1)][es-cbe-guide] by [CBE][cbe-once] |

> See [NOTES.md][notes] to check the limitations of each implementation.
> See [NOTES.md][notes] to details of each implementation.
## Installation

Expand Down Expand Up @@ -58,5 +59,7 @@ about how to contribute to this project.

[en-wiki]: https://en.wikipedia.org/wiki/Braille_ASCII
[es-cbe-guide]: https://sid.usal.es/idocs/F8/FDO12069/signografiabasica.pdf
[fr-cbfu]: https://www.avh.asso.fr/sites/default/files/cbfu_edition_internationale_1.pdf
[cbe-once]: https://www.once.es/servicios-sociales/braille/comision-braille-espanola/comision-braille-espanola-cbe
[fr-cbfu]: https://www.avh.asso.fr/sites/default/files/cbfu_edition_internationale_1.pdf
[de-system]: http://bskdl.org/textschrift.html
[bskdl]: http://bskdl.org
6 changes: 6 additions & 0 deletions tests/de.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵
⠨⠁⠨⠃⠨⠉⠨⠙⠨⠑⠨⠋⠨⠛⠨⠓⠨⠊⠨⠚⠨⠅⠨⠇⠨⠍⠨⠝⠨⠕⠨⠏⠨⠟⠨⠗⠨⠎⠨⠞⠨⠥⠨⠧⠨⠺⠨⠭⠨⠽⠨⠵
⠀\'⠈⠜⠐⠂"^>⠂⠠⠔<-⠄⠼⠚⠴⠘⠷⠈⠎+⠖⠐⠥⠆⠒(⠈⠸⠢⠘⠾⠈⠼)=+÷
⠼⠚⠼⠁⠼⠃⠼⠉⠼⠙⠼⠑⠼⠋⠼⠛⠼⠓⠼⠊
áéíóúàèìòù⠜ëï⠪⠳ÁÉÍÓÚÀÈÌÒÙ⠨⠜ËÏ⠨⠪⠨⠳
çÇ⠼⠚⠴⠼⠚⠴⠴⠶⠘⠉⠶⠶⠘⠗⠶℗🄯⠐⠂\<>⠐⠤{}—⠈⠑⠈⠎⠈⠉⠈⠇¥¥⠈⠸⠤
2 changes: 1 addition & 1 deletion tests/fr.expect.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵
⠨⠁⠨⠃⠨⠉⠨⠙⠨⠑⠨⠋⠨⠛⠨⠓⠨⠊⠨⠚⠨⠅⠨⠇⠨⠍⠨⠝⠨⠕⠨⠏⠨⠟⠨⠗⠨⠎⠨⠞⠨⠥⠨⠧⠨⠺⠨⠭⠨⠽⠨⠵
⠀⠐⠌⠄⠜⠌⠶⠈⠐⠜⠂⠐⠔⠐⠣⠤⠲⠐⠬⠘⠦⠘⠎⠖⠖⠐⠿⠆⠒⠦⠐⠤⠢⠴⠃⠐⠼⠴⠶⠖⠒
⠼⠼⠡⠼⠣⠼⠩⠼⠹⠼⠱⠼⠫⠼⠻⠼⠳⠼⠪
⠚⠼⠁⠼⠃⠼⠉⠼⠙⠼⠑⠼⠋⠼⠛⠼⠓⠼⠊
á⠿íóú⠷⠮ìò⠾ä⠫⠻ö⠳Á⠨⠿ÍÓÚ⠨⠷⠨⠮ÌÒ⠨⠾Ä⠨⠫⠨⠻Ö⠨⠳
⠯⠨⠯⠐⠬⠐⠬⠬⠐⠉⠐⠗℗🄯⠌⠐⠌⠐⠣⠐⠜|⠠⠠⠦⠴⠄⠄⠤⠤⠘⠑⠘⠎⠘⠉⠘⠇⠘⠽⠘⠽⠐⠤⠤⠤
1 change: 1 addition & 0 deletions text_braille_l18n.inx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<option value="en">English (ASCII)</option>
<option value="es">Spanish</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="gl">Galician</option>
<option value="eu">Basque</option>
<option value="ca">Catalan/Valencian</option>
Expand Down
144 changes: 109 additions & 35 deletions text_braille_l18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@

# UTILITIES

# Common standards

UPPERCASE_PREFIXES = {
chr(15): 0x2828, # uppercase prefix: https://codepoints.net/U+000F
}

# English based locales

EN_ASCII = " A1B'K2L@CIF/MSP\"E3H9O6R^DJG>NTQ,*5<-U8V.%[$+X!&;:4\\0Z7(_?W]#Y)="

# Spanish based locales

ES_NUMBERS = {
LOUIS_BRAILLE_NUMBERS_PREFIX = 0x283c # Louis Braille's numbers prefix
LOUIS_BRAILLE_NUMBERS = { # Louis Braille's original numbers codification
"0": 0x281a,
"1": 0x2801,
"2": 0x2803,
Expand All @@ -30,6 +28,14 @@
"9": 0x280a,
}

# ---------------------

# English based locales

EN_ASCII = " A1B'K2L@CIF/MSP\"E3H9O6R^DJG>NTQ,*5<-U8V.%[$+X!&;:4\\0Z7(_?W]#Y)="

# Spanish based locales

ES_LETTERS = {
"A": 0x2801,
"B": 0x2803,
Expand Down Expand Up @@ -143,19 +149,6 @@

# French based locales

FR_NUMBERS = {
"0": 0x283c,
"1": 0x2821,
"2": 0x2823,
"3": 0x2829,
"4": 0x2839,
"5": 0x2831,
"6": 0x282b,
"7": 0x283b,
"8": 0x2833,
"9": 0x282a,
}

FR_LETTERS = {
"A": 0x2801,
"B": 0x2803,
Expand Down Expand Up @@ -275,24 +268,85 @@
"¥": (0x2818, 0x283d),
}

# German based locales

DE_ACCENT_MARKS = {
"Ä": 0x281c,
"Ö": 0x282a,
"Ü": 0x2833,
}

DE_SIGNS = {
" ": 0x2800, # braille space
",": 0x2802,
";": 0x2806,
":": 0x2812,
"?": 0x2822,
"!": 0x2816,
"„": 0x2826,
"“": 0x2834,
"§": 0x282c,
".": 0x2804,
"–": 0x2824,
"‚": 0x2820,
}

DE_COMBINATIONS = {
# signs
"ß": (0x282e,), # converted to 'SS' if uppercased, so defined in combinations
"|": (0x2810, 0x2824),
"[": (0x2818, 0x2837),
"]": (0x2818, 0x283e),
"/": (0x2818, 0x280c),
"`": (0x2820, 0x2826),
"´": (0x2820, 0x2834),
"/": (0x2810, 0x2802),
"&": (0x2810, 0x2825),
"*": (0x2820, 0x2814),
"→": (0x2812, 0x2812, 0x2815),
"←": (0x282a, 0x2812, 0x2812),
"↔": (0x282a, 0x2812, 0x2812, 0x2815),
"%": (0x283c, 0x281a, 0x2834),
"‰": (0x283c, 0x281a, 0x2834, 0x2834),
"°": (0x2808, 0x2834),
"′": (0x2808, 0x2814),
"″": (0x2808, 0x2814, 0x2814),
"@": (0x2808, 0x281c),
"_": (0x2808, 0x2838),
"#": (0x2808, 0x283c),

# currencies
"€": (0x2808, 0x2811),
"$": (0x2808, 0x280e),
"¢": (0x2808, 0x2809),
"£": (0x2808, 0x2807),

# legal
"©": (0x2836, 0x2818, 0x2809, 0x2836),
"®": (0x2836, 0x2818, 0x2817, 0x2836),
}

# END: UTILITIES

# ---------------------------------

# LOCALE FUNCTIONS

def en_char_map(char):
# https://en.wikipedia.org/wiki/Braille_ASCII#Braille_ASCII_values
"""English chars mapper.
Source: https://en.wikipedia.org/wiki/Braille_ASCII#Braille_ASCII_values
"""
try:
mapint = EN_ASCII.index(char.upper())
except ValueError:
return char
return chr(mapint + 0x2800)

def number_singleupper_combinations_factory(
def numbers_singleuppers_combinations_factory(
numbers_map,
singleuppers_map,
combinations_map,
combinations_map, # also individual characters that are modified if uppercased
number_prefix,
uppercase_prefix,
):
Expand Down Expand Up @@ -321,8 +375,8 @@ def es_char_map_loader():
Source: https://sid.usal.es/idocs/F8/FDO12069/signografiabasica.pdf
"""
return number_singleupper_combinations_factory(
ES_NUMBERS,
return numbers_singleuppers_combinations_factory(
LOUIS_BRAILLE_NUMBERS,
{
**ES_LETTERS,
**ES_ACCENT_MARKS,
Expand All @@ -341,8 +395,8 @@ def eu_char_map_loader():
Source: https://sid.usal.es/idocs/F8/FDO12069/signografiabasica.pdf
"""
return number_singleupper_combinations_factory(
ES_NUMBERS,
return numbers_singleuppers_combinations_factory(
LOUIS_BRAILLE_NUMBERS,
{
**ES_LETTERS,
**ES_SIGNS,
Expand All @@ -359,8 +413,8 @@ def ca_char_map_loader():
Source: https://sid.usal.es/idocs/F8/FDO12069/signografiabasica.pdf
"""
return number_singleupper_combinations_factory(
ES_NUMBERS,
return numbers_singleuppers_combinations_factory(
LOUIS_BRAILLE_NUMBERS,
{
**ES_LETTERS,
**CA_ACCENT_MARKS,
Expand All @@ -373,13 +427,12 @@ def ca_char_map_loader():
)

def fr_char_map_loader():
"""Catalan/Valencian chars mappers. Uses the same implementation as
Spanish but different accent marks.
"""French chars mapper.
Source: https://sid.usal.es/idocs/F8/FDO12069/signografiabasica.pdf
"""
return number_singleupper_combinations_factory(
FR_NUMBERS,
return numbers_singleuppers_combinations_factory(
LOUIS_BRAILLE_NUMBERS,
{
**FR_LETTERS,
**FR_ACCENT_MARKS,
Expand All @@ -391,12 +444,33 @@ def fr_char_map_loader():
0x2828,
)

def de_char_map_loader():
"""German chars mapper.
- For letters, uses the same dictionary as French implementation.
Source: http://bskdl.org/textschrift.html
"""
return numbers_singleuppers_combinations_factory(
LOUIS_BRAILLE_NUMBERS,
{
**FR_LETTERS, # Same as French implementation
**DE_ACCENT_MARKS,
**DE_SIGNS,
**UPPERCASE_PREFIXES,
},
DE_COMBINATIONS,
0x283c,
0x2828,
)

# END: LOCALE FUNCTIONS

LOCALE_CHARMAPS = {
"en": en_char_map,
"es": es_char_map_loader,
"fr": fr_char_map_loader,
"en": en_char_map, # English
"es": es_char_map_loader, # Spanish
"fr": fr_char_map_loader, # French
"de": de_char_map_loader, # German
"gl": es_char_map_loader, # Galician
"eu": eu_char_map_loader, # Euskera
"ca": ca_char_map_loader, # Catalan/Valencian
Expand Down

0 comments on commit 32a3e4c

Please sign in to comment.