2019-05-06 20:10:03 +10:00
|
|
|
const fs = require("fs")
|
2019-05-26 21:42:52 +10:00
|
|
|
const ver = "Usamin (18.5.0)"
|
2019-05-19 17:39:30 +10:00
|
|
|
const langs = ["ja", "en", "ps"]
|
|
|
|
const langsh = ["日本語", "English", "Crowdin translate system(beta)"]
|
|
|
|
const simples = ["acct", "index", "setting", "update", "setting"]
|
|
|
|
const samples = ["acct.sample.html", "index.sample.html", "setting.sample.html", "update.sample.html", "setting.sample.js"]
|
|
|
|
const pages = ["acct.html", "index.html", "setting.html", "update.html", "setting.vue.js"]
|
|
|
|
let langstr = ""
|
|
|
|
for (let n = 0; n < langs.length; n++) {
|
|
|
|
let lang = langs[n]
|
|
|
|
langstr = langstr + '<a onclick="changelang(\'' + lang + '\')" class="pointer" style="margin-right:5px;">' + langsh[n] + '</a>'
|
2019-05-07 01:42:06 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
for (let i = 0; i < samples.length; i++) {
|
|
|
|
let sample = samples[i]
|
2019-05-07 01:42:06 +10:00
|
|
|
let sourceParent = fs.readFileSync(sample, 'utf8')
|
2019-05-19 17:39:30 +10:00
|
|
|
for (let j = 0; j < langs.length; j++) {
|
|
|
|
let source = sourceParent
|
|
|
|
let lang = langs[j]
|
|
|
|
let target = JSON.parse(fs.readFileSync("language/" + simples[i] + "." + lang + ".json", 'utf8'))
|
|
|
|
Object.keys(target).forEach(function (key) {
|
2019-05-06 20:10:03 +10:00
|
|
|
let str = target[key]
|
|
|
|
var regExp = new RegExp("@@" + key + "@@", "g")
|
2019-05-19 17:39:30 +10:00
|
|
|
source = source.replace(regExp, str)
|
2019-05-06 20:10:03 +10:00
|
|
|
})
|
2019-05-19 17:39:30 +10:00
|
|
|
if (lang == "ps") {
|
2019-05-06 20:10:03 +10:00
|
|
|
source = source.replace(/@@comment-start@@/g, "")
|
|
|
|
source = source.replace(/@@comment-end@@/g, "")
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-05-06 20:10:03 +10:00
|
|
|
source = source.replace(/@@comment-start@@/g, "<!--")
|
|
|
|
source = source.replace(/@@comment-end@@/g, "-->")
|
|
|
|
}
|
|
|
|
source = source.replace(/@@versionLetter@@/g, ver)
|
|
|
|
source = source.replace(/@@lang@@/g, lang)
|
2019-05-07 01:42:06 +10:00
|
|
|
source = source.replace(/@@langlist@@/g, langstr)
|
2019-05-19 17:39:30 +10:00
|
|
|
fs.writeFileSync("../" + lang + "/" + pages[i], source)
|
2019-05-06 20:10:03 +10:00
|
|
|
}
|
|
|
|
}
|