Skip to content

Commit 7795732

Browse files
authored
Merge pull request #10 from BrowserSourcesForOBS/dev
Translate values not defined fix
2 parents c44a1c1 + 0419332 commit 7795732

File tree

5 files changed

+43
-43
lines changed

5 files changed

+43
-43
lines changed

core/client.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ socket.addEventListener('message', (event) => {
3939

4040
// Configuration and translation
4141
switchTheme.checked = message.config.themeDark
42-
buttonClose.title = translateElements.home.close
42+
buttonClose.title = translateElements.home.close || 'n/a'
4343
textVersion.textContent = message.config.version
4444
if (message.config.version !== 'Error' && message.config.versionRelease !== 'Error' && compareVersions(message.config.version, message.config.versionRelease) === 1) {
4545
const link = document.createElement('a')
@@ -48,12 +48,12 @@ socket.addEventListener('message', (event) => {
4848
link.id = 'link-newVersion'
4949
const button = document.createElement('button')
5050
button.className = 'button-versionRelease'
51-
button.title = translateElements.home.newVersionTitle
52-
button.textContent = translateElements.home.newVersion + message.config.versionRelease
51+
button.title = translateElements.home.newVersionTitle || 'n/a'
52+
button.textContent = (translateElements.home.newVersion || 'n/a') + (message.config.versionRelease || 'n/a')
5353
link.appendChild(button)
5454
leftButtons.appendChild(link)
5555
}
56-
buttonWiki.title = translateElements.home.wiki
56+
buttonWiki.title = translateElements.home.wiki || 'n/a'
5757
if (message.config.themeDark) {
5858
document.body.classList.remove('light-theme')
5959
document.body.classList.add('dark-theme')
@@ -76,11 +76,11 @@ socket.addEventListener('message', (event) => {
7676
? message.config.lang
7777
: 'en'
7878

79-
titleCrono.textContent = translateElements.home.cronoTitle
80-
titleCdown.textContent = translateElements.home.cdownTitle
81-
titleCdowntime.textContent = translateElements.home.cdowntimeTitle
82-
titleExtensible.textContent = translateElements.home.extensibleTitle
83-
titleTime.textContent = translateElements.home.timeTitle
79+
titleCrono.textContent = translateElements.home.cronoTitle || 'n/a'
80+
titleCdown.textContent = translateElements.home.cdownTitle || 'n/a'
81+
titleCdowntime.textContent = translateElements.home.cdowntimeTitle || 'n/a'
82+
titleExtensible.textContent = translateElements.home.extensibleTitle || 'n/a'
83+
titleTime.textContent = translateElements.home.timeTitle || 'n/a'
8484

8585
if (elementVariables && typeof elementVariables === 'object') {
8686
// console.log('Variables loaded from the server.')
@@ -148,7 +148,7 @@ buttonContainer.addEventListener('click', (event) => {
148148
copyTextToClipboard(copyText)
149149

150150
// Display a notification message
151-
showNotification(translateElements.home.notycopy, button)
151+
showNotification(translateElements.home.notycopy || 'n/a', button)
152152
}
153153
} else if (data[1] === 'copyButtonCrono') {
154154
// Get the text to copy from the "data-copy-text" attribute
@@ -158,7 +158,7 @@ buttonContainer.addEventListener('click', (event) => {
158158
copyTextToClipboard(copyText)
159159

160160
// Display a notification message
161-
showNotification(translateElements.home.notycopy, button)
161+
showNotification(translateElements.home.notycopy || 'n/a', button)
162162
}
163163
} else if (data[1] === 'copyButtonCdown') {
164164
// Get the text to copy from the "data-copy-text" attribute
@@ -168,7 +168,7 @@ buttonContainer.addEventListener('click', (event) => {
168168
copyTextToClipboard(copyText)
169169

170170
// Display a notification message
171-
showNotification(translateElements.home.notycopy, button)
171+
showNotification(translateElements.home.notycopy || 'n/a', button)
172172
}
173173
} else if (data[1] === 'removeButton') {
174174
socket.send(JSON.stringify({ action: 'removeData', remove: data[0] }))

core/template/cdown/control/control.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ socket.addEventListener('message', (event) => {
8282
? message.config.lang
8383
: 'en'
8484

85-
controlButton.textContent = translateElements.timer.buttons.start
86-
resetButton.textContent = translateElements.timer.buttons.reset
85+
controlButton.textContent = translateElements.timer.buttons.start || 'n/a'
86+
resetButton.textContent = translateElements.timer.buttons.reset || 'n/a'
8787

8888
if (elementVariables && typeof elementVariables === 'object') {
8989
checkTextTime = MsToText(elementVariables.textMilliseconds)
@@ -101,7 +101,7 @@ socket.addEventListener('message', (event) => {
101101
// Perform necessary actions with the variables here
102102
textMsg.textContent = elementVariables.msgEnd
103103
if (elementVariables.msgEnd === '') {
104-
textMsg.textContent = translateElements.timer.phMsgEnd
104+
textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a'
105105
textMsg.style.color = '#555'
106106
} else { textMsg.style.color = '#000' }
107107
timeText.value = MsToText(elementVariables.textMilliseconds)
@@ -122,7 +122,7 @@ socket.addEventListener('message', (event) => {
122122
if (message[classElement].status !== 'started') {
123123
textMsg.textContent = message[classElement].msgEnd
124124
if (message[classElement].msgEnd === '') {
125-
textMsg.textContent = translateElements.timer.phMsgEnd
125+
textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a'
126126
textMsg.style.color = '#555'
127127
} else { textMsg.style.color = '#000' }
128128
timeText.value = MsToText(message[classElement].textMilliseconds)
@@ -157,7 +157,7 @@ selectorLang.addEventListener('change', () => {
157157
})
158158

159159
controlButton.addEventListener('click', () => {
160-
if (controlButton.textContent === translateElements.timer.buttons.start) {
160+
if (controlButton.textContent === translateElements.timer.buttons.start || 'n/a') {
161161
socket.send(JSON.stringify({ action: 'startTimer', classElement }))
162162
} else {
163163
socket.send(JSON.stringify({ action: 'pauseCdown', classElement }))
@@ -218,7 +218,7 @@ subContainer.addEventListener('click', (event) => {
218218
})
219219

220220
textMsg.addEventListener('focus', () => {
221-
if (textMsg.textContent === translateElements.timer.phMsgEnd) {
221+
if (textMsg.textContent === translateElements.timer.phMsgEnd || 'n/a') {
222222
textMsg.textContent = ''
223223
textMsg.style.color = '#000'
224224
}
@@ -227,7 +227,7 @@ textMsg.addEventListener('focus', () => {
227227
textMsg.addEventListener('blur', () => {
228228
socket.send(JSON.stringify({ action: 'editMsg', msg: textMsg.textContent, classElement }))
229229
if (textMsg.textContent === '') {
230-
textMsg.textContent = translateElements.timer.phMsgEnd
230+
textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a'
231231
textMsg.style.color = '#555'
232232
} else { textMsg.style.color = '#000' }
233233
})
@@ -328,17 +328,17 @@ function updateControlButton (status) {
328328
controlButton.style.width = maxWidth
329329

330330
if (status === 'started') {
331-
controlButton.textContent = translateElements.timer.buttons.pause
331+
controlButton.textContent = translateElements.timer.buttons.pause || 'n/a'
332332
} else {
333-
controlButton.textContent = translateElements.timer.buttons.start
333+
controlButton.textContent = translateElements.timer.buttons.start || 'n/a'
334334
}
335335
}
336336

337337
function getMaxButtonWidth () {
338338
const widths = []
339339

340340
Object.keys(translateElements.timer.buttons).forEach((value) => {
341-
controlButton.textContent = translateElements.timer.buttons[value]
341+
controlButton.textContent = translateElements.timer.buttons[value] || 'n/a'
342342
widths.push(parseFloat(window.getComputedStyle(controlButton).getPropertyValue('width')))
343343
})
344344
// Get the maximum of the two widths

core/template/cdowntime/control/control.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ socket.addEventListener('message', (event) => {
107107
// Perform necessary actions with the variables here
108108
textMsg.textContent = elementVariables.msgEnd
109109
if (elementVariables.msgEnd === '') {
110-
textMsg.textContent = translateElements.timer.phMsgEnd
110+
textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a'
111111
textMsg.style.color = '#555'
112112
} else { textMsg.style.color = '#000' }
113113
timeData.value = new Date(elementVariables.endDatetime).toLocaleString('en-CA', { timeZone: elementVariables.timezone, hour12: false }).replace(/,\s/, 'T')
@@ -189,7 +189,7 @@ subContainer.addEventListener('click', (event) => {
189189
})
190190

191191
textMsg.addEventListener('focus', () => {
192-
if (textMsg.textContent === translateElements.timer.phMsgEnd) {
192+
if (textMsg.textContent === translateElements.timer.phMsgEnd || 'n/a') {
193193
textMsg.textContent = ''
194194
textMsg.style.color = '#000'
195195
}
@@ -198,7 +198,7 @@ textMsg.addEventListener('focus', () => {
198198
textMsg.addEventListener('blur', () => {
199199
socket.send(JSON.stringify({ action: 'editMsg', msg: textMsg.textContent, classElement }))
200200
if (textMsg.textContent === '') {
201-
textMsg.textContent = translateElements.timer.phMsgEnd
201+
textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a'
202202
textMsg.style.color = '#555'
203203
} else { textMsg.style.color = '#000' }
204204
})

core/template/crono/control/control.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ socket.addEventListener('message', (event) => {
8080
? message.config.lang
8181
: 'en'
8282

83-
controlButton.textContent = translateElements.timer.buttons.start
84-
resetButton.textContent = translateElements.timer.buttons.reset
83+
controlButton.textContent = translateElements.timer.buttons.start || 'n/a'
84+
resetButton.textContent = translateElements.timer.buttons.reset || 'n/a'
8585

8686
if (elementVariables && typeof elementVariables === 'object') {
8787
checkHexColor = elementVariables.colorText
@@ -139,7 +139,7 @@ languageSelector.addEventListener('change', () => {
139139
})
140140

141141
controlButton.addEventListener('click', () => {
142-
if (controlButton.textContent === translateElements.timer.buttons.start) {
142+
if (controlButton.textContent === translateElements.timer.buttons.start || 'n/a') {
143143
socket.send(JSON.stringify({ action: 'startTimer', classElement }))
144144
} else {
145145
socket.send(JSON.stringify({ action: 'pauseCrono', classElement }))
@@ -265,17 +265,17 @@ function updateControlButton (status) {
265265
controlButton.style.width = maxWidth
266266

267267
if (status === 'started') {
268-
controlButton.textContent = translateElements.timer.buttons.pause
268+
controlButton.textContent = translateElements.timer.buttons.pause || 'n/a'
269269
} else {
270-
controlButton.textContent = translateElements.timer.buttons.start
270+
controlButton.textContent = translateElements.timer.buttons.start || 'n/a'
271271
}
272272
}
273273

274274
function getMaxButtonWidth () {
275275
const widths = []
276276

277277
Object.keys(translateElements.timer.buttons).forEach((value) => {
278-
controlButton.textContent = translateElements.timer.buttons[value]
278+
controlButton.textContent = translateElements.timer.buttons[value] || 'n/a'
279279
widths.push(parseFloat(window.getComputedStyle(controlButton).getPropertyValue('width')))
280280
})
281281

core/template/extensible/control/control.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ socket.addEventListener('message', (event) => {
8787
? message.config.lang
8888
: 'en'
8989

90-
controlButton.textContent = translateElements.timer.buttons.start
91-
resetButton.textContent = translateElements.timer.buttons.reset
92-
checkboxLabelStopAdd.textContent = translateElements.timer.enableStopAdd
93-
checkboxLabelPauseAdd.textContent = translateElements.timer.enablePauseAdd
90+
controlButton.textContent = translateElements.timer.buttons.start || 'n/a'
91+
resetButton.textContent = translateElements.timer.buttons.reset || 'n/a'
92+
checkboxLabelStopAdd.textContent = translateElements.timer.enableStopAdd || 'n/a'
93+
checkboxLabelPauseAdd.textContent = translateElements.timer.enablePauseAdd || 'n/a'
9494

9595
if (elementVariables && typeof elementVariables === 'object') {
9696
checkTextTime = MsToText(elementVariables.textMilliseconds)
@@ -116,7 +116,7 @@ socket.addEventListener('message', (event) => {
116116
// Perform necessary actions with the variables here
117117
textMsg.textContent = elementVariables.msgEnd
118118
if (elementVariables.msgEnd === '') {
119-
textMsg.textContent = translateElements.timer.phMsgEnd
119+
textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a'
120120
textMsg.style.color = '#555'
121121
} else { textMsg.style.color = '#000' }
122122
timeText.value = MsToText(elementVariables.textMilliseconds)
@@ -140,7 +140,7 @@ socket.addEventListener('message', (event) => {
140140
if (message[classElement].status !== 'started') {
141141
textMsg.textContent = message[classElement].msgEnd
142142
if (message[classElement].msgEnd === '') {
143-
textMsg.textContent = translateElements.timer.phMsgEnd
143+
textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a'
144144
textMsg.style.color = '#555'
145145
} else { textMsg.style.color = '#000' }
146146
timeText.value = MsToText(message[classElement].textMilliseconds)
@@ -179,7 +179,7 @@ selectorLang.addEventListener('change', () => {
179179
})
180180

181181
controlButton.addEventListener('click', () => {
182-
if (controlButton.textContent === translateElements.timer.buttons.start) {
182+
if (controlButton.textContent === translateElements.timer.buttons.start || 'n/a') {
183183
socket.send(JSON.stringify({ action: 'startTimer', classElement }))
184184
} else {
185185
socket.send(JSON.stringify({ action: 'pauseExtensible', classElement }))
@@ -248,7 +248,7 @@ checkboxPauseAdd.addEventListener('change', () => {
248248
})
249249

250250
textMsg.addEventListener('focus', () => {
251-
if (textMsg.textContent === translateElements.timer.phMsgEnd) {
251+
if (textMsg.textContent === translateElements.timer.phMsgEnd || 'n/a') {
252252
textMsg.textContent = ''
253253
textMsg.style.color = '#000'
254254
}
@@ -257,7 +257,7 @@ textMsg.addEventListener('focus', () => {
257257
textMsg.addEventListener('blur', () => {
258258
socket.send(JSON.stringify({ action: 'editMsg', msg: textMsg.textContent, classElement }))
259259
if (textMsg.textContent === '') {
260-
textMsg.textContent = translateElements.timer.phMsgEnd
260+
textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a'
261261
textMsg.style.color = '#555'
262262
} else { textMsg.style.color = '#000' }
263263
})
@@ -362,17 +362,17 @@ function updateControlButton (status) {
362362
controlButton.style.width = maxWidth
363363

364364
if (status === 'started') {
365-
controlButton.textContent = translateElements.timer.buttons.pause
365+
controlButton.textContent = translateElements.timer.buttons.pause || 'n/a'
366366
} else {
367-
controlButton.textContent = translateElements.timer.buttons.start
367+
controlButton.textContent = translateElements.timer.buttons.start || 'n/a'
368368
}
369369
}
370370

371371
function getMaxButtonWidth () {
372372
const widths = []
373373

374374
Object.keys(translateElements.timer.buttons).forEach((value) => {
375-
controlButton.textContent = translateElements.timer.buttons[value]
375+
controlButton.textContent = translateElements.timer.buttons[value] || 'n/a'
376376
widths.push(parseFloat(window.getComputedStyle(controlButton).getPropertyValue('width')))
377377
})
378378
// Get the maximum of the two widths

0 commit comments

Comments
 (0)