from googletrans import Translator
import fileinput

translator = Translator()
temp_list = []
file = "./spanish_css.css"
with open(file, 'r') as f:
    with open("_translated_css.html.liquid", "a+") as n:
        # Uncomment the next three lines if you want the script to save a back up file, just in case.
        # read_data = f.read()
        # backup = open("backup_css.css", "w")
        # backup.write(read_data)
        lines = f.readlines()
        for line in lines:
            if "content:" in line:
                tr = line[11:-2]
                changed = translator.translate(tr, dest='fr')
                newline = line.replace(tr, changed.text)
                n.write(newline)
            else:
                n.write(line)
        f.close()
        n.close()
