Fix transaltions
This commit is contained in:
parent
1f398a8b4c
commit
fffc94fbdd
|
@ -16,6 +16,7 @@ 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 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"]
|
const pages = ["acct.html", "index.html", "setting.html", "update.html", "setting.vue.js"]
|
||||||
let langstr = ""
|
let langstr = ""
|
||||||
|
let refKey = []
|
||||||
for (let n = 0; n < langs.length; n++) {
|
for (let n = 0; n < langs.length; n++) {
|
||||||
let lang = langs[n]
|
let lang = langs[n]
|
||||||
let targetDir = '../' + lang
|
let targetDir = '../' + lang
|
||||||
|
@ -28,16 +29,31 @@ for (let n = 0; n < langs.length; n++) {
|
||||||
for (let i = 0; i < samples.length; i++) {
|
for (let i = 0; i < samples.length; i++) {
|
||||||
let sample = samples[i]
|
let sample = samples[i]
|
||||||
let sourceParent = fs.readFileSync(sample, 'utf8')
|
let sourceParent = fs.readFileSync(sample, 'utf8')
|
||||||
|
let englishRefer = JSON.parse(fs.readFileSync("language/en/" + simples[i] + ".json", 'utf8'))
|
||||||
for (let j = 0; j < langs.length; j++) {
|
for (let j = 0; j < langs.length; j++) {
|
||||||
let source = sourceParent
|
let source = sourceParent
|
||||||
let lang = langs[j]
|
let lang = langs[j]
|
||||||
let target = JSON.parse(fs.readFileSync("language/" + lang + "/" + simples[i] + ".json", 'utf8'))
|
let target = JSON.parse(fs.readFileSync("language/" + lang + "/" + simples[i] + ".json", 'utf8'))
|
||||||
|
if (lang == "ja") {
|
||||||
Object.keys(target).forEach(function (key) {
|
Object.keys(target).forEach(function (key) {
|
||||||
|
refKey.push(key)
|
||||||
let str = target[key]
|
let str = target[key]
|
||||||
str = str.replace(/"/g, '\\"')
|
str = str.replace(/"/g, '\\"')
|
||||||
var regExp = new RegExp("@@" + key + "@@", "g")
|
var regExp = new RegExp("@@" + key + "@@", "g")
|
||||||
source = source.replace(regExp, str)
|
source = source.replace(regExp, str)
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
for (let k = 0; k < refKey.length; k++) {
|
||||||
|
let tarKey = refKey[k]
|
||||||
|
if (target[tarKey]) {
|
||||||
|
var str = target[tarKey]
|
||||||
|
} else {
|
||||||
|
var str = englishRefer[tarKey]
|
||||||
|
}
|
||||||
|
var regExp = new RegExp("@@" + tarKey + "@@", "g")
|
||||||
|
source = source.replace(regExp, str)
|
||||||
|
}
|
||||||
|
}
|
||||||
if (lang == "ps") {
|
if (lang == "ps") {
|
||||||
source = source.replace(/@@comment-start@@/g, "")
|
source = source.replace(/@@comment-start@@/g, "")
|
||||||
source = source.replace(/@@comment-end@@/g, "")
|
source = source.replace(/@@comment-end@@/g, "")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user