Compare commits

...

4 Commits

Author SHA1 Message Date
Kamesuta
490119987a move some placeholder text to _placeholder.toml 2023-09-27 03:52:36 +09:00
Kamesuta
d2aba8cf5c separate lang file for customization 2023-09-27 03:10:49 +09:00
Kamesuta
66efac7035 cascadable langloader 2023-09-27 02:25:35 +09:00
Kamesuta
19d52beb2b Fix mojang/microsoft status icon is undefined 2023-09-27 00:28:33 +09:00
11 changed files with 70 additions and 39 deletions

View File

@ -1,7 +1,7 @@
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" http-equiv="Content-Security-Policy" content="script-src 'self' 'sha256-In6B8teKZQll5heMl9bS7CESTbGvuAt3VVV86BUQBDk='"/>
<title>Helios Launcher</title>
<title><%= lang('app.title') %></title>
<script src="./assets/js/scripts/uicore.js"></script>
<script src="./assets/js/scripts/uibinder.js"></script>
<link type="text/css" rel="stylesheet" href="./assets/css/launcher.css">

View File

@ -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){
@ -30,3 +31,16 @@ exports.queryJS = function(id, placeHolders){
exports.queryEJS = function(id, placeHolders){
return exports.query(`ejs.${id}`, placeHolders)
}
exports.setupLanguage = function(){
// Load a Placeholder Language File for texts that do not require translation
exports.loadLanguage('_placeholder')
// 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')
}

View File

@ -23,7 +23,7 @@ DistroAPI['commonDir'] = ConfigManager.getCommonDirectory()
DistroAPI['instanceDir'] = ConfigManager.getInstanceDirectory()
// Load Strings
LangLoader.loadLanguage('en_US')
LangLoader.setupLanguage()
/**
*

View File

@ -202,7 +202,7 @@ const refreshMojangStatuses = async function(){
const service = statuses[i]
const tooltipHTML = `<div class="mojangStatusContainer">
<span class="mojangStatusIcon" style="color: ${MojangRestAPI.statusToHex(service.status)};">${Lang.queryEJS('landing.mojangStatus.icon')}</span>
<span class="mojangStatusIcon" style="color: ${MojangRestAPI.statusToHex(service.status)};">${Lang.queryJS('landing.mojangStatus.icon')}</span>
<span class="mojangStatusName">${service.name}</span>
</div>`
if(service.essential){
@ -335,7 +335,7 @@ async function asyncSystemScan(effectiveJavaOptions, launchAfter = true){
$('#overlayContent').fadeOut(250, () => {
//$('#overlayDismiss').toggle(false)
setOverlayContent(
Lang.queryJS('landing.systemScan.javaRequired'),
Lang.queryJS('landing.systemScan.javaRequired', { 'major': effectiveJavaOptions.suggestedMajor }),
Lang.queryJS('landing.systemScan.javaRequiredMessage', { 'major': effectiveJavaOptions.suggestedMajor }),
Lang.queryJS('landing.systemScan.javaRequiredDismiss'),
Lang.queryJS('landing.systemScan.javaRequiredCancel')
@ -621,7 +621,7 @@ async function dlAsync(login = true) {
DiscordWrapper.initRPC(distro.rawDistribution.discord, serv.rawServer.discord)
hasRPC = true
proc.on('close', (code, signal) => {
loggerLaunchSuite.info(Lang.queryJS('landing.dlAsync.shuttingDownRPC'))
loggerLaunchSuite.info('Shutting down Discord Rich Presence..')
DiscordWrapper.shutdownRPC()
hasRPC = false
proc = null
@ -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(() => {

View File

@ -0,0 +1,20 @@
# Custom Language File for Launcher Customizer
[ejs.app]
title = "Helios Launcher"
[ejs.landing]
mediaGitHubURL = "https://github.com/dscalzi/HeliosLauncher"
mediaTwitterURL = "#"
mediaInstagramURL = "#"
mediaYouTubeURL = "#"
mediaDiscordURL = "https://discord.gg/zNWUXdt"
[ejs.settings]
sourceGithubLink = "https://github.com/dscalZi/HeliosLauncher"
supportLink = "https://github.com/dscalZi/HeliosLauncher/issues"
[ejs.welcome]
welcomeHeader = "WELCOME TO WESTEROSCRAFT"
welcomeDescription = "Our mission is to recreate the universe imagined by author George RR Martin in his fantasy series, A Song of Ice and Fire. Through the collaborative effort of thousands of community members, we have sought to create Westeros as accurately and precisely as possible within Minecraft. The world we are creating is yours to explore. Journey from Dorne to Castle Black, and if you arent afraid, beyond the Wall itself, but best not delay. As the words of House Stark ominously warn: Winter is Coming."
welcomeDescCTA = "You are just a few clicks away from Westeros."

View File

@ -0,0 +1,19 @@
# Placeholder Language File for texts that do not require translation
[ejs.landing]
newsArticleTitle = "Lorem Ipsum"
newsArticleDate = "Mar 15, 44 BC, 9:14 AM"
newsArticleAuthor = "by Cicero"
newsArticleComments = "0 Comments"
[ejs.overlay]
overlayTitle = "Lorem Ipsum:<br>Finis Illud"
overlayDesc = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.."
overlayAcknowledge = "Conare Iterum"
overlayDismiss = "Dismiss"
[ejs.settings]
versionValue = "0.0.1-alpha.18"
memoryTotalValue = "16G"
memoryAvailableValue = "7.3G"
javaExecVal = "null"

View File

@ -3,11 +3,6 @@ updateAvailableTooltip = "Update Available"
usernamePlaceholder = "Username"
usernameEditButton = "Edit"
settingsTooltip = "Settings"
mediaGitHubURL = "https://github.com/dscalzi/HeliosLauncher"
mediaTwitterURL = "#"
mediaInstagramURL = "#"
mediaYouTubeURL = "#"
mediaDiscordURL = "https://discord.gg/zNWUXdt"
serverStatus = "SERVER"
serverStatusPlaceholder = "OFFLINE"
mojangStatus = "MOJANG STATUS"
@ -19,10 +14,6 @@ launchButton = "PLAY"
launchButtonPlaceholder = "&#8226; No Server Selected"
launchProgressLabel = "0%"
launchDetails = "Please wait.."
newsArticleTitle = "Lorem Ipsum"
newsArticleDate = "Mar 15, 44 BC, 9:14 AM"
newsArticleAuthor = "by Cicero"
newsArticleComments = "0 Comments"
newsNavigationStatus = "1 of 1"
newsErrorLoadSpan = "Checking for News.."
newsErrorFailedSpan = "Failed to Load News"
@ -44,7 +35,7 @@ loginButtonText = "LOGIN"
loginNeedAccountLink = "https://minecraft.net/store/minecraft-java-edition/"
loginNeedAccountText = "Need an Account?"
loginPasswordDisclaimer1 = "Your password is sent directly to mojang and never stored."
loginPasswordDisclaimer2 = "Helios Launcher is not affiliated with Mojang AB."
loginPasswordDisclaimer2 = "<%= lang('app.title') %> is not affiliated with Mojang AB."
[ejs.loginOptions]
loginOptionsTitle = "Login Options"
@ -59,10 +50,6 @@ serverSelectCancel = "Cancel"
accountSelectHeader = "Select an Account"
accountSelectConfirm = "Select"
accountSelectCancel = "Cancel"
overlayTitle = "Lorem Ipsum:<br>Finis Illud"
overlayDesc = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.."
overlayAcknowledge = "Conare Iterum"
overlayDismiss = "Dismiss"
[ejs.settings]
navHeaderText = "Settings"
@ -107,12 +94,9 @@ maxRAM = "Maximum RAM"
minRAM = "Minimum RAM"
memoryDesc = "The recommended minimum RAM is 3 gigabytes. Setting the minimum and maximum values to the same value may reduce lag."
memoryTotalTitle = "Total"
memoryTotalValue = "16G"
memoryAvailableTitle = "Available"
memoryAvailableValue = "7.3G"
javaExecutableTitle = "Java Executable"
javaExecDetails = "Selected: Java 8 Update 172 (x64)"
javaExecVal = "null"
javaExecSelDialogTitle = "Select Java Executable"
javaExecSelButtonText = "Choose File"
javaExecDesc = "The Java executable is validated before game launch."
@ -132,16 +116,13 @@ chooseFolder = "Choose Folder"
dataDirectoryDesc = "All game files and local Java installations will be stored in the data directory.<br>Screenshots and world saves are stored in the instance folder for the corresponding server configuration."
aboutTabHeaderText = "About"
aboutTabHeaderDesc = "View information and release notes for the current version."
aboutTitle = "Helios Launcher"
aboutTitle = "<%= lang('app.title') %>"
aboutCurrentVersionCheck = "Stable Release"
versionCheck = "&#10003;"
stableRelease = "Stable Release"
versionText = "Version "
versionValue = "0.0.1-alpha.18"
sourceGithub = "Source (GitHub)"
sourceGithubLink = "https://github.com/dscalZi/HeliosLauncher"
support = "Support"
supportLink = "https://github.com/dscalZi/HeliosLauncher/issues"
devToolsConsole = "DevTools Console"
releaseNotes = "Release Notes"
changelog = "Changelog"
@ -158,9 +139,6 @@ updateReleaseNotes = "Update Release Notes"
waitingText = "Waiting for Microsoft.."
[ejs.welcome]
welcomeHeader = "WELCOME TO WESTEROSCRAFT"
welcomeDescription = "Our mission is to recreate the universe imagined by author George RR Martin in his fantasy series, A Song of Ice and Fire. Through the collaborative effort of thousands of community members, we have sought to create Westeros as accurately and precisely as possible within Minecraft. The world we are creating is yours to explore. Journey from Dorne to Castle Black, and if you arent afraid, beyond the Wall itself, but best not delay. As the words of House Stark ominously warn: Winter is Coming."
welcomeDescCTA = "You are just a few clicks away from Westeros."
continueButton = "CONTINUE"
@ -203,7 +181,7 @@ players = "PLAYERS"
[js.landing.systemScan]
checking = "Checking system info.."
noCompatibleJava = "No Compatible<br>Java Installation Found"
installJavaMessage = "In order to join WesterosCraft, you need a 64-bit installation of Java {major}. Would you like us to install a copy?"
installJavaMessage = "In order to launch Minecraft, you need a 64-bit installation of Java {major}. Would you like us to install a copy?"
installJava = "Install Java"
installJavaManually = "Install Manually"
javaDownloadPrepare = "Preparing Java Download.."
@ -235,7 +213,6 @@ preparingToLaunch = "Preparing to launch.."
launchingGame = "Launching game.."
launchWrapperNotDownloaded = "The main file, LaunchWrapper, failed to download properly. As a result, the game cannot launch.<br><br>To fix this issue, temporarily turn off your antivirus software and launch the game again.<br><br>If you have time, please <a href=\"https://github.com/dscalzi/HeliosLauncher/issues\">submit an issue</a> and let us know what antivirus software you use. We'll contact them and try to straighten things out."
doneEnjoyServer = "Done. Enjoy the server!"
shuttingDownRPC = "Shutting down Discord Rich Presence.."
checkConsoleForDetails = "Please check the console (CTRL + Shift + i) for more details."
[js.landing.news]

View File

@ -13,7 +13,7 @@
<% } else{ %>
<div id="frameContentWin">
<div id="frameTitleDock">
<span id="frameTitleText">Helios Launcher</span>
<span id="frameTitleText"><%= lang('app.title') %></span>
</div>
<div id="frameButtonDockWin">
<button class="frameButton fMb" id="frameButton_minimize" tabIndex="-1">

View File

@ -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>
@ -266,7 +266,7 @@
</div>
<input id="settingsJVMOptsVal" cValue="JVMOptions" serverDependent type="text">
</div>
<div id="settingsJVMOptsDesc"><%- lang('settings.jvmOptsDesc') %><br><a href="<%- lang('settings.jvmOptsLink') %>" id="settingsJvmOptsLink"><%- evalEjs(lang('settings.jvmOptsLinkText')) %></a></div>
<div id="settingsJVMOptsDesc"><%- lang('settings.jvmOptsDesc') %><br><a href="<%- lang('settings.jvmOptsLink') %>" id="settingsJvmOptsLink"><%- lang('settings.jvmOptsLinkText') %></a></div>
</div>
</div>
<div id="settingsTabLauncher" class="settingsTab" style="display: none;">

View File

@ -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) {
@ -243,7 +243,7 @@ function createWindow() {
const data = {
bkid: Math.floor((Math.random() * fs.readdirSync(path.join(__dirname, 'app', 'assets', 'images', 'backgrounds')).length)),
lang: LangLoader.queryEJS,
lang: (str) => ejs.render(LangLoader.queryEJS(str), data),
evalEjs: (str) => ejs.render(str, data)
}
Object.entries(data).forEach(([key, val]) => ejse.data(key, val))

View File

@ -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"
},