diff --git a/electron-app/ecoindex-app/src/configs/app.config.ts b/electron-app/ecoindex-app/src/configs/app.config.ts index 597060f..e0abd6c 100644 --- a/electron-app/ecoindex-app/src/configs/app.config.ts +++ b/electron-app/ecoindex-app/src/configs/app.config.ts @@ -4,6 +4,10 @@ export const config = { port: process.env.PORT ? process.env.PORT : 3000, title: pkg.displayName, languages: ['fr', 'en'], + lngs: [ + { code: 'fr', lng: 'Français' }, + { code: 'en', lng: 'English' }, + ], fallbackLng: 'en', namespace: 'translation', } diff --git a/electron-app/ecoindex-app/src/locales/en/translation.json b/electron-app/ecoindex-app/src/locales/en/translation.json index b8fa303..b325780 100644 --- a/electron-app/ecoindex-app/src/locales/en/translation.json +++ b/electron-app/ecoindex-app/src/locales/en/translation.json @@ -31,6 +31,7 @@ "Upgrade": "Upgrade", "Url(s) Mesure (Simple mode)": "Url(s) Mesure (Simple mode)", "View": "View", + "You can change the application language in the menu, Language.": "Vous pouvez changer la langue de l'application dans le menu, Language.", "You have an error but you think it's a bug. Report to the developper by clicking the button (datas are saved to your clipboard) and send theim by mail to ": "You have an error but you think it's a bug. Report to the developper by clicking the button (datas are saved to your clipboard) and send theim by mail to ", "Your Node installation is outdated, you must upgrade it to 20 or upper, upgrade it (you must be admin of your computer)! After upgrade, restart application.": "Your Node installation is outdated, you must upgrade it to 20 or upper, upgrade it (you must be admin of your computer)! After upgrade, restart application.", "en": "en", diff --git a/electron-app/ecoindex-app/src/locales/fr/translation.json b/electron-app/ecoindex-app/src/locales/fr/translation.json index 797b385..e615aba 100644 --- a/electron-app/ecoindex-app/src/locales/fr/translation.json +++ b/electron-app/ecoindex-app/src/locales/fr/translation.json @@ -3,7 +3,7 @@ "&Quit": "&Quitter", "1. Select ouput folder": "to translate", "About": "A propos", - "Browse": "to translate", + "Browse": "Parcourir", "Choose the type of mesure you want to do.": "to translate", "Copy application informations to clipboard.": "to translate", "Copy application informations to clipboard.
Send theim to developper at renaud@greenit.fr.": "to translate", @@ -15,7 +15,7 @@ "Help": "Aide", "Hide App": "Masquer l'application", "Hide Others": "Masquer les autres applications", - "Install": "to translate", + "Install": "Installer", "Key features": "to translate", "Language": "Langue", "Learn More about": "En apprendre plus sur", @@ -31,6 +31,7 @@ "Upgrade": "to translate", "Url(s) Mesure (Simple mode)": "Mesure d'URLs (mode simple)", "View": "Affichage", + "You can change the application language in the menu, Language.": "You can change the application language in the menu, Langue.", "You have an error but you think it's a bug. Report to the developper by clicking the button (datas are saved to your clipboard) and send theim by mail to ": "to translate", "Your Node installation is outdated, you must upgrade it to 20 or upper, upgrade it (you must be admin of your computer)! After upgrade, restart application.": "to translate", "en": "en", diff --git a/electron-app/ecoindex-app/src/main/main.ts b/electron-app/ecoindex-app/src/main/main.ts index 98ae44d..05d5693 100644 --- a/electron-app/ecoindex-app/src/main/main.ts +++ b/electron-app/ecoindex-app/src/main/main.ts @@ -195,10 +195,14 @@ const _createMainWindow = (): void => { channels.CHANGE_LANGUAGE_TO_FRONT, lng ) - getWelcomeWindow().webContents.send( - channels.CHANGE_LANGUAGE_TO_FRONT, - lng - ) + try { + getWelcomeWindow().webContents.send( + channels.CHANGE_LANGUAGE_TO_FRONT, + lng + ) + } catch (error) { + // destroyed after close + } menuFactoryService.buildMenu(app, getMainWindow(), i18n) }) } catch (error) { diff --git a/electron-app/ecoindex-app/src/menus/darwinMenu.ts b/electron-app/ecoindex-app/src/menus/darwinMenu.ts index 71edcb7..93fcaeb 100644 --- a/electron-app/ecoindex-app/src/menus/darwinMenu.ts +++ b/electron-app/ecoindex-app/src/menus/darwinMenu.ts @@ -2,9 +2,7 @@ import { BrowserWindow, app as ElectronApp, shell } from 'electron' import { config } from '../configs/app.config' import i18n from 'i18next' -import i18nBackend from 'i18next-electron-fs-backend' import pkg from '../../package.json' -import whitelist from '../configs/whitelist' export const darwinTemplate = ( app: typeof ElectronApp, @@ -110,14 +108,13 @@ export const darwinTemplate = ( // ), // }, ] - - const languageMenu = config.languages.map((languageCode) => { + const languageMenu = config.lngs.map((languageCode: any) => { return { - label: i18n.t(languageCode), + label: languageCode.lng, type: 'radio', - checked: i18n.language === languageCode, + checked: i18n.language === languageCode.code, click: () => { - i18n.changeLanguage(languageCode) + i18n.changeLanguage(languageCode.code) }, } }) as unknown as Electron.Menu diff --git a/electron-app/ecoindex-app/src/menus/otherMenu.ts b/electron-app/ecoindex-app/src/menus/otherMenu.ts index a341e97..edb09bf 100644 --- a/electron-app/ecoindex-app/src/menus/otherMenu.ts +++ b/electron-app/ecoindex-app/src/menus/otherMenu.ts @@ -78,13 +78,13 @@ export const otherTemplate = ( }, ] - const languageMenu = config.languages.map((languageCode) => { + const languageMenu = config.lngs.map((languageCode: any) => { return { - label: i18n.t(languageCode), + label: languageCode.lng, type: 'radio', - checked: i18n.language === languageCode, + checked: i18n.language === languageCode.code, click: () => { - i18n.changeLanguage(languageCode) + i18n.changeLanguage(languageCode.code) }, } }) as unknown as Electron.Menu diff --git a/electron-app/ecoindex-app/src/renderer/Hello/AppHello.tsx b/electron-app/ecoindex-app/src/renderer/Hello/AppHello.tsx index 1564749..8903306 100644 --- a/electron-app/ecoindex-app/src/renderer/Hello/AppHello.tsx +++ b/electron-app/ecoindex-app/src/renderer/Hello/AppHello.tsx @@ -40,6 +40,11 @@ function HelloApp() {
+

+ {t( + 'You can change the application language in the menu, Language.' + )} +

This desktop application allows you to perform measurements as on the{' '}