From ad9148bdcbfd73cad8f9b9f1380eaa29da1a1649 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 30 Oct 2021 13:29:09 +0200 Subject: report: Romanize Arabic letter names. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Although I’m not a fan of romanization/transcription I feel it improves accessibility of the English version when combined with Arabic script in brackets. --- lulua/report.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'lulua/report.py') diff --git a/lulua/report.py b/lulua/report.py index 7d0294a..0e5ec00 100644 --- a/lulua/report.py +++ b/lulua/report.py @@ -18,7 +18,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -import sys, argparse, logging, pickle, math +import sys, argparse, logging, pickle, math, unicodedata from gettext import GNUTranslations, NullTranslations from decimal import Decimal from fractions import Fraction @@ -75,6 +75,39 @@ def render (): env.filters['arabnum'] = arabnum env.filters['fraction'] = fraction + # Map global variables to Arabic letter romanizations, so we can use + # them easily in text. + # Taken from Abu-Chacra’s Arabic – An Essential Grammar. It’s + # too difficult for now to write a general-purpose romanization + # function, because it would need a dictionary. + letterNames = { + 'Hamzah': ('Hamzah', 'ء'), + 'Alif': ('ᵓAlif', 'ا'), + 'Alifhamzah': ('ᵓAlif-hamzah', 'أ'), + 'Wawhamzah': ('Wa\u0304w-hamzah', 'ؤ'), + 'Yahamzah': ('Ya\u0304ᵓ-hamzah', 'ئ'), + 'Ba': ('Baᵓ', 'ب'), + 'Ta': ('Taᵓ', 'ت'), + 'Tha': ('T\u0331aᵓ', 'ث'), + 'Ra': ('Raᵓ', 'ر'), + 'Dal': ('Da\u0304l', 'د'), + 'Dhal': ('D\u0331a\u0304l', 'ذ'), + 'Qaf': ('Qa\u0304f', 'ق'), + 'Lam': ('La\u0304m', 'ل'), + 'Lamalif': ('La\u0304m-ᵓalif', 'لا'), + 'Mim': ('Mi\u0304m', 'م'), + 'Nun': ('Nu\u0304n', 'ن'), + 'Waw': ('Wa\u0304w', 'و'), + 'Ya': ('Ya\u0304ᵓ', 'ي'), + 'Tamarbutah': ('Ta\u0304ᵓ marbu\u0304t\u0323ah', 'ة'), + 'Alifmaqsurah': ('ᵓAlif maqs\u0323u\u0304rah', 'ى'), + } + for k, (romanized, arabic) in letterNames.items (): + env.globals[k] = f'{romanized} ({arabic})' + env.globals[k.lower ()] = env.globals[k].lower () + env.globals[k + '_'] = romanized + env.globals[k.lower () + '_'] = romanized.lower () + corpus = [] for x in args.corpus: with open (x) as fd: -- cgit v1.2.3