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

Fix: translate update and folder modals #421

Merged
merged 12 commits into from
Nov 13, 2023
4 changes: 4 additions & 0 deletions assets/locales/de/dialog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"SelectFolderForStorage": "Ordner für {{storageForName}}-Speicher auswählen",
"SelectNodeFolder": "Ordner für die Speicherung von Knotendaten auswählen"
}
10 changes: 10 additions & 0 deletions assets/locales/de/updater.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"UpdateAvailable": "Updates für NiceNode verfügbar",
"DownloadingUpdate": "NiceNode Update wird heruntergeladen...",
"UpdateNiceNode": "Möchten Sie NiceNode jetzt aktualisieren? NiceNode wird nach dem Herunterladen des Updates neu gestartet. Aktualisieren auf Version.",
"Yes": "Ja",
"No": "Nein",
"NoUpdateAvailable": "Kein Update verfügbar",
"ErrorUpdating": "Entschuldigung, beim Aktualisieren von NiceNode ist ein Fehler aufgetreten",
"UnableToInstallUpdate": "Kann die neue Version von NiceNode nicht installieren. Sie können versuchen, die neue Version manuell unter {{downloadLink}} herunterzuladen"
}
4 changes: 4 additions & 0 deletions assets/locales/en/dialog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"SelectFolderForStorage": "Select folder for {{storageForName}} storage",
"SelectNodeFolder": "Select a folder for storing node data"
}
10 changes: 10 additions & 0 deletions assets/locales/en/updater.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"UpdateAvailable": "Updates for NiceNode available",
"DownloadingUpdate": "Downloading NiceNode update...",
"UpdateNiceNode": "Do you want to update NiceNode now? NiceNode will restart after downloading the update. Update to version",
"Yes": "Yes",
"No": "No",
"NoUpdateAvailable": "No update available",
"ErrorUpdating": "Sorry, there was an error updating NiceNode",
"UnableToInstallUpdate": "Unable to install the new version of NiceNode. You can try downloading the new version manually at {{downloadLink}}"
}
4 changes: 4 additions & 0 deletions assets/locales/es/dialog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"SelectFolderForStorage": "Seleccionar carpeta para almacenamiento de {{storageForName}}",
"SelectNodeFolder": "Seleccionar una carpeta para almacenar los datos del nodo"
}
10 changes: 10 additions & 0 deletions assets/locales/es/updater.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"UpdateAvailable": "Actualizaciones disponibles para NiceNode",
"DownloadingUpdate": "Descargando la actualización de NiceNode...",
"UpdateNiceNode": "¿Desea actualizar NiceNode ahora? NiceNode se reiniciará después de descargar la actualización. Actualizar a la versión",
"Yes": "Sí",
"No": "No",
"NoUpdateAvailable": "No hay actualizaciones disponibles",
"ErrorUpdating": "Lo siento, se produjo un error al actualizar NiceNode",
"UnableToInstallUpdate": "No se puede instalar la nueva versión de NiceNode. Puede intentar descargar la nueva versión manualmente en {{downloadLink}}"
}
4 changes: 4 additions & 0 deletions assets/locales/fr/dialog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"SelectFolderForStorage": "Sélectionner un dossier pour le stockage {{storageForName}}",
"SelectNodeFolder": "Sélectionner un dossier pour stocker les données du nœud"
}
10 changes: 10 additions & 0 deletions assets/locales/fr/updater.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"UpdateAvailable": "Mises à jour disponibles pour NiceNode",
"DownloadingUpdate": "Téléchargement de la mise à jour de NiceNode...",
"UpdateNiceNode": "Voulez-vous mettre à jour NiceNode maintenant ? NiceNode redémarrera après le téléchargement de la mise à jour. Mettre à jour vers la version",
"Yes": "Oui",
"No": "Non",
"NoUpdateAvailable": "Aucune mise à jour disponible",
"ErrorUpdating": "Désolé, une erreur s'est produite lors de la mise à jour de NiceNode",
"UnableToInstallUpdate": "Impossible d'installer la nouvelle version de NiceNode. Vous pouvez essayer de télécharger la nouvelle version manuellement à {{downloadLink}}"
}
4 changes: 4 additions & 0 deletions assets/locales/ja/dialog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"SelectFolderForStorage": "{{storageForName}}ストレージ用のフォルダーを選択",
"SelectNodeFolder": "ノードデータを保存するためのフォルダを選択"
}
10 changes: 10 additions & 0 deletions assets/locales/ja/updater.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"UpdateAvailable": "NiceNodeのアップデートが利用可能です",
"DownloadingUpdate": "NiceNodeのアップデートをダウンロード中...",
"UpdateNiceNode": "NiceNodeを今すぐアップデートしますか?アップデートのダウンロード後にNiceNodeが再起動します。バージョンにアップデート",
"Yes": "はい",
"No": "いいえ",
"NoUpdateAvailable": "アップデートはありません",
"ErrorUpdating": "申し訳ありませんが、NiceNodeのアップデート中にエラーが発生しました",
"UnableToInstallUpdate": "NiceNodeの新しいバージョンをインストールできません。{{downloadLink}}で新しいバージョンを手動でダウンロードしてみてください。"
}
4 changes: 4 additions & 0 deletions assets/locales/ru/dialog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"SelectFolderForStorage": "Выберите папку для хранения {{storageForName}}",
"SelectNodeFolder": "Выберите папку для хранения данных узла"
}
10 changes: 10 additions & 0 deletions assets/locales/ru/updater.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"UpdateAvailable": "Доступны обновления для NiceNode",
"DownloadingUpdate": "Загрузка обновления NiceNode...",
"UpdateNiceNode": "Вы хотите обновить NiceNode сейчас? NiceNode перезапустится после загрузки обновления. Обновить до версии",
"Yes": "Да",
"No": "Нет",
"NoUpdateAvailable": "Обновление не доступно",
"ErrorUpdating": "Извините, произошла ошибка при обновлении NiceNode",
"UnableToInstallUpdate": "Не удаётся установить новую версию NiceNode. Вы можете попробовать скачать новую версию вручную по адресу {{downloadLink}}"
}
4 changes: 4 additions & 0 deletions assets/locales/vi/dialog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"SelectFolderForStorage": "Chọn thư mục cho bộ nhớ {{storageForName}}",
"SelectNodeFolder": "Chọn một thư mục để lưu trữ dữ liệu của nút"
}
10 changes: 10 additions & 0 deletions assets/locales/vi/updater.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"UpdateAvailable": "Có cập nhật cho NiceNode",
"DownloadingUpdate": "Đang tải về cập nhật cho NiceNode...",
"UpdateNiceNode": "Bạn có muốn cập nhật NiceNode ngay bây giờ không? NiceNode sẽ khởi động lại sau khi tải xong cập nhật. Cập nhật lên phiên bản",
"Yes": "Có",
"No": "Không",
"NoUpdateAvailable": "Không có cập nhật",
"ErrorUpdating": "Xin lỗi, đã xảy ra lỗi khi cập nhật NiceNode",
"UnableToInstallUpdate": "Không thể cài đặt phiên bản mới của NiceNode. Bạn có thể thử tải xuống phiên bản mới thủ công tại {{downloadLink}}"
}
4 changes: 4 additions & 0 deletions assets/locales/zh/dialog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"SelectFolderForStorage": "选择{{storageForName}}存储的文件夹",
"SelectNodeFolder": "选择一个用于存储节点数据的文件夹"
}
10 changes: 10 additions & 0 deletions assets/locales/zh/updater.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"UpdateAvailable": "NiceNode 有更新",
"DownloadingUpdate": "正在下载 NiceNode 更新...",
"UpdateNiceNode": "您现在要更新 NiceNode 吗?NiceNode 将在下载更新后重新启动。更新到版本",
"Yes": "是",
"No": "否",
"NoUpdateAvailable": "没有可用更新",
"ErrorUpdating": "抱歉,更新 NiceNode 时出现错误",
"UnableToInstallUpdate": "无法安装NiceNode的新版本。您可以尝试在{{downloadLink}}手动下载新版本。"
}
9 changes: 7 additions & 2 deletions src/main/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import logger from './logger';
// eslint-disable-next-line import/no-cycle
import { getMainWindow } from './main';
import { getNode, updateNode } from './state/nodes';
import { i18nMain } from './i18nMain';

