From 3d470d9a324e92259166d043189cbb802bee275d Mon Sep 17 00:00:00 2001 From: jebibot <83044352+jebibot@users.noreply.github.com> Date: Sun, 26 Nov 2023 08:31:41 +0900 Subject: [PATCH] feat: localize discord RPC, window title, button (#314) * feat: localize discord RPC, window title, button * fix: settings.dropinMods.okButton key --- app/assets/js/discordwrapper.js | 6 ++++-- app/assets/js/scripts/landing.js | 6 +++--- app/assets/js/scripts/overlay.js | 2 +- app/assets/js/scripts/settings.js | 4 ++-- app/assets/lang/en_US.toml | 16 ++++++++++++++++ index.js | 4 ++-- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/app/assets/js/discordwrapper.js b/app/assets/js/discordwrapper.js index 1e44e86..11ed053 100644 --- a/app/assets/js/discordwrapper.js +++ b/app/assets/js/discordwrapper.js @@ -5,15 +5,17 @@ const logger = LoggerUtil.getLogger('DiscordWrapper') const { Client } = require('discord-rpc-patch') +const Lang = require('./langloader') + let client let activity -exports.initRPC = function(genSettings, servSettings, initialDetails = 'Waiting for Client..'){ +exports.initRPC = function(genSettings, servSettings, initialDetails = Lang.queryJS('discord.waiting')){ client = new Client({ transport: 'ipc' }) activity = { details: initialDetails, - state: 'Server: ' + servSettings.shortId, + state: Lang.queryJS('discord.state', {shortId: servSettings.shortId}), largeImageKey: servSettings.largeImageKey, largeImageText: servSettings.largeImageText, smallImageKey: genSettings.smallImageKey, diff --git a/app/assets/js/scripts/landing.js b/app/assets/js/scripts/landing.js index 0374334..1c73e04 100644 --- a/app/assets/js/scripts/landing.js +++ b/app/assets/js/scripts/landing.js @@ -563,7 +563,7 @@ async function dlAsync(login = true) { const onLoadComplete = () => { toggleLaunchArea(false) if(hasRPC){ - DiscordWrapper.updateDetails('Loading game..') + DiscordWrapper.updateDetails(Lang.queryJS('landing.discord.loading')) proc.stdout.on('data', gameStateChange) } proc.stdout.removeListener('data', tempListener) @@ -590,9 +590,9 @@ async function dlAsync(login = true) { const gameStateChange = function(data){ data = data.trim() if(SERVER_JOINED_REGEX.test(data)){ - DiscordWrapper.updateDetails('Exploring the Realm!') + DiscordWrapper.updateDetails(Lang.queryJS('landing.discord.joined')) } else if(GAME_JOINED_REGEX.test(data)){ - DiscordWrapper.updateDetails('Sailing to Westeros!') + DiscordWrapper.updateDetails(Lang.queryJS('landing.discord.joining')) } } diff --git a/app/assets/js/scripts/overlay.js b/app/assets/js/scripts/overlay.js index b7acfa2..0d6ab2a 100644 --- a/app/assets/js/scripts/overlay.js +++ b/app/assets/js/scripts/overlay.js @@ -130,7 +130,7 @@ async function toggleServerSelection(toggleState){ * @param {string} acknowledge Acknowledge button text. * @param {string} dismiss Dismiss button text. */ -function setOverlayContent(title, description, acknowledge, dismiss = 'Dismiss'){ +function setOverlayContent(title, description, acknowledge, dismiss = Lang.queryJS('overlay.dismiss')){ document.getElementById('overlayTitle').innerHTML = title document.getElementById('overlayDesc').innerHTML = description document.getElementById('overlayAcknowledge').innerHTML = acknowledge diff --git a/app/assets/js/scripts/settings.js b/app/assets/js/scripts/settings.js index 1d85005..628c63c 100644 --- a/app/assets/js/scripts/settings.js +++ b/app/assets/js/scripts/settings.js @@ -900,7 +900,7 @@ function bindDropinModsRemoveButton(){ setOverlayContent( Lang.queryJS('settings.dropinMods.deleteFailedTitle', { fullName }), Lang.queryJS('settings.dropinMods.deleteFailedMessage'), - Lang.queryJS('settings.okButton') + Lang.queryJS('settings.dropinMods.okButton') ) setOverlayHandler(null) toggleOverlay(true) @@ -955,7 +955,7 @@ function saveDropinModConfiguration(){ setOverlayContent( Lang.queryJS('settings.dropinMods.failedToggleTitle'), err.message, - Lang.queryJS('settings.okButton') + Lang.queryJS('settings.dropinMods.okButton') ) setOverlayHandler(null) toggleOverlay(true) diff --git a/app/assets/lang/en_US.toml b/app/assets/lang/en_US.toml index 8bd2f48..59877b7 100644 --- a/app/assets/lang/en_US.toml +++ b/app/assets/lang/en_US.toml @@ -130,6 +130,14 @@ waitingText = "Waiting for Microsoft.." continueButton = "CONTINUE" +[js.discord] +waiting = "Waiting for Client.." +state = "Server: {shortId}" + +[js.index] +microsoftLoginTitle = "Microsoft Login" +microsoftLogoutTitle = "Microsoft Logout" + [js.login] login = "LOGIN" loggingIn = "LOGGING IN" @@ -202,6 +210,14 @@ checkConsoleForDetails = "Please check the console (CTRL + Shift + i) for more d [js.landing.news] checking = "Checking for News" +[js.landing.discord] +loading = "Loading game.." +joining = "Sailing to Westeros!" +joined = "Exploring the Realm!" + +[js.overlay] +dismiss = "Dismiss" + [js.settings.fileSelectors] executables = "Executables" allFiles = "All Files" diff --git a/index.js b/index.js index ae0408a..7060c3c 100644 --- a/index.js +++ b/index.js @@ -125,7 +125,7 @@ ipcMain.on(MSFT_OPCODE.OPEN_LOGIN, (ipcEvent, ...arguments_) => { msftAuthViewSuccess = arguments_[0] msftAuthViewOnClose = arguments_[1] msftAuthWindow = new BrowserWindow({ - title: 'Microsoft Login', + title: LangLoader.queryJS('index.microsoftLoginTitle'), backgroundColor: '#222222', width: 520, height: 600, @@ -178,7 +178,7 @@ ipcMain.on(MSFT_OPCODE.OPEN_LOGOUT, (ipcEvent, uuid, isLastAccount) => { msftLogoutSuccess = false msftLogoutSuccessSent = false msftLogoutWindow = new BrowserWindow({ - title: 'Microsoft Logout', + title: LangLoader.queryJS('index.microsoftLogoutTitle'), backgroundColor: '#222222', width: 520, height: 600,