forked from dscalzi/HeliosLauncher
-
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.
Merge remote-tracking branch 'refs/remotes/upstream/master'
# Conflicts: # app/app.ejs # app/assets/js/scripts/settings.js # app/frame.ejs # app/landing.ejs # app/login.ejs # app/loginOptions.ejs # app/settings.ejs # app/welcome.ejs # docs/MicrosoftAuth.md # docs/distro.md # electron-builder.yml # package-lock.json # package.json
- Loading branch information
Showing
33 changed files
with
3,177 additions
and
1,095 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 +1 @@ | ||
18 | ||
20 |
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
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
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,43 @@ | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const toml = require('toml') | ||
const merge = require('lodash.merge') | ||
|
||
let lang | ||
|
||
exports.loadLanguage = function(id){ | ||
lang = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'lang', `${id}.json`))) || {} | ||
lang = merge(lang || {}, toml.parse(fs.readFileSync(path.join(__dirname, '..', 'lang', `${id}.toml`))) || {}) | ||
} | ||
|
||
exports.query = function(id){ | ||
exports.query = function(id, placeHolders){ | ||
let query = id.split('.') | ||
let res = lang | ||
for(let q of query){ | ||
res = res[q] | ||
} | ||
return res === lang ? {} : res | ||
let text = res === lang ? '' : res | ||
if (placeHolders) { | ||
Object.entries(placeHolders).forEach(([key, value]) => { | ||
text = text.replace(`{${key}}`, value) | ||
}) | ||
} | ||
return text | ||
} | ||
|
||
exports.queryJS = function(id, placeHolders){ | ||
return exports.query(`js.${id}`, placeHolders) | ||
} | ||
|
||
exports.queryJS = function(id){ | ||
return exports.query(`js.${id}`) | ||
exports.queryEJS = function(id, placeHolders){ | ||
return exports.query(`ejs.${id}`, placeHolders) | ||
} | ||
|
||
exports.setupLanguage = function(){ | ||
// Load Language Files | ||
exports.loadLanguage('en_US') | ||
// Uncomment this when translations are ready | ||
//exports.loadLanguage('xx_XX') | ||
|
||
// Load Custom Language File for Launcher Customizer | ||
exports.loadLanguage('_custom') | ||
} |
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
Oops, something went wrong.