BoboTiG / ebook-reader-dict

Finally decent dictionaries based on the Wiktionary for your beloved eBook reader. Daily updates & 14 languages supported so far.
http://www.tiger-222.fr/?d=2020/04/17/22/14/21-un-dictionnaire-alternatif-et-complet-pour-votre-liseuse
MIT License
423 stars 24 forks source link

[EL] Simplify template code #2251

Closed chopinesque closed 3 weeks ago

chopinesque commented 3 weeks ago

Is there some way to simplify multiple templates like this in a way that one only needs to add tpl and expansion text? I.e. instead of these:

    if tpl == "μτχχρ":
        text = italic("μετοχή παθητικού παρακειμένου")
        return text if data["0"] else f"({text})"

    if tpl == "μυθολ":
        text = italic("(μυθολογία)")
        return text if data["0"] else f"({text})"

Something like

Some code here
"μτχχρ": "μετοχή παθητικού παρακειμένου"
"μυθολ": "μυθολογία"
Some code here
BoboTiG commented 3 weeks ago

I'll answer as a suggestion on #2250.