mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 11:42:14 -08:00
cascadable langloader
This commit is contained in:
parent
19d52beb2b
commit
66efac7035
@ -1,11 +1,12 @@
|
|||||||
const fs = require('fs-extra')
|
const fs = require('fs-extra')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const toml = require('toml')
|
const toml = require('toml')
|
||||||
|
const merge = require('lodash.merge')
|
||||||
|
|
||||||
let lang
|
let lang
|
||||||
|
|
||||||
exports.loadLanguage = function(id){
|
exports.loadLanguage = function(id){
|
||||||
lang = toml.parse(fs.readFileSync(path.join(__dirname, '..', 'lang', `${id}.toml`))) || {}
|
lang = merge(lang || {}, toml.parse(fs.readFileSync(path.join(__dirname, '..', 'lang', `${id}.toml`))) || {})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.query = function(id, placeHolders){
|
exports.query = function(id, placeHolders){
|
||||||
@ -29,4 +30,12 @@ exports.queryJS = function(id, placeHolders){
|
|||||||
|
|
||||||
exports.queryEJS = function(id, placeHolders){
|
exports.queryEJS = function(id, placeHolders){
|
||||||
return exports.query(`ejs.${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')
|
||||||
}
|
}
|
@ -23,7 +23,7 @@ DistroAPI['commonDir'] = ConfigManager.getCommonDirectory()
|
|||||||
DistroAPI['instanceDir'] = ConfigManager.getInstanceDirectory()
|
DistroAPI['instanceDir'] = ConfigManager.getInstanceDirectory()
|
||||||
|
|
||||||
// Load Strings
|
// Load Strings
|
||||||
LangLoader.loadLanguage('en_US')
|
LangLoader.setupLanguage()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -738,7 +738,7 @@ let newsLoadingListener = null
|
|||||||
*/
|
*/
|
||||||
function setNewsLoading(val){
|
function setNewsLoading(val){
|
||||||
if(val){
|
if(val){
|
||||||
const nLStr = Lang.queryJS('landing.news.loading')
|
const nLStr = Lang.queryJS('landing.news.checking')
|
||||||
let dotStr = '..'
|
let dotStr = '..'
|
||||||
nELoadSpan.innerHTML = nLStr + dotStr
|
nELoadSpan.innerHTML = nLStr + dotStr
|
||||||
newsLoadingListener = setInterval(() => {
|
newsLoadingListener = setInterval(() => {
|
||||||
|
@ -245,7 +245,7 @@
|
|||||||
<button class="settingsFileSelButton" id="settingsJavaExecSel" dialogTitle="<%- lang('settings.javaExecSelDialogTitle') %>" dialogDirectory="false"><%- lang('settings.javaExecSelButtonText') %></button>
|
<button class="settingsFileSelButton" id="settingsJavaExecSel" dialogTitle="<%- lang('settings.javaExecSelDialogTitle') %>" dialogDirectory="false"><%- lang('settings.javaExecSelButtonText') %></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="settingsFileSelDesc"><%- lang('settings.javaExecDesc') %> <strong id="settingsJavaReqDesc"><%- lang('settings.javaReqDesc') %></strong><br><%- lang('settings.javaPathDesc', {'pathSuffix': `bin${process.platform === 'win32' ? '\\\\javaw.exe' : '/java'}`}) %></div>
|
<div class="settingsFileSelDesc"><%- lang('settings.javaExecDesc') %> <strong id="settingsJavaReqDesc"><%- lang('settings.javaReqDesc') %></strong><br><%- lang('settings.javaPathDesc', {'pathSuffix': `bin${process.platform === 'win32' ? '\\javaw.exe' : '/java'}`}) %></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="settingsJVMOptsContainer">
|
<div id="settingsJVMOptsContainer">
|
||||||
<div id="settingsJVMOptsTitle"><%- lang('settings.jvmOptsTitle') %></div>
|
<div id="settingsJVMOptsTitle"><%- lang('settings.jvmOptsTitle') %></div>
|
||||||
|
4
index.js
4
index.js
@ -12,10 +12,10 @@ const path = require('path')
|
|||||||
const semver = require('semver')
|
const semver = require('semver')
|
||||||
const { pathToFileURL } = require('url')
|
const { pathToFileURL } = require('url')
|
||||||
const { AZURE_CLIENT_ID, MSFT_OPCODE, MSFT_REPLY_TYPE, MSFT_ERROR, SHELL_OPCODE } = require('./app/assets/js/ipcconstants')
|
const { AZURE_CLIENT_ID, MSFT_OPCODE, MSFT_REPLY_TYPE, MSFT_ERROR, SHELL_OPCODE } = require('./app/assets/js/ipcconstants')
|
||||||
|
const LangLoader = require('./app/assets/js/langloader')
|
||||||
|
|
||||||
// Setup Lang
|
// Setup Lang
|
||||||
const LangLoader = require('./app/assets/js/langloader')
|
LangLoader.setupLanguage()
|
||||||
LangLoader.loadLanguage('en_US')
|
|
||||||
|
|
||||||
// Setup auto updater.
|
// Setup auto updater.
|
||||||
function initAutoUpdater(event, data) {
|
function initAutoUpdater(event, data) {
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
"helios-core": "~2.0.5",
|
"helios-core": "~2.0.5",
|
||||||
"helios-distribution-types": "^1.2.0",
|
"helios-distribution-types": "^1.2.0",
|
||||||
"jquery": "^3.7.0",
|
"jquery": "^3.7.0",
|
||||||
|
"lodash.merge": "^4.6.2",
|
||||||
"semver": "^7.5.4",
|
"semver": "^7.5.4",
|
||||||
"toml": "^3.0.0"
|
"toml": "^3.0.0"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user