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

fix #632: [FR] Improve support of 'apocope' template #636

Merged
merged 1 commit into from
Jan 20, 2021
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
1 change: 0 additions & 1 deletion wikidict/lang/fr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@
"=": "=",
"absolu": "<i>absolu</i>",
"antonomase": "antonomase",
"apocope": "Apocope",
"apJC": "apr. J.-C.",
"attention": "⚠",
"au singulier uniquement": "<i>au singulier uniquement</i>",
Expand Down
11 changes: 7 additions & 4 deletions wikidict/lang/fr/template_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ def render_agglutination(tpl: str, parts: List[str], data: Dict[str, str]) -> st

def render_apherese(tpl: str, parts: List[str], data: Dict[str, str]) -> str:
"""
render aphérèse and apocope

>>> render_apherese("aphérèse", [], defaultdict(str))
'<i>aphérèse</i>'
'aphérèse'
>>> render_apherese("aphérèse", ["fr"], defaultdict(str))
'<i>aphérèse</i>'
'aphérèse'
>>> render_apherese("aphérèse", ["fr"], defaultdict(str, {"de": "enfant", "m": "1"}))
'Aphérèse de <i>enfant</i>'
>>> render_apherese("aphérèse", ["fr"], defaultdict(str, {"de": "enfant"}))
Expand All @@ -131,10 +133,10 @@ def render_apherese(tpl: str, parts: List[str], data: Dict[str, str]) -> str:
'aphérèse de <i>enfant</i>'
""" # noqa
if not parts or not data:
return italic("aphérèse")
return tpl

auto_cap = data["m"] in ("1", "oui")
phrase = ("A" if auto_cap else "a") + "phérèse"
phrase = capitalize(tpl) if auto_cap else tpl
if data["texte"] and data["nolien"] not in ("1", "oui"):
phrase += f' de {italic(data["texte"])}'
elif data["de"]:
Expand Down Expand Up @@ -685,6 +687,7 @@ def render_zh_lien(tpl: str, parts: List[str], data: Dict[str, str]) -> str:
"acronyme": render_acronyme,
"agglutination": render_agglutination,
"aphérèse": render_apherese,
"apocope": render_apherese,
"argot": render_argot,
"calque": render_etyl,
"cit_réf": render_cit_ref,
Expand Down