Skip to content

Commit

Permalink
feat: continue translate and fixing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hrenaud committed Aug 6, 2024
1 parent 92744c5 commit d2b8917
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 17 deletions.
4 changes: 4 additions & 0 deletions electron-app/ecoindex-app/src/configs/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
1 change: 1 addition & 0 deletions electron-app/ecoindex-app/src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions electron-app/ecoindex-app/src/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br />Send theim to developper at [email protected].": "to translate",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
12 changes: 8 additions & 4 deletions electron-app/ecoindex-app/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 4 additions & 7 deletions electron-app/ecoindex-app/src/menus/darwinMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions electron-app/ecoindex-app/src/menus/otherMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions electron-app/ecoindex-app/src/renderer/Hello/AppHello.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ function HelloApp() {
<DarkModeSwitcher visible={false} />
<Header />
<div className="prose mx-auto !max-w-max dark:prose-invert prose-headings:underline">
<p className="text-sm italic">
{t(
'You can change the application language in the menu, Language.'
)}
</p>
<p>
This desktop application allows you to perform measurements
as on the{' '}
Expand Down

0 comments on commit d2b8917

Please sign in to comment.