#! /usr/bin/env python # -*- coding: utf-8 -*- # author: Lilian BESSON # email: Lilian.BESSON[AT]ens-cachan[DOT]fr # date: 23-07-2014 # web: https://bitbucket.org/lbesson/bin/src/master/fr2en_tex.sh # # A small script to translate latex documents from French to English. # The goal is to translate only the text content, not the latex code parts. # # Licence: GPL v3 # import sys import subprocess import glob try: from ANSIColors import printc except: def printc(a): print(a) printc(".: Lilian Besson presents :.") printc("Maths exercice LaTeX sources auto-translator, v0.1") file = str(sys.argv[1]) if len(sys.argv)>1 else glob.glob("*.fr.tex")[1] out = file.replace(".fr.tex", ".en.tex") for line in open(file).readlines(): # Succession de remplacements line.replace(" grand ", " big ").replace() # On produit le fichier partiellement traduit printc("Fichier %s" % file) printc("Succès :)")