Skip to content

Commit

Permalink
Merge pull request #468 from ZIMkaRU/refactoring/optimize-electron-tr…
Browse files Browse the repository at this point in the history
…anslation-file-data-structure

Optimize electron translation file data structure
  • Loading branch information
ezewer authored Nov 29, 2024
2 parents ff836ab + 2e6eacf commit 13c10b7
Show file tree
Hide file tree
Showing 23 changed files with 518 additions and 562 deletions.
416 changes: 197 additions & 219 deletions build/locales/en/translations.json

Large diffs are not rendered by default.

416 changes: 197 additions & 219 deletions build/locales/ru/translations.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions src/auto-updater/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ const _fireToast = (
backdrop: 'rgba(0,0,0,0.0)',

icon: 'info',
title: i18next.t('common.autoUpdater.title'),
title: i18next.t('autoUpdater.title'),
showConfirmButton: true,
showCancelButton: false,
confirmButtonText: i18next.t('common.autoUpdater.confirmButtonText'),
cancelButtonText: i18next.t('common.autoUpdater.cancelButtonText'),
confirmButtonText: i18next.t('common.confirmButtonText'),
cancelButtonText: i18next.t('common.cancelButtonText'),
timerProgressBar: false,

...opts,
Expand Down Expand Up @@ -268,7 +268,7 @@ const _autoUpdaterFactory = () => {

autoUpdater.addInstallingUpdateEventHandler(() => {
return showLoadingWindow({
description: i18next.t('common.autoUpdater.loadingWindow.description'),
description: i18next.t('autoUpdater.loadingWindow.description'),
isRequiredToCloseAllWins: true
})
})
Expand Down Expand Up @@ -318,7 +318,7 @@ const _autoUpdaterFactory = () => {
/ERR_INTERNET_DISCONNECTED/gi.test(err.toString())
) {
await _fireToast({
title: i18next.t('common.autoUpdater.errorToast.inetIssueTitle'),
title: i18next.t('autoUpdater.errorToast.inetIssueTitle'),
icon: 'error',
timer: 60000
})
Expand All @@ -327,7 +327,7 @@ const _autoUpdaterFactory = () => {
}

await _fireToast({
title: i18next.t('common.autoUpdater.errorToast.title'),
title: i18next.t('autoUpdater.errorToast.title'),
icon: 'error',
timer: 60000
})
Expand All @@ -343,7 +343,7 @@ const _autoUpdaterFactory = () => {

await _fireToast(
{
title: i18next.t('common.autoUpdater.checkingForUpdateToast.title'),
title: i18next.t('autoUpdater.checkingForUpdateToast.title'),
type: 'warning',
timer: 10000
},
Expand All @@ -364,10 +364,10 @@ const _autoUpdaterFactory = () => {
const { value, dismiss } = await _fireToast(
{
title: i18next.t(
'common.autoUpdater.updateAvailableToast.title',
'autoUpdater.updateAvailableToast.title',
{ version }
),
text: i18next.t('common.autoUpdater.updateAvailableToast.description'),
text: i18next.t('autoUpdater.updateAvailableToast.description'),
icon: 'info',
timer: 10000
}
Expand Down Expand Up @@ -402,7 +402,7 @@ const _autoUpdaterFactory = () => {

await _fireToast(
{
title: i18next.t('common.autoUpdater.updateNotAvailableToast.title'),
title: i18next.t('autoUpdater.updateNotAvailableToast.title'),
icon: 'success',
timer: 10000
}
Expand All @@ -425,7 +425,7 @@ const _autoUpdaterFactory = () => {

await _fireToast(
{
title: i18next.t('common.autoUpdater.downloadProgressToast.title'),
title: i18next.t('autoUpdater.downloadProgressToast.title'),
icon: 'info'
},
{
Expand Down Expand Up @@ -458,10 +458,10 @@ const _autoUpdaterFactory = () => {
const { value } = await _fireToast(
{
title: i18next.t(
'common.autoUpdater.updateDownloadedToast.title',
'autoUpdater.updateDownloadedToast.title',
{ version }
),
text: i18next.t('common.autoUpdater.updateDownloadedToast.description'),
text: i18next.t('autoUpdater.updateDownloadedToast.description'),
icon: 'question',
timer: 60000,
showCancelButton: true
Expand Down
6 changes: 3 additions & 3 deletions src/change-reports-folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ module.exports = ({ pathToUserDocuments }) => {
} = await dialog.showOpenDialog(
win,
{
title: i18next.t('common.changeReportsFolder.modalDialog.title'),
title: i18next.t('changeReportsFolder.modalDialog.title'),
defaultPath: pathToUserDocuments,
buttonLabel: i18next.t('common.changeReportsFolder.modalDialog.buttonLabel'),
buttonLabel: i18next.t('changeReportsFolder.modalDialog.buttonLabel'),
properties: [
'openDirectory',
'createDirectory',
Expand Down Expand Up @@ -70,7 +70,7 @@ module.exports = ({ pathToUserDocuments }) => {
try {
await showErrorModalDialog(
win,
i18next.t('common.changeReportsFolder.modalDialog.title'),
i18next.t('changeReportsFolder.modalDialog.title'),
err
)
} catch (err) {
Expand Down
20 changes: 10 additions & 10 deletions src/change-sync-frequency.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ module.exports = () => {
}

const timeFormatAlertOptions = {
title: i18next.t('common.changeSyncFrequency.timeFormatModalDialog.title'),
title: i18next.t('changeSyncFrequency.timeFormatModalDialog.title'),
icon: 'question',
customClass: getAlertCustomClassObj({
title: 'titleColor',
Expand All @@ -140,20 +140,20 @@ module.exports = () => {
focusConfirm: true,
showCancelButton: true,
confirmButtonText: i18next
.t('common.changeSyncFrequency.timeFormatModalDialog.confirmButtonText'),
.t('common.confirmButtonText'),
cancelButtonText: i18next
.t('common.changeSyncFrequency.timeFormatModalDialog.cancelButtonText'),
.t('common.cancelButtonText'),
progressSteps: [1, 2],
currentProgressStep: 0,
input: 'radio',
inputValue: 'hours',
inputOptions: {
mins: i18next
.t('common.changeSyncFrequency.timeFormatModalDialog.inputOptions.mins'),
.t('changeSyncFrequency.timeFormatModalDialog.inputOptions.mins'),
hours: i18next
.t('common.changeSyncFrequency.timeFormatModalDialog.inputOptions.hours'),
.t('changeSyncFrequency.timeFormatModalDialog.inputOptions.hours'),
days: i18next
.t('common.changeSyncFrequency.timeFormatModalDialog.inputOptions.days')
.t('changeSyncFrequency.timeFormatModalDialog.inputOptions.days')
},
willOpen: () => {
if (!timeFormatAlert.browserWindow) return
Expand All @@ -162,7 +162,7 @@ module.exports = () => {
}
}
const alertOptions = {
title: i18next.t('common.changeSyncFrequency.timeModalDialog.title'),
title: i18next.t('changeSyncFrequency.timeModalDialog.title'),
icon: 'question',
customClass: getAlertCustomClassObj({
title: 'titleColor',
Expand All @@ -172,9 +172,9 @@ module.exports = () => {
focusConfirm: true,
showCancelButton: true,
confirmButtonText: i18next
.t('common.changeSyncFrequency.timeModalDialog.confirmButtonText'),
.t('common.confirmButtonText'),
cancelButtonText: i18next
.t('common.changeSyncFrequency.timeModalDialog.cancelButtonText'),
.t('common.cancelButtonText'),
progressSteps: [1, 2],
currentProgressStep: 1,
input: 'range',
Expand Down Expand Up @@ -295,7 +295,7 @@ module.exports = () => {
try {
await showErrorModalDialog(
win,
i18next.t('common.changeSyncFrequency.title'),
i18next.t('changeSyncFrequency.title'),
err
)
} catch (err) {
Expand Down
14 changes: 7 additions & 7 deletions src/enforce-macos-app-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ module.exports = async () => {
const clickedButtonIndex = dialog.showMessageBoxSync({
type: 'error',
message: i18next
.t('common.enforceMacOSAppLocation.appLocationModalDialog.message'),
.t('enforceMacOSAppLocation.appLocationModalDialog.message'),
detail: i18next.t(
'common.enforceMacOSAppLocation.appLocationModalDialog.detail',
'enforceMacOSAppLocation.appLocationModalDialog.detail',
{ productName }
),
buttons: [
i18next.t('common.enforceMacOSAppLocation.appLocationModalDialog.confirmButtonText'),
i18next.t('enforceMacOSAppLocation.appLocationModalDialog.confirmButtonText'),
i18next.t(
'common.enforceMacOSAppLocation.appLocationModalDialog.cancelButtonText',
'enforceMacOSAppLocation.appLocationModalDialog.cancelButtonText',
{ productName }
)
],
Expand All @@ -48,7 +48,7 @@ module.exports = async () => {

await showLoadingWindow({
description: i18next
.t('common.enforceMacOSAppLocation.loadingWindow.description'),
.t('enforceMacOSAppLocation.loadingWindow.description'),
isRequiredToCloseAllWins: true,
isIndeterminateMode: true
})
Expand All @@ -59,11 +59,11 @@ module.exports = async () => {
dialog.showMessageBoxSync({
type: 'error',
message: i18next.t(
'common.enforceMacOSAppLocation.appRunningModalDialog.message',
'enforceMacOSAppLocation.appRunningModalDialog.message',
{ productName }
),
buttons: [
i18next.t('common.enforceMacOSAppLocation.appRunningModalDialog.confirmButtonText')
i18next.t('common.confirmButtonText')
]
})

Expand Down
4 changes: 2 additions & 2 deletions src/error-manager/get-error-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module.exports = (params) => {

const title = '[BUG REPORT]'
const description = 'Bug report'
const errBoxTitle = i18next.t('common.errorManager.errorModalDialog.errBoxTitle')
const errBoxDescription = i18next.t('common.errorManager.errorModalDialog.errBoxDescription')
const errBoxTitle = i18next.t('errorManager.errorModalDialog.errBoxTitle')
const errBoxDescription = i18next.t('errorManager.errorModalDialog.errBoxDescription')

if (
error &&
Expand Down
4 changes: 2 additions & 2 deletions src/error-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ const initLogger = () => {
const error = message.data.join(os.EOL)

if (/Failed to get 'documents' path/gi.test(error)) {
const title = i18next.t('common.errorManager.failedToGetDocsPath.title')
const msg = i18next.t('common.errorManager.failedToGetDocsPath.message')
const title = i18next.t('errorManager.failedToGetDocsPath.title')
const msg = i18next.t('errorManager.failedToGetDocsPath.message')

showModalDialog({
errBoxTitle: title,
Expand Down
12 changes: 6 additions & 6 deletions src/error-manager/show-modal-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const converter = new Converter({

const _fireAlert = (params) => {
const {
title = i18next.t('common.errorManager.errorModalDialog.title'),
title = i18next.t('errorManager.errorModalDialog.title'),
html = '',
parentWin,
hasNoParentWin
Expand Down Expand Up @@ -112,9 +112,9 @@ const _fireAlert = (params) => {
icon: 'question',
focusConfirm: true,
showConfirmButton: true,
confirmButtonText: i18next.t('common.errorManager.errorModalDialog.confirmButtonText'),
confirmButtonText: i18next.t('errorManager.errorModalDialog.confirmButtonText'),
showCancelButton: true,
cancelButtonText: i18next.t('common.errorManager.errorModalDialog.cancelButtonText'),
cancelButtonText: i18next.t('common.cancelButtonText'),
timerProgressBar: false,

...params,
Expand Down Expand Up @@ -177,18 +177,18 @@ module.exports = async (params) => {
* before the translation init
*/
errBoxTitle = i18next.t(
'common.errorManager.errorModalDialog.errBoxTitle',
'errorManager.errorModalDialog.errBoxTitle',
'Bug report'
),
errBoxDescription = i18next.t(
'common.errorManager.errorModalDialog.errBoxDescription',
'errorManager.errorModalDialog.errBoxDescription',
'A new GitHub issue will be opened'
),
mdIssue,
alertOpts = {}
} = params ?? {}
const zenityBtn = i18next.t(
'common.errorManager.errorModalDialog.zenityBtn',
'errorManager.errorModalDialog.zenityBtn',
'Report and Exit'
)

Expand Down
18 changes: 9 additions & 9 deletions src/export-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ module.exports = ({
} = await dialog.showSaveDialog(
win,
{
title: i18next.t('common.exportDB.saveDialog.title'),
title: i18next.t('exportDB.saveDialog.title'),
defaultPath,
buttonLabel: i18next
.t('common.exportDB.saveDialog.buttonLabel'),
.t('exportDB.saveDialog.buttonLabel'),
filters: [{ name: 'ZIP', extensions: ['zip'] }]
}
)
Expand All @@ -70,7 +70,7 @@ module.exports = ({

await showLoadingWindow({
description: i18next
.t('common.exportDB.loadingWindow.description')
.t('exportDB.loadingWindow.description')
})

const progressHandler = async (args) => {
Expand All @@ -79,9 +79,9 @@ module.exports = ({
prettyArchiveSize
} = args ?? {}

const _description = i18next.t('common.exportDB.loadingWindow.description')
const _description = i18next.t('exportDB.loadingWindow.description')
const _archived = i18next.t(
'common.exportDB.loadingWindow.archiveSize',
'exportDB.loadingWindow.archiveSize',
{ prettyArchiveSize }
)

Expand All @@ -103,18 +103,18 @@ module.exports = ({

await showMessageModalDialog(win, {
buttons: [
i18next.t('common.exportDB.modalDialog.confirmButtonText')
i18next.t('common.confirmButtonText')
],
defaultId: 0,
title: i18next.t('common.exportDB.modalDialog.title'),
message: i18next.t('common.exportDB.modalDialog.message')
title: i18next.t('exportDB.modalDialog.title'),
message: i18next.t('exportDB.modalDialog.message')
})
} catch (err) {
try {
await hideLoadingWindow()
await showErrorModalDialog(
win,
i18next.t('common.exportDB.modalDialog.title'),
i18next.t('exportDB.modalDialog.title'),
err
)
} catch (err) {
Expand Down
12 changes: 6 additions & 6 deletions src/import-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ module.exports = ({
} = await dialog.showOpenDialog(
win,
{
title: i18next.t('common.importDB.openDialog.title'),
title: i18next.t('importDB.openDialog.title'),
defaultPath: pathToUserDocuments,
buttonLabel: i18next
.t('common.importDB.openDialog.buttonLabel'),
.t('importDB.openDialog.buttonLabel'),
properties: [
'openFile',
'createDirectory',
Expand Down Expand Up @@ -88,9 +88,9 @@ module.exports = ({
} = args ?? {}

const _description = i18next
.t('common.importDB.loadingWindow.description')
.t('importDB.loadingWindow.description')
const _unzipped = i18next.t(
'common.importDB.loadingWindow.unzippedBytes',
'importDB.loadingWindow.unzippedBytes',
{ prettyUnzippedBytes }
)

Expand All @@ -105,7 +105,7 @@ module.exports = ({
await pauseApp({
loadingWinParams: {
description: i18next
.t('common.importDB.loadingWindow.description')
.t('importDB.loadingWindow.description')
}
})
await _rmDbExcludeMain(pathToUserData, DB_FILE_NAME)
Expand Down Expand Up @@ -135,7 +135,7 @@ module.exports = ({
: win
await showErrorModalDialog(
_win,
i18next.t('common.importDB.modalDialog.title'),
i18next.t('importDB.modalDialog.title'),
err
)
} catch (err) {
Expand Down
Loading

0 comments on commit 13c10b7

Please sign in to comment.