-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.ts
More file actions
31 lines (29 loc) · 911 Bytes
/
code.ts
File metadata and controls
31 lines (29 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* This file gets run in the context of google apps script
* LanguageApp and ContentService among others are globals in that context
*/
/**
* Using get requests to translate
*/
declare let global: any
global.doGet = (e: any) => {
const { parameters } = e;
const input = parameters.text;
const output = LanguageApp.translate(input, 'en', 'id');
const json = JSON.stringify({
input,
output
})
return ContentService.createTextOutput(json)
.setMimeType(ContentService.MimeType.JSON);
};
// since doGet is run on a request permissions should be tested via this function in the online editor
global.testPermissions = () => {
const output = LanguageApp.translate('hello world', 'en', 'id');
const json = JSON.stringify({
text: output
});
const jsonString = ContentService.createTextOutput(json)
.setMimeType(ContentService.MimeType.JSON);
return jsonString;
}