const t = i18nMain.getFixedT(null, 'dialog');

export const updateNodeDataDir = async (node: Node, newDataDir: string) => {
node.runtime.dataDir = newDataDir;
Expand Down Expand Up @@ -40,7 +43,9 @@ export const openDialogForNodeDataDir = async (nodeId: NodeId) => {
defaultPath = getNodesDirPath();
}
const result = await dialog.showOpenDialog(mainWindow, {
title: `Select folder for ${node.spec.displayName} storage`,
title: t('SelectFolderForStorage', {
storageForName: node.spec.displayName,
}),
defaultPath,
properties: ['openDirectory'],
});
Expand Down Expand Up @@ -69,7 +74,7 @@ export const openDialogForStorageLocation = async (): Promise<
}
const defaultPath = getNodesDirPath();
const result = await dialog.showOpenDialog(mainWindow, {
title: `Select a folder for storing node data`,
title: t('SelectNodeFolder'),
defaultPath,
properties: ['openDirectory'],
});
Expand Down
32 changes: 32 additions & 0 deletions src/main/i18nMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,50 @@ import { getMenuBuilder } from './main';
import enTranslations from '../../assets/locales/en/translation.json';
import enNotifications from '../../assets/locales/en/notifications.json';
import enWindowMenu from '../../assets/locales/en/windowMenu.json';
import enUpdater from '../../assets/locales/en/updater.json';
import enDialog from '../../assets/locales/en/dialog.json';

