Skip to content
Draft
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
11 changes: 4 additions & 7 deletions docs/scripts/translate_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
# gpt-4.5 needed this for better quality
ENABLE_SMALL_CHUNK_TRANSLATION = False

SEARCH_EXCLUSION = """---
search:
exclude: true
---
"""

def search_front_matter(lang_code: str) -> str:
return f"---\nsearch:\n lang: {lang_code}\n---\n"


# Define the source and target directories
Expand Down Expand Up @@ -239,8 +237,7 @@ def translate_file(file_path: str, target_path: str, lang_code: str) -> None:
for idx, code_block in enumerate(code_blocks):
translated_text = translated_text.replace(f"CODE_BLOCK_{idx:02}", code_block)

# FIXME: enable mkdocs search plugin to seamlessly work with i18n plugin
translated_text = SEARCH_EXCLUSION + translated_text
translated_text = search_front_matter(lang_code) + translated_text
# Save the combined translated content
with open(target_path, "w", encoding="utf-8") as f:
f.write(translated_text)
Expand Down
Loading