i18n for landing.js

This commit is contained in:
Kamesuta 2023-09-02 13:47:41 +09:00
parent 10742f7786
commit 747af279d3
2 changed files with 106 additions and 48 deletions

View File

@ -125,7 +125,7 @@ document.getElementById('launch_button').addEventListener('click', async e => {
} }
} catch(err) { } catch(err) {
loggerLanding.error('Unhandled error in during launch process.', err) loggerLanding.error('Unhandled error in during launch process.', err)
showLaunchFailure('Error During Launch', 'See console (CTRL + Shift + i) for more details.') showLaunchFailure(Lang.queryJS('landing.launch.failureTitle'), Lang.queryJS('landing.launch.failureText'))
} }
}) })
@ -145,7 +145,7 @@ document.getElementById('avatarOverlay').onclick = async e => {
// Bind selected account // Bind selected account
function updateSelectedAccount(authUser){ function updateSelectedAccount(authUser){
let username = 'No Account Selected' let username = Lang.queryJS('landing.selectedAccount.noAccountSelected')
if(authUser != null){ if(authUser != null){
if(authUser.displayName != null){ if(authUser.displayName != null){
username = authUser.displayName username = authUser.displayName
@ -165,14 +165,14 @@ function updateSelectedServer(serv){
} }
ConfigManager.setSelectedServer(serv != null ? serv.rawServer.id : null) ConfigManager.setSelectedServer(serv != null ? serv.rawServer.id : null)
ConfigManager.save() ConfigManager.save()
server_selection_button.innerHTML = '\u2022 ' + (serv != null ? serv.rawServer.name : 'No Server Selected') server_selection_button.innerHTML = Lang.queryJS('landing.selectedServer.icon') + (serv != null ? serv.rawServer.name : Lang.queryJS('landing.noSelection'))
if(getCurrentView() === VIEWS.settings){ if(getCurrentView() === VIEWS.settings){
animateSettingsTabRefresh() animateSettingsTabRefresh()
} }
setLaunchEnabled(serv != null) setLaunchEnabled(serv != null)
} }
// Real text is set in uibinder.js on distributionIndexDone. // Real text is set in uibinder.js on distributionIndexDone.
server_selection_button.innerHTML = '\u2022 Loading..' server_selection_button.innerHTML = Lang.queryJS('landing.selectedServer.icon') + Lang.queryJS('landing.selectedServer.loading')
server_selection_button.onclick = async e => { server_selection_button.onclick = async e => {
e.target.blur() e.target.blur()
await toggleServerSelection(true) await toggleServerSelection(true)
@ -201,16 +201,14 @@ const refreshMojangStatuses = async function(){
for(let i=0; i<statuses.length; i++){ for(let i=0; i<statuses.length; i++){
const service = statuses[i] 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="mojangStatusName">${service.name}</span>
</div>`
if(service.essential){ if(service.essential){
tooltipEssentialHTML += `<div class="mojangStatusContainer"> tooltipEssentialHTML += tooltipHTML
<span class="mojangStatusIcon" style="color: ${MojangRestAPI.statusToHex(service.status)};">&#8226;</span>
<span class="mojangStatusName">${service.name}</span>
</div>`
} else { } else {
tooltipNonEssentialHTML += `<div class="mojangStatusContainer"> tooltipNonEssentialHTML += tooltipHTML
<span class="mojangStatusIcon" style="color: ${MojangRestAPI.statusToHex(service.status)};">&#8226;</span>
<span class="mojangStatusName">${service.name}</span>
</div>`
} }
if(service.status === 'yellow' && status !== 'red'){ if(service.status === 'yellow' && status !== 'red'){
@ -243,14 +241,14 @@ const refreshServerStatus = async (fade = false) => {
loggerLanding.info('Refreshing Server Status') loggerLanding.info('Refreshing Server Status')
const serv = (await DistroAPI.getDistribution()).getServerById(ConfigManager.getSelectedServer()) const serv = (await DistroAPI.getDistribution()).getServerById(ConfigManager.getSelectedServer())
let pLabel = 'SERVER' let pLabel = Lang.queryJS('landing.serverStatus.server')
let pVal = 'OFFLINE' let pVal = Lang.queryJS('landing.serverStatus.offline')
try { try {
const servStat = await getServerStatus(47, serv.hostname, serv.port) const servStat = await getServerStatus(47, serv.hostname, serv.port)
console.log(servStat) console.log(servStat)
pLabel = 'PLAYERS' pLabel = Lang.queryJS('landing.serverStatus.players')
pVal = servStat.players.online + '/' + servStat.players.max pVal = servStat.players.online + '/' + servStat.players.max
} catch (err) { } catch (err) {
@ -288,7 +286,7 @@ function showLaunchFailure(title, desc){
setOverlayContent( setOverlayContent(
title, title,
desc, desc,
'Okay' Lang.queryJS('landing.launch.okay')
) )
setOverlayHandler(null) setOverlayHandler(null)
toggleOverlay(true) toggleOverlay(true)
@ -304,7 +302,7 @@ function showLaunchFailure(title, desc){
*/ */
async function asyncSystemScan(effectiveJavaOptions, launchAfter = true){ async function asyncSystemScan(effectiveJavaOptions, launchAfter = true){
setLaunchDetails('Checking system info..') setLaunchDetails(Lang.queryJS('landing.systemScan.checking'))
toggleLaunchArea(true) toggleLaunchArea(true)
setLaunchPercentage(0, 100) setLaunchPercentage(0, 100)
@ -317,30 +315,30 @@ async function asyncSystemScan(effectiveJavaOptions, launchAfter = true){
// If the result is null, no valid Java installation was found. // If the result is null, no valid Java installation was found.
// Show this information to the user. // Show this information to the user.
setOverlayContent( setOverlayContent(
'No Compatible<br>Java Installation Found', Lang.queryJS('landing.systemScan.noCompatibleJava'),
`In order to join WesterosCraft, you need a 64-bit installation of Java ${effectiveJavaOptions.suggestedMajor}. Would you like us to install a copy?`, Lang.queryJS('landing.systemScan.installJavaMessage', { 'suggestedMajor': effectiveJavaOptions.suggestedMajor }),
'Install Java', Lang.queryJS('landing.systemScan.installJava'),
'Install Manually' Lang.queryJS('landing.systemScan.installJavaManually')
) )
setOverlayHandler(() => { setOverlayHandler(() => {
setLaunchDetails('Preparing Java Download..') setLaunchDetails(Lang.queryJS('landing.systemScan.javaDownloadPrepare'))
toggleOverlay(false) toggleOverlay(false)
try { try {
downloadJava(effectiveJavaOptions, launchAfter) downloadJava(effectiveJavaOptions, launchAfter)
} catch(err) { } catch(err) {
loggerLanding.error('Unhandled error in Java Download', err) loggerLanding.error('Unhandled error in Java Download', err)
showLaunchFailure('Error During Java Download', 'See console (CTRL + Shift + i) for more details.') showLaunchFailure(Lang.queryJS('landing.systemScan.javaDownloadFailureTitle'), Lang.queryJS('landing.systemScan.javaDownloadFailureText'))
} }
}) })
setDismissHandler(() => { setDismissHandler(() => {
$('#overlayContent').fadeOut(250, () => { $('#overlayContent').fadeOut(250, () => {
//$('#overlayDismiss').toggle(false) //$('#overlayDismiss').toggle(false)
setOverlayContent( setOverlayContent(
'Java is Required<br>to Launch', Lang.queryJS('landing.systemScan.javaRequired'),
`A valid x64 installation of Java ${effectiveJavaOptions.suggestedMajor} is required to launch.<br><br>Please refer to our <a href="https://github.com/dscalzi/HeliosLauncher/wiki/Java-Management#manually-installing-a-valid-version-of-java">Java Management Guide</a> for instructions on how to manually install Java.`, Lang.queryJS('landing.systemScan.javaRequiredMessage', { 'suggestedMajor': effectiveJavaOptions.suggestedMajor }),
'I Understand', Lang.queryJS('landing.systemScan.javaRequiredDismiss'),
'Go Back' Lang.queryJS('landing.systemScan.javaRequiredCancel')
) )
setOverlayHandler(() => { setOverlayHandler(() => {
toggleLaunchArea(false) toggleLaunchArea(false)
@ -385,7 +383,7 @@ async function downloadJava(effectiveJavaOptions, launchAfter = true) {
effectiveJavaOptions.distribution) effectiveJavaOptions.distribution)
if(asset == null) { if(asset == null) {
throw new Error('Failed to find OpenJDK distribution.') throw new Error(Lang.queryJS('landing.downloadJava.findJdkFailure'))
} }
let received = 0 let received = 0
@ -400,7 +398,7 @@ async function downloadJava(effectiveJavaOptions, launchAfter = true) {
if(!await validateLocalFile(asset.path, asset.algo, asset.hash)) { if(!await validateLocalFile(asset.path, asset.algo, asset.hash)) {
log.error(`Hashes do not match, ${asset.id} may be corrupted.`) log.error(`Hashes do not match, ${asset.id} may be corrupted.`)
// Don't know how this could happen, but report it. // Don't know how this could happen, but report it.
throw new Error('Downloaded JDK has bad hash, file may be corrupted.') throw new Error(Lang.queryJS('landing.downloadJava.javaDownloadCorruptedError'))
} }
} }
@ -409,7 +407,7 @@ async function downloadJava(effectiveJavaOptions, launchAfter = true) {
remote.getCurrentWindow().setProgressBar(2) remote.getCurrentWindow().setProgressBar(2)
// Wait for extration to complete. // Wait for extration to complete.
const eLStr = 'Extracting Java' const eLStr = Lang.queryJS('landing.downloadJava.extractingJava')
let dotStr = '' let dotStr = ''
setLaunchDetails(eLStr) setLaunchDetails(eLStr)
const extractListener = setInterval(() => { const extractListener = setInterval(() => {
@ -431,7 +429,7 @@ async function downloadJava(effectiveJavaOptions, launchAfter = true) {
ConfigManager.save() ConfigManager.save()
clearInterval(extractListener) clearInterval(extractListener)
setLaunchDetails('Java Installed!') setLaunchDetails(Lang.queryJS('landing.downloadJava.javaInstalled'))
// TODO Callback hell // TODO Callback hell
// Refactor the launch functions // Refactor the launch functions
@ -456,7 +454,7 @@ async function dlAsync(login = true) {
const loggerLaunchSuite = LoggerUtil.getLogger('LaunchSuite') const loggerLaunchSuite = LoggerUtil.getLogger('LaunchSuite')
setLaunchDetails('Loading server information..') setLaunchDetails(Lang.queryJS('landing.dlAsync.loadingServerInfo'))
let distro let distro
@ -465,7 +463,7 @@ async function dlAsync(login = true) {
onDistroRefresh(distro) onDistroRefresh(distro)
} catch(err) { } catch(err) {
loggerLaunchSuite.error('Unable to refresh distribution index.', err) loggerLaunchSuite.error('Unable to refresh distribution index.', err)
showLaunchFailure('Fatal Error', 'Could not load a copy of the distribution index. See the console (CTRL + Shift + i) for more details.') showLaunchFailure(Lang.queryJS('landing.dlAsync.fatalError'), Lang.queryJS('landing.dlAsync.unableToLoadDistributionIndex'))
return return
} }
@ -478,7 +476,7 @@ async function dlAsync(login = true) {
} }
} }
setLaunchDetails('Please wait..') setLaunchDetails(Lang.queryJS('landing.dlAsync.pleaseWait'))
toggleLaunchArea(true) toggleLaunchArea(true)
setLaunchPercentage(0, 100) setLaunchPercentage(0, 100)
@ -494,17 +492,17 @@ async function dlAsync(login = true) {
fullRepairModule.childProcess.on('error', (err) => { fullRepairModule.childProcess.on('error', (err) => {
loggerLaunchSuite.error('Error during launch', err) loggerLaunchSuite.error('Error during launch', err)
showLaunchFailure('Error During Launch', err.message || 'See console (CTRL + Shift + i) for more details.') showLaunchFailure(Lang.queryJS('landing.dlAsync.errorDuringLaunchTitle'), err.message || Lang.queryJS('landing.dlAsync.errorDuringLaunchText'))
}) })
fullRepairModule.childProcess.on('close', (code, _signal) => { fullRepairModule.childProcess.on('close', (code, _signal) => {
if(code !== 0){ if(code !== 0){
loggerLaunchSuite.error(`Full Repair Module exited with code ${code}, assuming error.`) loggerLaunchSuite.error(`Full Repair Module exited with code ${code}, assuming error.`)
showLaunchFailure('Error During Launch', 'See console (CTRL + Shift + i) for more details.') showLaunchFailure(Lang.queryJS('landing.dlAsync.errorDuringLaunchTitle'), Lang.queryJS('landing.dlAsync.seeConsoleForDetails'))
} }
}) })
loggerLaunchSuite.info('Validating files.') loggerLaunchSuite.info('Validating files.')
setLaunchDetails('Validating file integrity..') setLaunchDetails(Lang.queryJS('landing.dlAsync.validatingFileIntegrity'))
let invalidFileCount = 0 let invalidFileCount = 0
try { try {
invalidFileCount = await fullRepairModule.verifyFiles(percent => { invalidFileCount = await fullRepairModule.verifyFiles(percent => {
@ -513,14 +511,14 @@ async function dlAsync(login = true) {
setLaunchPercentage(100) setLaunchPercentage(100)
} catch (err) { } catch (err) {
loggerLaunchSuite.error('Error during file validation.') loggerLaunchSuite.error('Error during file validation.')
showLaunchFailure('Error During File Verification', err.displayable || 'See console (CTRL + Shift + i) for more details.') showLaunchFailure(Lang.queryJS('landing.dlAsync.errorDuringFileVerificationTitle'), err.displayable || Lang.queryJS('landing.dlAsync.seeConsoleForDetails'))
return return
} }
if(invalidFileCount > 0) { if(invalidFileCount > 0) {
loggerLaunchSuite.info('Downloading files.') loggerLaunchSuite.info('Downloading files.')
setLaunchDetails('Downloading files..') setLaunchDetails(Lang.queryJS('landing.dlAsync.downloadingFiles'))
setLaunchPercentage(0) setLaunchPercentage(0)
try { try {
await fullRepairModule.download(percent => { await fullRepairModule.download(percent => {
@ -529,7 +527,7 @@ async function dlAsync(login = true) {
setDownloadPercentage(100) setDownloadPercentage(100)
} catch(err) { } catch(err) {
loggerLaunchSuite.error('Error during file download.') loggerLaunchSuite.error('Error during file download.')
showLaunchFailure('Error During File Download', err.displayable || 'See console (CTRL + Shift + i) for more details.') showLaunchFailure(Lang.queryJS('landing.dlAsync.errorDuringFileDownloadTitle'), err.displayable || Lang.queryJS('landing.dlAsync.seeConsoleForDetails'))
return return
} }
} else { } else {
@ -541,7 +539,7 @@ async function dlAsync(login = true) {
fullRepairModule.destroyReceiver() fullRepairModule.destroyReceiver()
setLaunchDetails('Preparing to launch..') setLaunchDetails(Lang.queryJS('landing.dlAsync.preparingToLaunch'))
const mojangIndexProcessor = new MojangIndexProcessor( const mojangIndexProcessor = new MojangIndexProcessor(
ConfigManager.getCommonDirectory(), ConfigManager.getCommonDirectory(),
@ -559,7 +557,7 @@ async function dlAsync(login = true) {
const authUser = ConfigManager.getSelectedAccount() const authUser = ConfigManager.getSelectedAccount()
loggerLaunchSuite.info(`Sending selected account (${authUser.displayName}) to ProcessBuilder.`) loggerLaunchSuite.info(`Sending selected account (${authUser.displayName}) to ProcessBuilder.`)
let pb = new ProcessBuilder(serv, versionData, forgeData, authUser, remote.app.getVersion()) let pb = new ProcessBuilder(serv, versionData, forgeData, authUser, remote.app.getVersion())
setLaunchDetails('Launching game..') setLaunchDetails(Lang.queryJS('landing.dlAsync.launchingGame'))
// const SERVER_JOINED_REGEX = /\[.+\]: \[CHAT\] [a-zA-Z0-9_]{1,16} joined the game/ // const SERVER_JOINED_REGEX = /\[.+\]: \[CHAT\] [a-zA-Z0-9_]{1,16} joined the game/
const SERVER_JOINED_REGEX = new RegExp(`\\[.+\\]: \\[CHAT\\] ${authUser.displayName} joined the game`) const SERVER_JOINED_REGEX = new RegExp(`\\[.+\\]: \\[CHAT\\] ${authUser.displayName} joined the game`)
@ -604,7 +602,7 @@ async function dlAsync(login = true) {
data = data.trim() data = data.trim()
if(data.indexOf('Could not find or load main class net.minecraft.launchwrapper.Launch') > -1){ if(data.indexOf('Could not find or load main class net.minecraft.launchwrapper.Launch') > -1){
loggerLaunchSuite.error('Game launch failed, LaunchWrapper was not downloaded properly.') loggerLaunchSuite.error('Game launch failed, LaunchWrapper was not downloaded properly.')
showLaunchFailure('Error During Launch', '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.') showLaunchFailure(Lang.queryJS('landing.dlAsync.errorDuringLaunchTitle'), Lang.queryJS('landing.dlAsync.launchWrapperNotDownloaded'))
} }
} }
@ -616,14 +614,14 @@ async function dlAsync(login = true) {
proc.stdout.on('data', tempListener) proc.stdout.on('data', tempListener)
proc.stderr.on('data', gameErrorListener) proc.stderr.on('data', gameErrorListener)
setLaunchDetails('Done. Enjoy the server!') setLaunchDetails(Lang.queryJS('landing.dlAsync.doneEnjoyServer'))
// Init Discord Hook // Init Discord Hook
if(distro.rawDistribution.discord != null && serv.rawServerdiscord != null){ if(distro.rawDistribution.discord != null && serv.rawServerdiscord != null){
DiscordWrapper.initRPC(distro.rawDistribution.discord, serv.rawServer.discord) DiscordWrapper.initRPC(distro.rawDistribution.discord, serv.rawServer.discord)
hasRPC = true hasRPC = true
proc.on('close', (code, signal) => { proc.on('close', (code, signal) => {
loggerLaunchSuite.info('Shutting down Discord Rich Presence..') loggerLaunchSuite.info(Lang.queryJS('landing.dlAsync.shuttingDownRPC'))
DiscordWrapper.shutdownRPC() DiscordWrapper.shutdownRPC()
hasRPC = false hasRPC = false
proc = null proc = null
@ -633,7 +631,7 @@ async function dlAsync(login = true) {
} catch(err) { } catch(err) {
loggerLaunchSuite.error('Error during launch', err) loggerLaunchSuite.error('Error during launch', err)
showLaunchFailure('Error During Launch', 'Please check the console (CTRL + Shift + i) for more details.') showLaunchFailure(Lang.queryJS('landing.dlAsync.errorDuringLaunchTitle'), Lang.queryJS('landing.dlAsync.checkConsoleForDetails'))
} }
} }
@ -740,7 +738,7 @@ let newsLoadingListener = null
*/ */
function setNewsLoading(val){ function setNewsLoading(val){
if(val){ if(val){
const nLStr = 'Checking for News' const nLStr = Lang.queryJS('landing.news.loading')
let dotStr = '..' let dotStr = '..'
nELoadSpan.innerHTML = nLStr + dotStr nELoadSpan.innerHTML = nLStr + dotStr
newsLoadingListener = setInterval(() => { newsLoadingListener = setInterval(() => {

View File

@ -209,7 +209,67 @@
}, },
"landing": { "landing": {
"launch": { "launch": {
"pleaseWait": "Please wait.." "pleaseWait": "Please wait..",
"failureTitle": "Error During Launch",
"failureText": "See console (CTRL + Shift + i) for more details.",
"okay": "Okay"
},
"selectedAccount": {
"noAccountSelected": "No Account Selected"
},
"selectedServer": {
"icon": "\u2022 ",
"noSelection": "No Server Selected",
"loading": "Loading.."
},
"mojangStatus": {
"icon": "&#8226;"
},
"serverStatus": {
"server": "SERVER",
"offline": "OFFLINE",
"players": "PLAYERS"
},
"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 {suggestedMajor}. Would you like us to install a copy?",
"installJava": "Install Java",
"installJavaManually": "Install Manually",
"javaDownloadPrepare": "Preparing Java Download..",
"javaDownloadFailureTitle": "Error During Java Download",
"javaDownloadFailureText": "See console (CTRL + Shift + i) for more details.",
"javaRequired": "Java is Required<br>to Launch",
"javaRequiredMessage": "A valid x64 installation of Java {suggestedMajor} is required to launch.<br><br>Please refer to our <a href=\"https://github.com/dscalzi/HeliosLauncher/wiki/Java-Management#manually-installing-a-valid-version-of-java\">Java Management Guide</a> for instructions on how to manually install Java.",
"javaRequiredDismiss": "I Understand",
"javaRequiredCancel": "Go Back"
},
"downloadJava": {
"findJdkFailure": "Failed to find OpenJDK distribution.",
"javaDownloadCorruptedError": "Downloaded JDK has a bad hash, the file may be corrupted.",
"extractingJava": "Extracting Java",
"javaInstalled": "Java Installed!"
},
"dlAsync": {
"loadingServerInfo": "Loading server information..",
"fatalError": "Fatal Error",
"unableToLoadDistributionIndex": "Could not load a copy of the distribution index. See the console (CTRL + Shift + i) for more details.",
"pleaseWait": "Please wait..",
"errorDuringLaunchTitle": "Error During Launch",
"seeConsoleForDetails": "See console (CTRL + Shift + i) for more details.",
"validatingFileIntegrity": "Validating file integrity..",
"errorDuringFileVerificationTitle": "Error During File Verification",
"downloadingFiles": "Downloading files..",
"errorDuringFileDownloadTitle": "Error During File Download",
"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."
},
"news": {
"checking": "Checking for News"
} }
} }
} }