Skip to content

Commit

Permalink
Merge pull request #439 from ZIMkaRU/feature/add-translation-support-…
Browse files Browse the repository at this point in the history
…to-enforce-macos-app-location

Add translation support to enforce-macos-app-location module
  • Loading branch information
ezewer authored Nov 8, 2024
2 parents a182f51 + 3d37161 commit 1b4d061
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
15 changes: 15 additions & 0 deletions build/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@
"confirmButtonText": "OK",
"cancelButtonText": "Cancel"
}
},
"enforceMacOSAppLocation": {
"appLocationModalDialog": {
"message": "Move to Applications folder?",
"detail": "{{productName}} must live in the Applications folder to be able to run correctly",
"confirmButtonText": "Move to Applications folder",
"cancelButtonText": "Quit {{productName}}"
},
"loadingWindow": {
"description": "Moving the app..."
},
"appRunningModalDialog": {
"message": "Another version of {{productName}} is currently running. Quit it, then launch this version of the app again",
"confirmButtonText": "OK"
}
}
},
"menu": {
Expand Down
15 changes: 15 additions & 0 deletions build/locales/ru/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@
"confirmButtonText": "OK",
"cancelButtonText": "Отмена"
}
},
"enforceMacOSAppLocation": {
"appLocationModalDialog": {
"message": "Переместить в папку Приложения?",
"detail": "{{productName}} должен находиться в папке Приложения для корректной работы",
"confirmButtonText": "Переместить в папку Приложения",
"cancelButtonText": "Выйти из {{productName}}"
},
"loadingWindow": {
"description": "Перемещение приложения..."
},
"appRunningModalDialog": {
"message": "В настоящее время запущена другая версия {{productName}}. Закройте ее, затем снова запустите эту версию приложения",
"confirmButtonText": "OK"
}
}
},
"menu": {
Expand Down
26 changes: 19 additions & 7 deletions src/enforce-macos-app-location.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const { app, dialog } = require('electron')
const i18next = require('i18next')

const productName = require('./helpers/product-name')
const {
Expand All @@ -22,11 +23,18 @@ module.exports = async () => {

const clickedButtonIndex = dialog.showMessageBoxSync({
type: 'error',
message: 'Move to Applications folder?',
detail: `${productName} must live in the Applications folder to be able to run correctly.`,
message: i18next
.t('common.enforceMacOSAppLocation.appLocationModalDialog.message'),
detail: i18next.t(
'common.enforceMacOSAppLocation.appLocationModalDialog.detail',
{ productName }
),
buttons: [
'Move to Applications folder',
`Quit ${productName}`
i18next.t('common.enforceMacOSAppLocation.appLocationModalDialog.confirmButtonText'),
i18next.t(
'common.enforceMacOSAppLocation.appLocationModalDialog.cancelButtonText',
{ productName }
)
],
defaultId: 0,
cancelId: 1
Expand All @@ -39,7 +47,8 @@ module.exports = async () => {
}

await showLoadingWindow({
description: 'Moving the app...',
description: i18next
.t('common.enforceMacOSAppLocation.loadingWindow.description'),
isRequiredToCloseAllWins: true,
isIndeterminateMode: true
})
Expand All @@ -49,9 +58,12 @@ module.exports = async () => {
if (conflict === 'existsAndRunning') {
dialog.showMessageBoxSync({
type: 'error',
message: `Another version of ${productName} is currently running. Quit it, then launch this version of the app again.`,
message: i18next.t(
'common.enforceMacOSAppLocation.appRunningModalDialog.message',
{ productName }
),
buttons: [
'OK'
i18next.t('common.enforceMacOSAppLocation.appRunningModalDialog.confirmButtonText')
]
})

Expand Down

0 comments on commit 1b4d061

Please sign in to comment.