Skip to content

Commit f3f617a

Browse files
authored
scripts/set-alias-page.py: also check if the translated alias page doesn't match the template (#20142)
1 parent 916cdf5 commit f3f617a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scripts/set-alias-page.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class AliasPageContent:
9393
title: str
9494
original_command: str
9595
documentation_command: str
96+
full_page: str = ""
9697

9798

9899
@dataclass
@@ -171,9 +172,17 @@ def set_alias_page(
171172
existing_locale_page_content = get_alias_command_in_page(
172173
path, get_locale_alias_pattern(locale)
173174
)
175+
stripped_translation_template = config.templates[locale]
176+
stripped_translation_template = stripped_translation_template.replace("example", "")
177+
178+
stripped_translation = existing_locale_page_content.full_page
179+
stripped_translation = re.sub(r"#.*", "# ", stripped_translation)
180+
stripped_translation = re.sub(r"`(?!tldr).*`", "``", stripped_translation)
181+
stripped_translation = re.sub(r"`tldr .*`", "`tldr `", stripped_translation)
174182

175183
if (
176-
existing_locale_page_content.title == page_content.title
184+
stripped_translation_template == stripped_translation
185+
and existing_locale_page_content.title == page_content.title
177186
and existing_locale_page_content.original_command
178187
== page_content.original_command
179188
and existing_locale_page_content.documentation_command
@@ -267,6 +276,7 @@ def get_alias_command_in_page(path: Path, alias_pattern: str) -> AliasPageConten
267276
title=title,
268277
original_command=original_command,
269278
documentation_command=documentation_command,
279+
full_page=content,
270280
)
271281

272282

0 commit comments

Comments
 (0)