import esTranslations from '../../assets/locales/es/translation.json';
import esNotifications from '../../assets/locales/es/notifications.json';
import esWindowMenu from '../../assets/locales/es/windowMenu.json';
import esUpdater from '../../assets/locales/es/updater.json';
import esDialog from '../../assets/locales/es/dialog.json';

import zhTranslations from '../../assets/locales/zh/translation.json';
import zhNotifications from '../../assets/locales/zh/notifications.json';
import zhWindowMenu from '../../assets/locales/zh/windowMenu.json';
import zhUpdater from '../../assets/locales/zh/updater.json';
import zhDialog from '../../assets/locales/zh/dialog.json';

import frTranslations from '../../assets/locales/fr/translation.json';
import frNotifications from '../../assets/locales/fr/notifications.json';
import frWindowMenu from '../../assets/locales/fr/windowMenu.json';
import frUpdater from '../../assets/locales/fr/updater.json';
import frDialog from '../../assets/locales/fr/dialog.json';

import jaTranslations from '../../assets/locales/ja/translation.json';
import jaNotifications from '../../assets/locales/ja/notifications.json';
import jaWindowMenu from '../../assets/locales/ja/windowMenu.json';
import jaUpdater from '../../assets/locales/ja/updater.json';
import jaDialog from '../../assets/locales/ja/dialog.json';

import deTranslations from '../../assets/locales/de/translation.json';
import deNotifications from '../../assets/locales/de/notifications.json';
import deWindowMenu from '../../assets/locales/de/windowMenu.json';
import deUpdater from '../../assets/locales/de/updater.json';
import deDialog from '../../assets/locales/de/dialog.json';

import ruTranslations from '../../assets/locales/ru/translation.json';
import ruNotifications from '../../assets/locales/ru/notifications.json';
import ruWindowMenu from '../../assets/locales/ru/windowMenu.json';
import ruUpdater from '../../assets/locales/ru/updater.json';
import ruDialog from '../../assets/locales/ru/dialog.json';

import viTranslations from '../../assets/locales/vi/translation.json';
import viNotifications from '../../assets/locales/vi/notifications.json';
import viWindowMenu from '../../assets/locales/vi/windowMenu.json';
import viUpdater from '../../assets/locales/vi/updater.json';
import viDialog from '../../assets/locales/vi/dialog.json';

// Default app language is english
const ENGLISH_LANGUAGE_CODE = 'en';
Expand All @@ -49,41 +65,57 @@ i18n.use(I18nextCLILanguageDetector).init({
translation: enTranslations,
notifications: enNotifications,
windowMenu: enWindowMenu,
updater: enUpdater,
dialog: enDialog,
},
es: {
translation: esTranslations,
notifications: esNotifications,
windowMenu: esWindowMenu,
updater: esUpdater,
dialog: esDialog,
},
zh: {
translation: zhTranslations,
notifications: zhNotifications,
windowMenu: zhWindowMenu,
updater: zhUpdater,
dialog: zhDialog,
},
fr: {
translation: frTranslations,
notifications: frNotifications,
windowMenu: frWindowMenu,
updater: frUpdater,
dialog: frDialog,
},
ja: {
translation: jaTranslations,
notifications: jaNotifications,
windowMenu: jaWindowMenu,
updater: jaUpdater,
dialog: jaDialog,
},
de: {
translation: deTranslations,
notifications: deNotifications,
windowMenu: deWindowMenu,
updater: deUpdater,
dialog: deDialog,
},
ru: {
translation: ruTranslations,
notifications: ruNotifications,
windowMenu: ruWindowMenu,
updater: ruUpdater,
dialog: ruDialog,
},
vi: {
translation: viTranslations,
notifications: viNotifications,
windowMenu: viWindowMenu,
updater: viUpdater,
dialog: viDialog,
},

// ... other languages ...
Expand Down
3 changes: 1 addition & 2 deletions src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ const developerMenu: CommonMenuItemConstructorOptions = {
},
],
};

