()
| 111 | |
| 112 | # Main function to run the process |
| 113 | async def main(): |
| 114 | input_dir = "../tutorials/learnpython.org/en" |
| 115 | output_base_dir = "../tutorials/learnpython.org" |
| 116 | |
| 117 | # Process English JSON first |
| 118 | welcome_file = Path(input_dir) / "welcome.md" |
| 119 | if not welcome_file.exists(): |
| 120 | logger.error(f"Welcome.md file not found at {welcome_file}") |
| 121 | return |
| 122 | |
| 123 | # Extract English sections |
| 124 | sections = extract_sections_from_markdown(str(welcome_file)) |
| 125 | |
| 126 | # Create English JSON if it doesn't already exist |
| 127 | english_output_dir = Path(output_base_dir) / "en" |
| 128 | english_output_dir.mkdir(parents=True, exist_ok=True) |
| 129 | if not check_existing_json(english_output_dir): |
| 130 | save_index_json(sections, str(english_output_dir)) |
| 131 | |
| 132 | # Process translations based on English JSON |
| 133 | for lang in languages: |
| 134 | if lang["code"] == "en": |
| 135 | continue |
| 136 | |
| 137 | target_language = lang["name"] |
| 138 | output_dir = Path(output_base_dir) / lang["code"] |
| 139 | output_dir.mkdir(parents=True, exist_ok=True) |
| 140 | |
| 141 | if check_existing_json(output_dir): |
| 142 | continue |
| 143 | |
| 144 | translated_sections = await translate_sections(sections, target_language) |
| 145 | save_index_json(translated_sections, str(output_dir)) |
| 146 | |
| 147 | if __name__ == "__main__": |
| 148 | import asyncio |
no test coverage detected