After reading your question I wrote a code that fulfills your expectations. This is the code in question:
function koreanTranslator() {
var spreadsheetID = "{SPREADSHEET ID}";
var koreanSheet = SpreadsheetApp.openById(spreadsheetID).getSheetByName(
"Example");
var koreanCells = koreanSheet.getRange(1, 1, koreanSheet.getLastRow(),
koreanSheet.getLastColumn()).getValues();
var equivalencesSheet = SpreadsheetApp.openById(spreadsheetID).getSheetByName(
"Reference");
var equivalencesCells = equivalencesSheet.getRange(2, 1, equivalencesSheet
.getLastRow(),
2).getValues();
for (var i = 0; i < koreanCells.length; i++) {
for (var j = 0; j < koreanCells[0].length; j++) {
for (var k = 0; k < equivalencesCells.length; k++) {
if (koreanCells[i][j] == equivalencesCells[k][0]) {
koreanSheet.getRange(i + 1, j + 1).setValue(equivalencesCells[k][1]);
}
}
}
}
}
The code will first open the spreadsheet with .openById()
, continuing by opening both sheets with .getSheetByName()
. After that, it will read both tables with .getRange()
(calculating the size of the table with .getLastColumn()
and .getLastRow()
, so you can use bigger or shorter tables without changing the code) and .getValues()
.
Finally, the code will iterate by each cell in the korean sheet and compare it with the dictionary sheet; and if it finds a coincidence it will update the korean sheet with .setValue()
. Please, don't hesitate to comment on my answer for further help or more clarification.