-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c03ea67
commit 1c32b4d
Showing
9 changed files
with
131 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
exports.filePath = "./dist/hash.json"; | ||
exports.fileName = "hash.json"; | ||
exports.fileName = "hash.json"; | ||
exports.messagePath = "src/message.json"; | ||
exports.supportedLanguages = [ | ||
"en-US" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
const xml2js = require('xml2js'); | ||
const fs = require('fs'); | ||
const { messagePath, supportedLanguages } = require('./config'); | ||
|
||
const parser = new xml2js.Parser({ attrkey: "ATTR" }); | ||
|
||
function existsPath(path) { | ||
return new Promise((resolve) => { | ||
fs.exists(path, resolve); | ||
}); | ||
} | ||
|
||
function parseFile(result) { | ||
const { root: { data } } = result; | ||
const Resource = data.reduce((curr, { ATTR: { name }, value }) => { | ||
curr[name] = value[0]; | ||
return curr; | ||
}, {}); | ||
|
||
return { | ||
Resource | ||
}; | ||
} | ||
|
||
function getLanguageFromPath(path) { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(path, { encoding: 'utf-8' }, (error, file) => { | ||
if (error !== null) { | ||
reject(error); | ||
return; | ||
} | ||
|
||
parser.parseString(file, function (parseError, file) { | ||
if (parseError !== null) { | ||
reject(parseError); | ||
return; | ||
} | ||
const data = parseFile(file); | ||
resolve(data); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
async function getLanguage(language, defaultValue) { | ||
const path = `../Resource.${language}.resx`; | ||
const exists = await existsPath(path); | ||
if (!exists) { | ||
return { ...defaultValue }; | ||
} | ||
const data = await getLanguageFromPath(path); | ||
const result = Object.assign({}, defaultValue, data); | ||
return result; | ||
} | ||
|
||
async function createMessage() { | ||
const messages = {}; | ||
const defaultValue = await getLanguageFromPath("../Resource.resx"); | ||
|
||
for (const language of supportedLanguages) { | ||
const result = await getLanguage(language, defaultValue); | ||
messages[language] = result; | ||
} | ||
return messages; | ||
} | ||
|
||
async function updateMessage() { | ||
const file = await createMessage(); | ||
fs.writeFile(messagePath, JSON.stringify(file, null, 2), function (err) { | ||
if (err) { | ||
console.log(err); | ||
return; | ||
} | ||
console.log("updated message JSON file"); | ||
}); | ||
} | ||
|
||
updateMessage(); |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
{ | ||
"en-US":{ | ||
"Resource":{ | ||
"About1":"Complete Neutronium Vue Demo", | ||
"About2":"Including Ioc, navigation (vue-router) internalization (vue-i18n) and chromeless window", | ||
"About3":"Made with vuetify framework", | ||
"Cancel":"Cancel", | ||
"Completed":"Completed", | ||
"ConfirmationNeeded":"Confirmation needed", | ||
"DoYouWantToCloseApplication":"Do you want to close application?", | ||
"DoYouWantToRestartApplication":"Do you want to restart application?", | ||
"GoToAboutSection":"Go To About Section", | ||
"MadeBy":"made by", | ||
"Menu_about":"About", | ||
"Menu_main":"Main", | ||
"Ok":"Ok", | ||
"ProjectDescription":"Neutronium Vue SPA Template including IoC, routing and internalization", | ||
"Restart":"Restart" | ||
} | ||
{ | ||
"en-US": { | ||
"Resource": { | ||
"About1": "Complete Neutronium Vue Demo", | ||
"About2": "Including Ioc, navigation (vue-router) internalization (vue-i18n) and chromeless window", | ||
"About3": "Made with vuetify framework", | ||
"Cancel": "Cancel", | ||
"Completed": "Completed", | ||
"ConfirmationNeeded": "Confirmation needed", | ||
"DoYouWantToCloseApplication": "Do you want to close application?", | ||
"DoYouWantToRestartApplication": "Do you want to restart application?", | ||
"GoToAboutSection": "Go To About Section", | ||
"MadeBy": "made by", | ||
"Menu_about": "About", | ||
"Menu_main": "Main", | ||
"Ok": "Ok", | ||
"ProjectDescription": "Neutronium Vue SPA Template including IoC, routing and internalization", | ||
"Restart": "Restart" | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.