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

Add translation support to auto-updater #430

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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ REPO_BRANCH=master
IS_BFX_API_STAGING=0
IS_DEV_ENV=0
IS_AUTO_UPDATE_DISABLED=0
IS_AUTO_UPDATE_BEING_TESTED=0

SHOULD_LOCALHOST_BE_USED_FOR_LOADING_UI_IN_DEV_MODE=0

Expand Down
26 changes: 26 additions & 0 deletions build/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@
"completedBody": "Your tax report is ready!",
"errorBody": "An unexpected error occurred while generating the tax report!"
}
},
"autoUpdater": {
"loadingWindow": {
"description": "Updating..."
},
"errorToast": {
"title": "Application update failed",
"inetIssueTitle": "Internet disconnected"
},
"checkingForUpdateToast": {
"title": "Checking for update"
},
"updateAvailableToast": {
"title": "An update to v{{version}} is available",
"description": "Starting download..."
},
"updateNotAvailableToast": {
"title": "No updates available"
},
"downloadProgressToast": {
"title": "Downloading..."
},
"updateDownloadedToast": {
"title": "Update v{{version}} downloaded",
"description": "Should the app be updated right now?"
}
}
},
"menu": {
Expand Down
26 changes: 26 additions & 0 deletions build/locales/ru/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@
"completedBody": "Ваш налоговый отчет готов!",
"errorBody": "При формировании налогового отчета произошла непредвиденная ошибка!"
}
},
"autoUpdater": {
"loadingWindow": {
"description": "Обновление..."
},
"errorToast": {
"title": "Обновление приложения не удалось",
"inetIssueTitle": "Интернет отключен"
},
"checkingForUpdateToast": {
"title": "Проверка обновления"
},
"updateAvailableToast": {
"title": "Доступно обновление до версии v{{version}}",
"description": "Начинаем загрузку..."
},
"updateNotAvailableToast": {
"title": "Нет доступных обновлений"
},
"downloadProgressToast": {
"title": "Загрузка..."
},
"updateDownloadedToast": {
"title": "Обновление v{{version}} загружено",
"description": "Стоит ли обновить приложение прямо сейчас?"
}
}
},
"menu": {
Expand Down
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ try {
process.env[key] = val
}
} catch (err) {}
try {
// Uses only in dev mode as dotenv is added into dev deps
require('dotenv').config({ override: true })
} catch (err) {}

const { app } = require('electron')
require('./src/i18next')
Expand Down
27 changes: 17 additions & 10 deletions src/auto-updater/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
} = require('electron-updater')
const Alert = require('electron-alert')
const yaml = require('js-yaml')
const i18next = require('i18next')

const log = require('../error-manager/log')
const BfxMacUpdater = require('./bfx.mac.updater')
Expand Down Expand Up @@ -264,7 +265,7 @@ const _autoUpdaterFactory = () => {

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

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

await _fireToast(
{
title: 'Checking for update',
title: i18next.t('common.autoUpdater.checkingForUpdateToast.title'),
type: 'warning',
timer: 10000
},
Expand All @@ -359,8 +360,11 @@ const _autoUpdaterFactory = () => {

const { value, dismiss } = await _fireToast(
{
title: `An update to v${version} is available`,
text: 'Starting download...',
title: i18next.t(
'common.autoUpdater.updateAvailableToast.title',
{ version }
),
text: i18next.t('common.autoUpdater.updateAvailableToast.description'),
icon: 'info',
timer: 10000
}
Expand Down Expand Up @@ -395,7 +399,7 @@ const _autoUpdaterFactory = () => {

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

await _fireToast(
{
title: 'Downloading...',
title: i18next.t('common.autoUpdater.downloadProgressToast.title'),
icon: 'info'
},
{
Expand Down Expand Up @@ -450,8 +454,11 @@ const _autoUpdaterFactory = () => {

const { value } = await _fireToast(
{
title: `Update v${version} downloaded`,
text: 'Should the app be updated right now?',
title: i18next.t(
'common.autoUpdater.updateDownloadedToast.title',
{ version }
),
text: i18next.t('common.autoUpdater.updateDownloadedToast.description'),
icon: 'question',
timer: 60000,
showCancelButton: true
Expand Down