|
| 1 | +import argparse |
| 2 | +import os |
| 3 | + |
| 4 | +def edit_headers(target_language = "en"): |
| 5 | + translation_dict = { |
| 6 | + "Sample Preparation":{ |
| 7 | + "en":"Sample Preparation", |
| 8 | + "es":"Preparación de la muestra", |
| 9 | + "pt":"Preparação da amostra", |
| 10 | + "cs":"Příprava vzorku", |
| 11 | + }, |
| 12 | + "Sample Acquisition":{ |
| 13 | + "en":"Sample Acquisition", |
| 14 | + "es":"Adquisición de muestras", |
| 15 | + "pt":"Aquisição da amostra", |
| 16 | + "cs":"Snímání vzorku", |
| 17 | + }, |
| 18 | + "Image Analysis and Data Handling":{ |
| 19 | + "en":"Image Analysis and Data Handling", |
| 20 | + "es":"Análisis de Imágenes y Manejo de Datos", |
| 21 | + "pt":"Análise de imagens e tratamento de dados", |
| 22 | + "cs":"Analýza obrazu a práce s daty", |
| 23 | + }, |
| 24 | + "Data Interpretation":{ |
| 25 | + "en":"Data Interpretation", |
| 26 | + "es":"Interpretación de Datos", |
| 27 | + "pt":"Interpretação de dados", |
| 28 | + "cs":"Interpretace dat", |
| 29 | + }, |
| 30 | + "Additional Resources":{ |
| 31 | + "en":"Additional Resources", |
| 32 | + "es":"Recursos Adicionales", |
| 33 | + "pt":"Recursos Adicionais", |
| 34 | + "cs":"Další zdroje", |
| 35 | + }, |
| 36 | + } |
| 37 | + |
| 38 | + lines = open("_toc.yml", "r").readlines() |
| 39 | + newlines = [] |
| 40 | + for line in lines: |
| 41 | + for caption in translation_dict.keys(): |
| 42 | + if line == f"- caption: {caption}\n": |
| 43 | + line=line.replace(caption,translation_dict[caption][target_language]) |
| 44 | + newlines.append(line) |
| 45 | + |
| 46 | + with open("_toc.yml","w") as toc: |
| 47 | + toc.writelines(newlines) |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +if __name__ == "__main__": |
| 52 | + parser = argparse.ArgumentParser(description="Say what language to translate the headers to") |
| 53 | + |
| 54 | + parser.add_argument("target_language", help="Language to translate header language into. Currently supported options are en, es, pt, and cs") |
| 55 | + |
| 56 | + args = parser.parse_args() |
| 57 | + |
| 58 | + edit_headers(target_language=args.target_language) |
0 commit comments