Skip to content

Commit

Permalink
Fix false parameter in {{article encyclopédique}}
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertbossot committed Apr 21, 2024
1 parent 1d21f49 commit da975ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lib/page_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ def get_section_by_title(page_content, section_title_regex, section_level=2):
return page_content, start_position, end_position


def is_template_name(string, template_name):
def is_template_name_start(string, template_name):
regex = f'^({template_name[:1].upper()}|{template_name[:1].lower()}){template_name[1:]}'
return re.search(regex, string)

Expand Down
19 changes: 11 additions & 8 deletions src/lib/templates_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def translate_template_parameters(current_template):
continue

if old_param[p] == 'agency':
if is_template_name(current_template, 'article') and not has_parameter(current_template, 'périodique') \
if is_template_name_start(current_template, 'article') and not has_parameter(current_template, 'périodique') \
and not has_parameter(current_template, 'work'):
fr_name = 'périodique'
else:
Expand All @@ -586,8 +586,11 @@ def translate_template_parameters(current_template):
fr_name = 'date'

elif old_param[p] == 'publisher':
if is_template_name(current_template, 'article') and not has_parameter(current_template, 'périodique') \
and not has_parameter(current_template, 'work'):
input(is_template_name_start(current_template, 'article'))
if (is_template_name_start(current_template, 'article')
and not is_template_name_start(current_template, 'article encyclopédique')
and not has_parameter(current_template, 'périodique')
and not has_parameter(current_template, 'work')):
fr_name = 'périodique'
else:
fr_name = 'éditeur'
Expand All @@ -609,23 +612,23 @@ def translate_template_parameters(current_template):
current_template = current_template.replace(old_param_value, title + language_parameter)

elif old_param[p] == 'type':
if is_template_name(current_template, 'article'):
if is_template_name_start(current_template, 'article'):
fr_name = 'nature article'
elif is_template_name(current_template, 'ouvrage'):
elif is_template_name_start(current_template, 'ouvrage'):
fr_name = 'nature ouvrage'
else:
fr_name = 'type'

elif old_param[p] == 'website':
if not is_template_name(
if not is_template_name_start(
current_template, 'article'
) or has_parameter(current_template, 'périodique'):
fr_name = old_param[p]

elif old_param[p] == 'work':
if is_template_name(current_template, 'article') and not has_parameter(current_template, 'périodique'):
if is_template_name_start(current_template, 'article') and not has_parameter(current_template, 'périodique'):
fr_name = 'périodique'
elif is_template_name(current_template, 'lien web') and not has_parameter(current_template, 'site') \
elif is_template_name_start(current_template, 'lien web') and not has_parameter(current_template, 'site') \
and not has_parameter(current_template, 'website'):
fr_name = 'site'
else:
Expand Down

0 comments on commit da975ac

Please sign in to comment.