Skip to content

Commit

Permalink
[FR] Handle the 'LienRouge' template (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasconic authored Nov 22, 2020
1 parent 3f4ef0d commit 494dacd
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scripts/lang/fr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,22 @@ def last_template_handler(template: Tuple[str, ...], locale: str) -> str:
'马 (馬, <i>mǎ</i>)'
>>> last_template_handler(["zh-lien", "骨", "gǔ", "骨"], "fr")
'骨 (骨, <i>gǔ</i>)'
>>> last_template_handler(["LienRouge", "fr=Comité", "trad=United Nations", "texte=COPUOS"], "fr")
'<i>COPUOS</i>'
>>> last_template_handler(["LienRouge", "Comité", "trad=Ausschuss", "texte=COPUOS"], "fr")
'<i>COPUOS</i>'
>>> last_template_handler(["LienRouge", "fr=Comité", "trad=United Nations"], "fr")
'<i>Comité</i>'
>>> last_template_handler(["LienRouge", "Comité", "trad=Ausschuss"], "fr")
'<i>Comité</i>'
>>> last_template_handler(["LienRouge", "fr=Comité"], "fr")
'<i>Comité</i>'
>>> last_template_handler(["LienRouge", "Comité"], "fr")
'<i>Comité</i>'
>>> last_template_handler(["LienRouge", "trad=United Nations"], "fr")
'<i>United Nations</i>'
"""
from .langs import langs
from ..defaults import last_template_handler as default
Expand Down Expand Up @@ -1030,6 +1046,17 @@ def last_template_handler(template: Tuple[str, ...], locale: str) -> str:
return f"{simple} ({pinyin})"
return f"{simple} ({traditional}, {pinyin})"

if tpl == "LienRouge":
data = extract_keywords_from(parts)
if data["texte"]:
return italic(data["texte"])
if data["fr"]:
return italic(data["fr"])
if parts:
return italic(parts[0])
if data["trad"]:
return italic(data["trad"])

# This is a country in the current locale
if tpl in langs:
return langs[tpl]
Expand Down

0 comments on commit 494dacd

Please sign in to comment.