function onOpen(){
//Logger.log('Hello');
DocumentApp.getUi()
.createMenu('Advanced')
.addItem('번역', 'myFun1')
.addToUi();
}
function myFun1(){
var ui = DocumentApp.getUi();
var selection = DocumentApp.getActiveDocument().getSelection();
var rangeElements = selection.getRangeElements();
var text = rangeElements.map( function(element) {
return element.getElement().asText().getText();
})
var string = text.join('');
var userDefinedLanguage = PropertiesService.getUserProperties().getProperty('target_language')
var targetLanguage = userDefinedLanguage ? userDefinedLanguage : 'ko';
var translation = LanguageApp.translate(string, 'en', targetLanguage);
ui.alert('The following translation will be made: \n' + string + ' -> ' + translation);
DocumentApp.getActiveDocument().getBody().appendParagraph(translation)
}
[그림] 스크립트 편집기에서 작성하기
댓글 없음:
댓글 쓰기