const t = (str: string) => i18nMain.t(str, { ns: 'windowMenu' });
const t = i18nMain.getFixedT(null, 'windowMenu');
export default class MenuBuilder {
mainWindow: BrowserWindow;

Expand Down
27 changes: 16 additions & 11 deletions src/main/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import sleep from 'await-sleep';

import logger, { autoUpdateLogger } from './logger';
import { reportEvent } from './events';
import { i18nMain } from './i18nMain';

let notifyUserIfNoUpdateAvailable: boolean;

const t = i18nMain.getFixedT(null, 'updater');

const intiUpdateHandlers = (browserWindow: BrowserWindow) => {
autoUpdater.on('error', (error) => {
logger.error('autoUpdater:::::::::error', error);
Expand All @@ -16,7 +19,7 @@ const intiUpdateHandlers = (browserWindow: BrowserWindow) => {
logger.info('autoUpdater:::::::::checking-for-update');
});
autoUpdater.on('download-progress', (info) => {
logger.info(`autoUpdater:::::::::download-progress: `, info);
logger.info('autoUpdater:::::::::download-progress: ', info);
});
autoUpdater.on('update-available', async (info: UpdateInfo) => {
logger.info('autoUpdater:::::::::update-available: ', info);
Expand All @@ -25,9 +28,9 @@ const intiUpdateHandlers = (browserWindow: BrowserWindow) => {
dialog
.showMessageBox(browserWindow, {
type: 'info',
title: 'Updates for NiceNode available',
message: `Do you want update NiceNode now? NiceNode will restart after downloading the update. Update to version ${info.version}.`,
buttons: ['Yes', 'No'],
title: t('UpdateAvailable'),
message: `${t('UpdateNiceNode')} ${info.version}.`,
buttons: [t('Yes'), t('No')],
})
.then(async (buttonIndex) => {
// eslint-disable-next-line promise/always-return
Expand All @@ -37,15 +40,15 @@ const intiUpdateHandlers = (browserWindow: BrowserWindow) => {
autoUpdater.downloadUpdate();
dialog.showMessageBox(browserWindow, {
type: 'info',
title: 'Updates for NiceNode available',
message: `Downloading NiceNode update...`,
title: t('UpdateAvailable'),
message: t('DownloadingUpdate'),
});
} else {
console.log('update checkbox not checked');
}
})
.catch((err) => {
console.error('error in update available diaglog: ', err);
console.error('error in update available dialog: ', err);
});
});

Expand All @@ -54,8 +57,8 @@ const intiUpdateHandlers = (browserWindow: BrowserWindow) => {
if (notifyUserIfNoUpdateAvailable) {
dialog.showMessageBox(browserWindow, {
type: 'info',
title: 'No update available',
message: `No update available`,
title: t('NoUpdateAvailable'),
message: t('NoUpdateAvailable'),
});
notifyUserIfNoUpdateAvailable = false;
}
Expand All @@ -71,8 +74,10 @@ const intiUpdateHandlers = (browserWindow: BrowserWindow) => {
logger.error('Error in: autoUpdater.quitAndInstall()');
logger.error(err);
dialog.showErrorBox(
'Sorry, there was an error updating NiceNode',
'Unable to install the new version of NiceNode. You can try downloading the new version manually at https://www.nicenode.xyz/#download',
t('ErrorUpdating'),
t('UnableToInstallUpdate', {
downloadLink: 'https://www.nicenode.xyz/#download',
}),
);
// todo: send error details
reportEvent('ErrorUpdatingNiceNode');
Expand Down