Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: localize discord RPC, window title, button #314

Merged
merged 2 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/assets/js/discordwrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions app/assets/js/scripts/landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'))
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/assets/js/scripts/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/assets/js/scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions app/assets/lang/en_US.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down