Cin7 templates, Luminate templates. Walmart scripts and directory reorg
This commit is contained in:
23
Scripts/Walmart/Luminate/translate_css.py
Normal file
23
Scripts/Walmart/Luminate/translate_css.py
Normal file
@ -0,0 +1,23 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user