-
Notifications
You must be signed in to change notification settings - Fork 32
/
process-languages.js
executable file
·43 lines (33 loc) · 1.17 KB
/
process-languages.js
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
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env node
"use strict";
var fs = require("fs");
var langFiles =
fs
.readdirSync("./lang")
.filter(function(a) { return /\.json$/.test(a); })
.map(function(a) { return "./lang/" + a; });
console.log("<table>");
console.log("<tr><th>Language</th><th>Translator</th><th>Language</th><th>Translator</th></tr>");
var left = false;
console.log(
langFiles
.map(function(fileName) { return fs.readFileSync(fileName, "utf-8"); })
.map(JSON.parse)
.filter(function(json) { return json["credit0-name"]; })
.sort(function(a, b) { return a["language"].localeCompare(b["language"]); })
.map(function(json) {
left = !left;
var ret = (left ? "<tr>" : "") + "<td>" + json["language"] + "</td><td>";
for (var i = 0; json["credit" + i + "-name"]; i ++)
if (json["credit" + i + "-url"])
ret += (i == 0 ? "" : ", ") +
"<a href=\"" + json["credit" + i + "-url"] + "\" target=\"_blank\">" +
json["credit" + i + "-name"] + "</a>";
else
ret += (i == 0 ? "" : ", ") + json["credit" + i + "-name"];
return ret + (left ? "" : "</tr>")
}).join("\n")
);
if (left)
console.log("<td> </td><td> </td></tr>")
console.log("</table>");