Skip to content

Commit 8c2d8e2

Browse files
committed
[FR] Fix support for "substantivation de" template
Fixes #2342.
1 parent 300a91e commit 8c2d8e2

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

wikidict/lang/fr/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,6 @@
441441
# {{sport|fr}}
442442
# {{sport|fr|collectifs}}
443443
"sport": "term(capitalize(concat(parts, ' ', indexes=[0, 2])))",
444-
# {{substantivation de|mettre en exergue}}
445-
"substantivation de": 'f"Substantivation de {italic(parts[1])}"',
446444
# {{superlatif de|petit|fr}}
447445
"superlatif de": "sentence(parts)",
448446
# {{wd|Q30092597|Frederick H. Pough}}

wikidict/lang/fr/template_handlers.py

+38
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,43 @@ def render_sigle(tpl: str, parts: list[str], data: defaultdict[str, str], *, wor
10791079
return phrase
10801080

10811081

1082+
def render_substantivation_de(tpl: str, parts: list[str], data: defaultdict[str, str], *, word: str = "") -> str:
1083+
"""
1084+
>>> render_substantivation_de("substantivation de", ["mot", "fr"], defaultdict(str))
1085+
'Substantivation de <i>mot</i>'
1086+
>>> render_substantivation_de("substantivation de", ["mot", "fr"], defaultdict(str, {"type": "adjectif"}))
1087+
'Substantivation de l’adjectif <i>mot</i>'
1088+
>>> render_substantivation_de("substantivation de", ["mot", "fr"], defaultdict(str, {"type": "infinitif"}))
1089+
'Substantivation de l’infinitif <i>mot</i>'
1090+
>>> render_substantivation_de("substantivation de", ["mot", "fr"], defaultdict(str, {"type": "participe"}))
1091+
'Substantivation du participe du verbe <i>mot</i>'
1092+
>>> render_substantivation_de("substantivation de", ["mot", "fr"], defaultdict(str, {"type": "locution verbale"}))
1093+
'Substantivation de la locution verbale <i>mot</i>'
1094+
>>> render_substantivation_de("substantivation de", ["mot", "fr"], defaultdict(str, {"type": "locution verbale", "sens": "verbeux"}))
1095+
'Substantivation de la locution verbale <i>mot</i> (« verbeux »)'
1096+
"""
1097+
text = "Substantivation"
1098+
1099+
match type_ := data["type"]:
1100+
case "adjectif" | "infinitif":
1101+
text += f" de l’{type_}"
1102+
case "locution verbale":
1103+
text += f" de la {type_}"
1104+
case "participe":
1105+
text += f" du {type_} du verbe"
1106+
case "":
1107+
text += " de"
1108+
case _:
1109+
assert 0, f"Unhandled {tpl!r} type {type_!r}."
1110+
1111+
text += f" {italic(parts[0])}"
1112+
1113+
if sens := data["sens"]:
1114+
text += f" (« {sens} »)"
1115+
1116+
return text
1117+
1118+
10821119
def render_suisse(tpl: str, parts: list[str], data: defaultdict[str, str], *, word: str = "") -> str:
10831120
"""
10841121
>>> render_suisse("Suisse", ["fr"], defaultdict(str, {"précision":"Fribourg, Valais, Vaud"}))
@@ -1374,6 +1411,7 @@ def render_zh_lien(tpl: str, parts: list[str], data: defaultdict[str, str], *, w
13741411
"sigle": render_sigle,
13751412
"source?": render_refnec,
13761413
"source ?": render_refnec,
1414+
"substantivation de": render_substantivation_de,
13771415
"Suisse": render_suisse,
13781416
"supplétion": render_suppletion,
13791417
"syncope": render_modele_etym,

0 commit comments

Comments
 (0)