mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 03:32:12 -08:00
cascadable langloader
This commit is contained in:
parent
19d52beb2b
commit
66efac7035
@ -1,11 +1,12 @@
|
||||
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 = 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){
|
||||
@ -29,4 +30,12 @@ exports.queryJS = function(id, placeHolders){
|
||||
|
||||
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')
|
||||
}
|
@ -23,7 +23,7 @@ DistroAPI['commonDir'] = ConfigManager.getCommonDirectory()
|
||||
DistroAPI['instanceDir'] = ConfigManager.getInstanceDirectory()
|
||||
|
||||
// Load Strings
|
||||
LangLoader.loadLanguage('en_US')
|
||||
LangLoader.setupLanguage()
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -738,7 +738,7 @@ let newsLoadingListener = null
|
||||
*/
|
||||
function setNewsLoading(val){
|
||||
if(val){
|
||||
const nLStr = Lang.queryJS('landing.news.loading')
|
||||
const nLStr = Lang.queryJS('landing.news.checking')
|
||||
let dotStr = '..'
|
||||
nELoadSpan.innerHTML = nLStr + dotStr
|
||||
newsLoadingListener = setInterval(() => {
|
||||
|
@ -245,7 +245,7 @@
|
||||
<button class="settingsFileSelButton" id="settingsJavaExecSel" dialogTitle="<%- lang('settings.javaExecSelDialogTitle') %>" dialogDirectory="false"><%- lang('settings.javaExecSelButtonText') %></button>
|
||||
</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 id="settingsJVMOptsContainer">
|
||||
<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 { pathToFileURL } = require('url')
|
||||
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
|
||||
const LangLoader = require('./app/assets/js/langloader')
|
||||
LangLoader.loadLanguage('en_US')
|
||||
LangLoader.setupLanguage()
|
||||
|
||||
// Setup auto updater.
|
||||
function initAutoUpdater(event, data) {
|
||||
|
@ -35,6 +35,7 @@
|
||||
"helios-core": "~2.0.5",
|
||||
"helios-distribution-types": "^1.2.0",
|
||||
"jquery": "^3.7.0",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"semver": "^7.5.4",
|
||||
"toml": "^3.0.0"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user