forked from huggingface/course
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add translation checker (huggingface#329)
- Loading branch information
Showing
10 changed files
with
44 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import argparse | ||
import os | ||
import yaml | ||
|
||
from pathlib import Path | ||
|
||
PATH_TO_COURSE = Path("chapters/") | ||
|
||
def load_sections(language: str): | ||
toc = yaml.safe_load( | ||
open(os.path.join(PATH_TO_COURSE / language, "_toctree.yml"), "r") | ||
) | ||
sections = [] | ||
for chapter in toc: | ||
for section in chapter["sections"]: | ||
sections.append(section["local"]) | ||
return set(sorted(sections)) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--language", type=str, help="Translation language to validate") | ||
args = parser.parse_args() | ||
|
||
english_sections = load_sections("en") | ||
translation_sections = load_sections(args.language) | ||
missing_sections = english_sections.difference(translation_sections) | ||
|
||
if len(missing_sections) > 0: | ||
print("Missing sections:") | ||
for section in missing_sections: | ||
print(section) | ||
else: | ||
print("✅ No missing sections - translation complete!") |