Skip to content

Commit dcd6ea9

Browse files
author
Orta
authored
Merge pull request #251 from microsoft/update_translator
Update the translation issues automatically
2 parents 334ec2d + d104949 commit dcd6ea9

File tree

3 files changed

+62
-12
lines changed

3 files changed

+62
-12
lines changed

.github/workflows/nightly.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v1
16+
- run: yarn install
17+
18+
# Update all the translation issues on a nightly basis
19+
- run: node packages/typescriptlang-org/scripts/updateGitHubTranslationIssues.ts
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.TS_BOT_TOKEN }}
22+
1623
# Setup Git
1724
- run: git config user.name "typescript-bot"
1825
- run: git config user.email "bot@typescriptlang.org"
@@ -21,5 +28,5 @@ jobs:
2128
env:
2229
GITHUB_TOKEN: ${{ secrets.TS_BOT_TOKEN }}
2330

24-
- run: git commit --no-edit --allow-empty
31+
- run: git commit --allow-empty -m "Nightly Deploy"
2532
- run: git push upstream master:release -f

packages/typescriptlang-org/scripts/makeMarkdownOfTranslations.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@ const { join } = require("path")
22
const fs = require("fs")
33
const path = require("path")
44

5-
const lang = process.argv.slice(2)[0]
6-
if (!lang) {
7-
console.log("You need to run this script with a language arg")
8-
console.log(
9-
"> node packages/typescriptlang-org/scripts/makeMarkdownOfTranslations.js jp"
10-
)
11-
}
12-
13-
const getAllTODOFiles = () => {
5+
const getAllTODOFiles = lang => {
146
const diffFolders = (root, lang) => {
157
const en = join(root, "en")
168
const thisLang = join(root, lang)
@@ -111,5 +103,17 @@ const toMarkdown = files => {
111103
return md.join("\n")
112104
}
113105

114-
const files = getAllTODOFiles()
115-
console.log(toMarkdown(files))
106+
if (!module.parent) {
107+
const lang = process.argv.slice(2)[0]
108+
if (!lang) {
109+
console.log("You need to run this script with a language arg")
110+
console.log(
111+
"> node packages/typescriptlang-org/scripts/makeMarkdownOfTranslations.js jp"
112+
)
113+
}
114+
115+
const files = getAllTODOFiles(lang)
116+
console.log(toMarkdown(files))
117+
}
118+
119+
module.exports = { toMarkdown, getAllTODOFiles }
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// @ts-check
2+
3+
const nodeFetch = require("node-fetch").default
4+
const { writeFileSync, readFileSync } = require("fs")
5+
const { join } = require("path")
6+
const { getAllTODOFiles, toMarkdown } = require("./makeMarkdownOfTranslations")
7+
const Octokit = require("@octokit/rest")
8+
9+
const languages = {
10+
ja: 220,
11+
pt: 233,
12+
es: 232,
13+
}
14+
15+
const go = async () => {
16+
const octokit = Octokit({
17+
auth: process.env.GITHUB_TOKEN,
18+
userAgent: "TS Lang Issue Updater",
19+
})
20+
21+
const langs = Object.keys(languages)
22+
23+
for (let index = 0; index < langs.length; index++) {
24+
const lang = langs[index]
25+
const issueNumber = languages[lang]
26+
27+
const files = getAllTODOFiles(lang)
28+
const body = toMarkdown(files)
29+
30+
await octokit.issues.update({
31+
owner: "Microsoft",
32+
repo: "TypeScript-Website",
33+
issue_number: issueNumber,
34+
body,
35+
})
36+
}
37+
}
38+
39+
go()

0 commit comments

Comments
 (0)