<reponame>dvidd/translate-json<filename>languages/spanish.py
from googletrans import Translator

import os
import json

translator = Translator()

# English to spanish
file = '../data/en.json'
finaljson = {}


with open(file) as f:
    data = json.load(f)

for idx, i in enumerate(data):
    # Here you can select any lenguage
    translation = translator.translate(data[i], dest='es')
    print(translation.text)
    data[i] = translation.text


with open('spanish.json','w') as f:
    json.dump(data, f, indent=4)


from googletrans import Translator

import os
import json

translator = Translator()

# English to spanish
file = '../data/en.json'
finaljson = {}


with open(file) as f:
    data = json.load(f)

for idx, i in enumerate(data):
    # Here you can select any lenguage
    translation = translator.translate(data[i], dest='es')
    print(translation.text)
    data[i] = translation.text


with open('spanish.json','w') as f:
    json.dump(data, f, indent=4)
# English to spanish # Here you can select any lenguage