From 988d9391a5e7c6477b748dcf3274bbb728b20d13 Mon Sep 17 00:00:00 2001 From: Kamesuta Date: Sat, 2 Sep 2023 15:07:55 +0900 Subject: [PATCH] i18n for settings.js --- app/assets/js/scripts/landing.js | 4 +- app/assets/js/scripts/overlay.js | 2 +- app/assets/js/scripts/settings.js | 87 +++++++++++++++---------------- app/assets/lang/en_US.json | 68 ++++++++++++++++++++++-- 4 files changed, 109 insertions(+), 52 deletions(-) diff --git a/app/assets/js/scripts/landing.js b/app/assets/js/scripts/landing.js index 4ef5d057..7d65ed60 100644 --- a/app/assets/js/scripts/landing.js +++ b/app/assets/js/scripts/landing.js @@ -316,7 +316,7 @@ async function asyncSystemScan(effectiveJavaOptions, launchAfter = true){ // Show this information to the user. setOverlayContent( Lang.queryJS('landing.systemScan.noCompatibleJava'), - Lang.queryJS('landing.systemScan.installJavaMessage', { 'suggestedMajor': effectiveJavaOptions.suggestedMajor }), + Lang.queryJS('landing.systemScan.installJavaMessage', { 'major': effectiveJavaOptions.suggestedMajor }), Lang.queryJS('landing.systemScan.installJava'), Lang.queryJS('landing.systemScan.installJavaManually') ) @@ -336,7 +336,7 @@ async function asyncSystemScan(effectiveJavaOptions, launchAfter = true){ //$('#overlayDismiss').toggle(false) setOverlayContent( Lang.queryJS('landing.systemScan.javaRequired'), - Lang.queryJS('landing.systemScan.javaRequiredMessage', { 'suggestedMajor': effectiveJavaOptions.suggestedMajor }), + Lang.queryJS('landing.systemScan.javaRequiredMessage', { 'major': effectiveJavaOptions.suggestedMajor }), Lang.queryJS('landing.systemScan.javaRequiredDismiss'), Lang.queryJS('landing.systemScan.javaRequiredCancel') ) diff --git a/app/assets/js/scripts/overlay.js b/app/assets/js/scripts/overlay.js index 9c84a292..b7acfa2e 100644 --- a/app/assets/js/scripts/overlay.js +++ b/app/assets/js/scripts/overlay.js @@ -289,7 +289,7 @@ async function populateServerListings(){ - ${Lang.queryJS('overlay.mainServer')} + ${Lang.queryJS('settings.serverListing.mainServer')} ` : ''} diff --git a/app/assets/js/scripts/settings.js b/app/assets/js/scripts/settings.js index 0b5f3227..1d850055 100644 --- a/app/assets/js/scripts/settings.js +++ b/app/assets/js/scripts/settings.js @@ -59,8 +59,8 @@ function bindFileSelectors(){ if(isJavaExecSel && process.platform === 'win32') { options.filters = [ - { name: 'Executables', extensions: ['exe'] }, - { name: 'All Files', extensions: ['*'] } + { name: Lang.queryJS('settings.fileSelectors.executables'), extensions: ['exe'] }, + { name: Lang.queryJS('settings.fileSelectors.allFiles'), extensions: ['*'] } ] } @@ -374,9 +374,9 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGIN, (_, ...arguments_) => { // Unexpected error. setOverlayContent( - 'Something Went Wrong', - 'Microsoft authentication failed. Please try again.', - 'OK' + Lang.queryJS('settings.msftLogin.errorTitle'), + Lang.queryJS('settings.msftLogin.errorMessage'), + Lang.queryJS('settings.msftLogin.okButton') ) setOverlayHandler(() => { toggleOverlay(false) @@ -401,7 +401,7 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGIN, (_, ...arguments_) => { setOverlayContent( error, errorDesc, - 'OK' + Lang.queryJS('settings.msftLogin.okButton') ) setOverlayHandler(() => { toggleOverlay(false) @@ -429,10 +429,7 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGIN, (_, ...arguments_) => { } else { // Uh oh. msftLoginLogger.error('Unhandled error during login.', displayableError) - actualDisplayableError = { - title: 'Unknown Error During Login', - desc: 'An unknown error has occurred. Please see the console for details.' - } + actualDisplayableError = Lang.queryJS('login.error.unknown') } switchView(getCurrentView(), viewOnClose, 500, 500, () => { @@ -461,11 +458,11 @@ function bindAuthAccountSelect(){ for(let i=0; iThis is Your Last Account', - 'In order to use the launcher you must be logged into at least one account. You will need to login again after.

Are you sure you want to log out?', - 'I\'m Sure', - 'Cancel' + Lang.queryJS('settings.authAccountLogout.lastAccountWarningTitle'), + Lang.queryJS('settings.authAccountLogout.lastAccountWarningMessage'), + Lang.queryJS('settings.authAccountLogout.confirmButton'), + Lang.queryJS('settings.authAccountLogout.cancelButton') ) setOverlayHandler(() => { processLogOut(val, isLastAccount) @@ -555,9 +552,9 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGOUT, (_, ...arguments_) => { // Unexpected error. setOverlayContent( - 'Something Went Wrong', - 'Microsoft logout failed. Please try again.', - 'OK' + Lang.queryJS('settings.msftLogout.errorTitle'), + Lang.queryJS('settings.msftLogout.errorMessage'), + Lang.queryJS('settings.msftLogout.okButton') ) setOverlayHandler(() => { toggleOverlay(false) @@ -611,12 +608,12 @@ function refreshAuthAccountSelected(uuid){ const selBtn = val.getElementsByClassName('settingsAuthAccountSelect')[0] if(uuid === val.getAttribute('uuid')){ selBtn.setAttribute('selected', '') - selBtn.innerHTML = 'Selected Account ✔' + selBtn.innerHTML = Lang.queryJS('settings.authAccountSelect.selectedButton') } else { if(selBtn.hasAttribute('selected')){ selBtn.removeAttribute('selected') } - selBtn.innerHTML = 'Select Account' + selBtn.innerHTML = Lang.queryJS('settings.authAccountSelect.selectButton') } }) } @@ -648,18 +645,18 @@ function populateAuthAccounts(){
-
Username
+
${Lang.queryJS('settings.authAccountPopulate.username')}
${acc.displayName}
-
UUID
+
${Lang.queryJS('settings.authAccountPopulate.uuid')}
${acc.uuid}
- +
- +
@@ -873,7 +870,7 @@ async function resolveDropinModsForUI(){
${dropin.name}
- +
@@ -901,9 +898,9 @@ function bindDropinModsRemoveButton(){ document.getElementById(fullName).remove() } else { setOverlayContent( - `Failed to Delete
Drop-in Mod ${fullName}`, - 'Make sure the file is not in use and try again.', - 'Okay' + Lang.queryJS('settings.dropinMods.deleteFailedTitle', { fullName }), + Lang.queryJS('settings.dropinMods.deleteFailedMessage'), + Lang.queryJS('settings.okButton') ) setOverlayHandler(null) toggleOverlay(true) @@ -956,9 +953,9 @@ function saveDropinModConfiguration(){ DropinModUtil.toggleDropinMod(CACHE_SETTINGS_MODS_DIR, dropin.fullName, dropinUIEnabled).catch(err => { if(!isOverlayVisible()){ setOverlayContent( - 'Failed to Toggle
One or More Drop-in Mods', + Lang.queryJS('settings.dropinMods.failedToggleTitle'), err.message, - 'Okay' + Lang.queryJS('settings.okButton') ) setOverlayHandler(null) toggleOverlay(true) @@ -1093,7 +1090,7 @@ async function loadSelectedServerOnModsTab(){ - Main Server + ${Lang.queryJS('settings.serverListing.mainServer')} ` : ''} @@ -1344,19 +1341,19 @@ async function populateJavaExecDetails(execPath){ const details = await validateSelectedJvm(ensureJavaDirIsRoot(execPath), server.effectiveJavaOptions.supported) if(details != null) { - settingsJavaExecDetails.innerHTML = `Selected: Java ${details.semverStr} (${details.vendor})` + settingsJavaExecDetails.innerHTML = Lang.queryJS('settings.java.selectedJava', { version: details.semverStr, vendor: details.vendor }) } else { - settingsJavaExecDetails.innerHTML = 'Invalid Selection' + settingsJavaExecDetails.innerHTML = Lang.queryJS('settings.java.invalidSelection') } } function populateJavaReqDesc(server) { - settingsJavaReqDesc.innerHTML = `Requires Java ${server.effectiveJavaOptions.suggestedMajor} x64.` + settingsJavaReqDesc.innerHTML = Lang.queryJS('settings.java.requiresJava', { major: server.effectiveJavaOptions.suggestedMajor }) } function populateJvmOptsLink(server) { const major = server.effectiveJavaOptions.suggestedMajor - settingsJvmOptsLink.innerHTML = `Available Options for Java ${major} (HotSpot VM)` + settingsJvmOptsLink.innerHTML = Lang.queryJS('settings.java.availableOptions', { major: major }) if(major >= 12) { settingsJvmOptsLink.href = `https://docs.oracle.com/en/java/javase/${major}/docs/specs/man/java.html#extra-options-for-java` } @@ -1433,11 +1430,11 @@ function isPrerelease(version){ function populateVersionInformation(version, valueElement, titleElement, checkElement){ valueElement.innerHTML = version if(isPrerelease(version)){ - titleElement.innerHTML = 'Pre-release' + titleElement.innerHTML = Lang.queryJS('settings.about.preReleaseTitle') titleElement.style.color = '#ff886d' checkElement.style.background = '#ff886d' } else { - titleElement.innerHTML = 'Stable Release' + titleElement.innerHTML = Lang.queryJS('settings.about.stableReleaseTitle') titleElement.style.color = null checkElement.style.background = null } @@ -1476,7 +1473,7 @@ function populateReleaseNotes(){ }, timeout: 2500 }).catch(err => { - settingsAboutChangelogText.innerHTML = 'Failed to load release notes.' + settingsAboutChangelogText.innerHTML = Lang.queryJS('settings.about.releaseNotesFailed') }) } @@ -1524,27 +1521,27 @@ function settingsUpdateButtonStatus(text, disabled = false, handler = null){ */ function populateSettingsUpdateInformation(data){ if(data != null){ - settingsUpdateTitle.innerHTML = `New ${isPrerelease(data.version) ? 'Pre-release' : 'Release'} Available` + settingsUpdateTitle.innerHTML = isPrerelease(data.version) ? Lang.queryJS('settings.updates.newPreReleaseTitle') : Lang.queryJS('settings.updates.newReleaseTitle') settingsUpdateChangelogCont.style.display = null settingsUpdateChangelogTitle.innerHTML = data.releaseName settingsUpdateChangelogText.innerHTML = data.releaseNotes populateVersionInformation(data.version, settingsUpdateVersionValue, settingsUpdateVersionTitle, settingsUpdateVersionCheck) if(process.platform === 'darwin'){ - settingsUpdateButtonStatus('Download from GitHubClose the launcher and run the dmg to update.', false, () => { + settingsUpdateButtonStatus(Lang.queryJS('settings.updates.downloadButton'), false, () => { shell.openExternal(data.darwindownload) }) } else { - settingsUpdateButtonStatus('Downloading..', true) + settingsUpdateButtonStatus(Lang.queryJS('settings.updates.downloadingButton'), true) } } else { - settingsUpdateTitle.innerHTML = 'You Are Running the Latest Version' + settingsUpdateTitle.innerHTML = Lang.queryJS('settings.updates.latestVersionTitle') settingsUpdateChangelogCont.style.display = 'none' populateVersionInformation(remote.app.getVersion(), settingsUpdateVersionValue, settingsUpdateVersionTitle, settingsUpdateVersionCheck) - settingsUpdateButtonStatus('Check for Updates', false, () => { + settingsUpdateButtonStatus(Lang.queryJS('settings.updates.checkForUpdatesButton'), false, () => { if(!isDev){ ipcRenderer.send('autoUpdateAction', 'checkForUpdate') - settingsUpdateButtonStatus('Checking for Updates..', true) + settingsUpdateButtonStatus(Lang.queryJS('settings.updates.checkingForUpdatesButton'), true) } }) } diff --git a/app/assets/lang/en_US.json b/app/assets/lang/en_US.json index a0c0febe..08c805c8 100644 --- a/app/assets/lang/en_US.json +++ b/app/assets/lang/en_US.json @@ -210,14 +210,14 @@ "systemScan": { "checking": "Checking system info..", "noCompatibleJava": "No Compatible
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?", + "installJavaMessage": "In order to join WesterosCraft, 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..", "javaDownloadFailureTitle": "Error During Java Download", "javaDownloadFailureText": "See console (CTRL + Shift + i) for more details.", "javaRequired": "Java is Required
to Launch", - "javaRequiredMessage": "A valid x64 installation of Java {suggestedMajor} is required to launch.

Please refer to our Java Management Guide for instructions on how to manually install Java.", + "javaRequiredMessage": "A valid x64 installation of Java {major} is required to launch.

Please refer to our Java Management Guide for instructions on how to manually install Java.", "javaRequiredDismiss": "I Understand", "javaRequiredCancel": "Go Back" }, @@ -249,8 +249,68 @@ "checking": "Checking for News" } }, - "overlay": { - "mainServer": "Main Server" + "settings": { + "fileSelectors": { + "executables": "Executables", + "allFiles": "All Files" + }, + "mstfLogin": { + "errorTitle": "Something Went Wrong", + "errorMessage": "Microsoft authentication failed. Please try again.", + "okButton": "OK" + }, + "mstfLogout": { + "errorTitle": "Something Went Wrong", + "errorMessage": "Microsoft logout failed. Please try again.", + "okButton": "OK" + }, + "authAccountSelect": { + "selectButton": "Select Account", + "selectedButton": "Selected Account ✔" + }, + "authAccountLogout": { + "lastAccountWarningTitle": "Warning
This is Your Last Account", + "lastAccountWarningMessage": "In order to use the launcher you must be logged into at least one account. You will need to login again after.

Are you sure you want to log out?", + "confirmButton": "I'm Sure", + "cancelButton": "Cancel" + }, + "authAccountPopulate": { + "username": "Username", + "uuid": "UUID", + "selectAccount": "Select Account", + "selectedAccount": "Selected Account ✓", + "logout": "Log Out" + }, + "dropinMods": { + "removeButton": "Remove", + "deleteFailedTitle": "Failed to Delete
Drop-in Mod {fullName}", + "deleteFailedMessage": "Make sure the file is not in use and try again.", + "failedToggleTitle": "Failed to Toggle
One or More Drop-in Mods", + "okButton": "Okay" + }, + "serverListing": { + "mainServer": "Main Server" + }, + "java": { + "selectedJava": "Selected: Java {version} ({vendor})", + "invalidSelection": "Invalid Selection", + "requiresJava": "Requires Java {major} x64.", + "availableOptions": "Available Options for Java {major} (HotSpot VM)" + }, + "about": { + "preReleaseTitle": "Pre-release", + "stableReleaseTitle": "Stable Release", + "releaseNotesFailed": "Failed to load release notes." + }, + "updates": { + "newReleaseTitle": "New Release Available", + "newPreReleaseTitle": "New Pre-release Available", + "downloadingButton": "Downloading..", + "downloadButton": "Download from GitHubClose the launcher and run the dmg to update.", + "latestVersionTitle": "You Are Running the Latest Version", + "checkForUpdatesButton": "Check for Updates", + "checkingForUpdatesButton": "Checking for Updates.." + } } } } \ No newline at end of file