forked from microsoft/TypeScript-Website-Localizations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdangerfile.ts
29 lines (21 loc) · 781 Bytes
/
dangerfile.ts
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
const markdownTranslate = require('@orta/markdown-translator')
import {danger, markdown} from "danger"
const go = async () => {
const allMDFiles = [...danger.git.modified_files, ...danger.git.created_files].filter(f => f.endsWith(".md")).filter(f => f.split("/").length > 2)
for (const file of allMDFiles) {
const fileContents = await danger.github.utils.fileContents(file)
if (!fileContents) continue
const translation = await markdownTranslate({
text: fileContents,
from: file.split("/")[2],
to: "en",
subscriptionKey: process.env.AZURE_TRANSLATE_KEY,
region: "eastus"
})
markdown(`<details>
<summary>Translation of ${danger.github.utils.fileLinks([file])}</summary>
${translation}
</details>`)
};
}
go()