Skip to content

Commit

Permalink
[NO] Support "tre" template
Browse files Browse the repository at this point in the history
  • Loading branch information
BoboTiG committed Sep 23, 2024
1 parent 48bd6cf commit 211d500
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions wikidict/lang/no/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
"trenger referanse",
)

# Templates that will be completed/replaced using italic style.
templates_italic = {
"tre": "tresort",
}


# Templates more complex to manage.
templates_multi = {
# {{alternativ skrivemåte|be}}
Expand Down Expand Up @@ -189,7 +195,7 @@ def last_template_handler(template: tuple[str, ...], locale: str, word: str = ""
'<i>ord</i>'
"""
from ...user_functions import concat, extract_keywords_from, term
from ...user_functions import concat, extract_keywords_from, lookup_italic, term
from .langs import langs
from .template_handlers import lookup_template, render_template

Expand All @@ -199,13 +205,13 @@ def last_template_handler(template: tuple[str, ...], locale: str, word: str = ""
tpl, *parts = template
extract_keywords_from(parts)

if tpl in {"kontekst", "tema"}:
return term(concat(parts, sep=", "))

if not parts or (len(parts) == 1 and parts[0] in {"nb", "nn", "no", "nrm"}):
return term(tpl)
match tpl:
case "etyl":
return langs.get(parts[0], parts[0])
case "kontekst" | "tema":
return term(concat(parts, sep=", "))

if tpl == "etyl":
return langs.get(parts[0], parts[0])
if italic_tpl := lookup_italic(tpl, locale, empty_default=True):
return term(italic_tpl)

raise ValueError(f"Unhandled {template=} {word=}")

0 comments on commit 211d500

Please sign in to comment.