mirror of
https://github.com/tldr-pages/tldr.git
synced 2026-08-28 19:59:24 +08:00
scripts/set-alias-page.py: also check if the translated alias page doesn't match the template (#20142)
This commit is contained in:
@@ -93,6 +93,7 @@ class AliasPageContent:
|
||||
title: str
|
||||
original_command: str
|
||||
documentation_command: str
|
||||
full_page: str = ""
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -171,9 +172,17 @@ def set_alias_page(
|
||||
existing_locale_page_content = get_alias_command_in_page(
|
||||
path, get_locale_alias_pattern(locale)
|
||||
)
|
||||
stripped_translation_template = config.templates[locale]
|
||||
stripped_translation_template = stripped_translation_template.replace("example", "")
|
||||
|
||||
stripped_translation = existing_locale_page_content.full_page
|
||||
stripped_translation = re.sub(r"#.*", "# ", stripped_translation)
|
||||
stripped_translation = re.sub(r"`(?!tldr).*`", "``", stripped_translation)
|
||||
stripped_translation = re.sub(r"`tldr .*`", "`tldr `", stripped_translation)
|
||||
|
||||
if (
|
||||
existing_locale_page_content.title == page_content.title
|
||||
stripped_translation_template == stripped_translation
|
||||
and existing_locale_page_content.title == page_content.title
|
||||
and existing_locale_page_content.original_command
|
||||
== page_content.original_command
|
||||
and existing_locale_page_content.documentation_command
|
||||
@@ -267,6 +276,7 @@ def get_alias_command_in_page(path: Path, alias_pattern: str) -> AliasPageConten
|
||||
title=title,
|
||||
original_command=original_command,
|
||||
documentation_command=documentation_command,
|
||||
full_page=content,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user