Skip to content

Commit

Permalink
Add translation checker (huggingface#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
lewtun authored Oct 5, 2022
1 parent 85019bc commit 32b2bda
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ This repo contains the content that's used to create the **[Hugging Face course]
| [Russian](https://huggingface.co/course/ru/chapter1/1) (WIP) | [`chapters/ru`](https://github.com/huggingface/course/tree/main/chapters/ru) | [@pdumin](https://github.com/pdumin), [@svv73](https://github.com/svv73) |
| [Thai](https://huggingface.co/course/th/chapter1/1) (WIP) | [`chapters/th`](https://github.com/huggingface/course/tree/main/chapters/th) | [@peeraponw](https://github.com/peeraponw), [@a-krirk](https://github.com/a-krirk), [@jomariya23156](https://github.com/jomariya23156), [@ckingkan](https://github.com/ckingkan) |
| [Turkish](https://huggingface.co/course/tr/chapter1/1) (WIP) | [`chapters/tr`](https://github.com/huggingface/course/tree/main/chapters/tr) | [@tanersekmen](https://github.com/tanersekmen), [@mertbozkir](https://github.com/mertbozkir), [@ftarlaci](https://github.com/ftarlaci), [@akkasayaz](https://github.com/akkasayaz) |
| [Vietnamese](https://huggingface.co/course/vi/chapter1/1) (WIP) | [`chapters/vi`](https://github.com/huggingface/course/tree/main/chapters/vi) | [@honghanhh](https://github.com/honghanhh) |
| [Chinese (simplified)](https://huggingface.co/course/zh-CN/chapter1/1) (WIP) | [`chapters/zh-CN`](https://github.com/huggingface/course/tree/main/chapters/zh-CN) | [@zhlhyx](https://github.com/zhlhyx), [petrichor1122](https://github.com/petrichor1122), [@1375626371](https://github.com/1375626371) |
| [Vietnamese](https://huggingface.co/course/vi/chapter1/1) | [`chapters/vi`](https://github.com/huggingface/course/tree/main/chapters/vi) | [@honghanhh](https://github.com/honghanhh) |
| [Chinese (simplified)](https://huggingface.co/course/zh-CN/chapter1/1) | [`chapters/zh-CN`](https://github.com/huggingface/course/tree/main/chapters/zh-CN) | [@zhlhyx](https://github.com/zhlhyx), [petrichor1122](https://github.com/petrichor1122), [@1375626371](https://github.com/1375626371) |
| [Chinese (traditional)](https://huggingface.co/course/zh-TW/chapter1/1) (WIP) | [`chapters/zh-TW`](https://github.com/huggingface/course/tree/main/chapters/zh-TW) | [@davidpeng86](https://github.com/davidpeng86) |


Expand Down
4 changes: 2 additions & 2 deletions chapters/ja/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
- local: chapter8/6
title: 概要

- title: Hugging Faceコースのイベント
- title: コースのイベント
sections:
- local: event/1
- local: events/2
title: パート2公開記念イベント
File renamed without changes.
4 changes: 2 additions & 2 deletions chapters/pt/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
- local: chapter8/3
title: Pedindo ajuda nos fóruns

- title: Evento do curso Hugging Face
- title: Evento do curso
sections:
- local: event/1
- local: events/2
title: Evento de lançamento da Parte 2
File renamed without changes.
4 changes: 2 additions & 2 deletions chapters/vi/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
title: Đố vui cuối chương
quiz: 9

- title: Sự kiện Khoá học Hugging Face
- title: Sự kiện Khoá học
sections:
- local: event/1
- local: events/2
title: Sự kiện Phát hành Phần 2
File renamed without changes.
4 changes: 2 additions & 2 deletions chapters/zh-CN/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
title: 章末测试
quiz: 9

- title: Hugging Face 课程活动
- title: 课程活动
sections:
- local: event/1
- local: events/2
title: Part 2 发布活动
File renamed without changes.
34 changes: 34 additions & 0 deletions utils/validate_translation.py
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!")

0 comments on commit 32b2bda

Please sign in to comment.