I should start by saying that I don’t speak Spanish and I certainly cannot translate it, but I thought it would be a fun exercise to see if I could programmatically translate cells in Google Spreadsheets from English to Spanish. This script uses Google Translate to automatically translate sentences after they’re typed into a spreadsheet. It could be helpful for writing Spanish ads for Google Adwords.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onEdit(e) { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var name = sheet.getName(); | |
var cell = sheet.getActiveCell(); | |
var value = cell.getValue(); | |
if (typeof value == 'string') { | |
var spanish = LanguageApp.translate(value, 'en', 'es'); | |
cell.setValue(spanish); | |
} | |
} |
I’ve read a few articles on how reliable the translations are. Is anyone familiar with how accurate the translations are? If you’re proficient with English & Spanish and care to take a look, let me know your thoughts on if this actually works.