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 #354: [FR] Support for e/ème/er/ère templates #373

Merged
merged 1 commit into from
Nov 25, 2020
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
15 changes: 13 additions & 2 deletions scripts/lang/fr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@
# Un documentation des fonctions disponibles se trouve dans le fichier HTML suivant :
# html/scripts/user_functions.html
templates_multi = {
# {{1er}}
# {{1er|mai}}
"1er": "f\"1{superscript('er')}{' ' + parts[1] if len(parts) > 1 else ''}\"",
# {{comparatif de|bien|fr|adv}}
"comparatif de": "sentence(parts)",
# {{cf}}
Expand All @@ -472,10 +475,14 @@
# XIX{{e}}
# {{e|-1}}
"e": "superscript(parts[1] if len(parts) > 1 else 'e')",
# XIX{{ème}}
"ème": "superscript(parts[1] if len(parts) > 1 else 'e')",
# {{er}}
"er": "superscript(parts[1] if len(parts) > 1 else 'er')",
# {{ère}}
"ère": "superscript(parts[1] if len(parts) > 1 else 'ère')",
# XIV{{exp|e}}
"exp": "superscript(parts[1] if len(parts) > 1 else 'e')",
# {{er}}
"er": "superscript('er')",
# {{emploi|au passif}}
"emploi": "term(capitalize(parts[1]))",
# {{#expr: 2 ^ 30}}
Expand Down Expand Up @@ -511,6 +518,10 @@
"nom w pc": "person(word, parts[1:])",
# {{nombre romain|12}}
"nombre romain": "int_to_roman(int(parts[1]))",
# {{numéro}}
"numéro": "f\"n{superscript('o')}\"",
# {{o}}
"o": "superscript('o')",
# {{petites capitales|Dupont}}
"petites capitales": "small_caps(parts[1])",
# {{pc|Dupont}}
Expand Down
7 changes: 7 additions & 0 deletions tests/test_fr.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ def test_parse_word(
@pytest.mark.parametrize(
"wikicode, expected",
[
("{{1er}}", "1<sup>er</sup>"),
("{{1er|mai}}", "1<sup>er</sup>&nbsp;mai"),
("{{adj-indéf-avec-de}}", "<i>(Avec de)</i>"),
("{{ancre|sens_sexe}}", ""),
("{{emploi|au passif}}", "<i>(Au passif)</i>"),
Expand All @@ -383,6 +385,9 @@ def test_parse_word(
("{{diminutif|fr|de=balle}}", "diminutif"),
("{{diminutif|fr|m=1}}", "Diminutif"),
("du XX{{e}} siècle", "du XX<sup>e</sup> siècle"),
("M{{e|me}}", "M<sup>me</sup>"),
("du XX{{ème}} siècle", "du XX<sup>e</sup> siècle"),
("le 1{{er}}", "le 1<sup>er</sup>"),
(
"{{étyl|grc|fr|mot=ἄκρος|tr=akros|sens=extrémité}}",
"grec ancien ἄκρος, <i>akros</i> («&nbsp;extrémité&nbsp;»)",
Expand Down Expand Up @@ -418,6 +423,8 @@ def test_parse_word(
("{{région|Lorraine et Dauphiné}}", "<i>(Lorraine et Dauphiné)</i>"),
("{{régionalisme}}", "<i>(Régionalisme)</i>"),
("{{régionalisme|Bretagne|fr}}", "<i>(Bretagne)</i>"),
("{{numéro}}", "n<sup>o</sup>"),
("{{o}}", "<sup>o</sup>"),
("{{pron|zjø|fr}}", "\\zjø\\"),
("{{pron-API|/j/}}", "/j/"),
("{{recons|lang-mot-vedette=fr|sporo|lang=frk|sc=Latn}}", "*<i>sporo</i>"),
Expand Down