From d8e324a005d2628d12fc83a2318eb9347c54a50e Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 28 Aug 2022 10:44:22 +0200 Subject: [PATCH] translate system menu --- interface/src/SignIn.tsx | 2 +- .../src/components/layout/LayoutMenu.tsx | 9 +- .../src/components/upload/SingleUpload.tsx | 12 +- interface/src/framework/ntp/NTPStatusForm.tsx | 8 +- .../framework/system/GeneralFileUpload.tsx | 32 +-- .../src/framework/system/OTASettingsForm.tsx | 13 +- .../src/framework/system/RestartMonitor.tsx | 11 +- interface/src/framework/system/System.tsx | 15 +- interface/src/framework/system/SystemLog.tsx | 21 +- .../src/framework/system/SystemStatusForm.tsx | 50 ++--- .../src/framework/system/UploadFileForm.tsx | 6 +- interface/src/i18n/de/index.ts | 30 ++- interface/src/i18n/en/index.ts | 28 ++- interface/src/i18n/i18n-types.ts | 200 ++++++++++++++++++ interface/src/project/DashboardData.tsx | 8 +- interface/src/project/HelpInformation.tsx | 4 +- 16 files changed, 366 insertions(+), 83 deletions(-) diff --git a/interface/src/SignIn.tsx b/interface/src/SignIn.tsx index dc67ad09c..9d5d47c51 100644 --- a/interface/src/SignIn.tsx +++ b/interface/src/SignIn.tsx @@ -58,7 +58,7 @@ const SignIn: FC = () => { enqueueSnackbar(LL.INVALID_LOGIN(), { variant: 'warning' }); } } else { - enqueueSnackbar(extractErrorMessage(error, 'Unexpected error, please try again'), { variant: 'error' }); + enqueueSnackbar(extractErrorMessage(error, LL.ERROR()), { variant: 'error' }); } setProcessing(false); } diff --git a/interface/src/components/layout/LayoutMenu.tsx b/interface/src/components/layout/LayoutMenu.tsx index 502f78f0d..b2d049e71 100644 --- a/interface/src/components/layout/LayoutMenu.tsx +++ b/interface/src/components/layout/LayoutMenu.tsx @@ -35,8 +35,13 @@ const LayoutMenu: FC = () => { {features.ntp && } {features.mqtt && } - - + + ); diff --git a/interface/src/components/upload/SingleUpload.tsx b/interface/src/components/upload/SingleUpload.tsx index acdc15071..574f4dae0 100644 --- a/interface/src/components/upload/SingleUpload.tsx +++ b/interface/src/components/upload/SingleUpload.tsx @@ -6,6 +6,8 @@ import { Box, Button, LinearProgress, Theme, Typography, useTheme } from '@mui/m import CloudUploadIcon from '@mui/icons-material/CloudUpload'; import CancelIcon from '@mui/icons-material/Cancel'; +import { useI18nContext } from '../../i18n/i18n-react'; + const progressPercentage = (progress: ProgressEvent) => Math.round((progress.loaded * 100) / progress.total); const getBorderColor = (theme: Theme, props: DropzoneState) => { @@ -41,14 +43,16 @@ const SingleUpload: FC = ({ onDrop, onCancel, uploading, prog const { getRootProps, getInputProps } = dropzoneState; const theme = useTheme(); + const { LL } = useI18nContext(); + const progressText = () => { if (uploading) { if (progress?.lengthComputable) { - return `Uploading: ${progressPercentage(progress)}%`; + return LL.UPLOADING() + `: ${progressPercentage(progress)}%`; } - return 'Uploading\u2026'; + return LL.UPLOADING() + `\u2026`; } - return 'Drop file or click here'; + return LL.UPLOAD_DROP_TEXT(); }; return ( @@ -81,7 +85,7 @@ const SingleUpload: FC = ({ onDrop, onCancel, uploading, prog /> )} diff --git a/interface/src/framework/ntp/NTPStatusForm.tsx b/interface/src/framework/ntp/NTPStatusForm.tsx index 51182af5f..1b9855e69 100644 --- a/interface/src/framework/ntp/NTPStatusForm.tsx +++ b/interface/src/framework/ntp/NTPStatusForm.tsx @@ -31,6 +31,8 @@ import { ButtonRow, FormLoader, SectionContent } from '../../components'; import { extractErrorMessage, formatDateTime, formatLocalDateTime, useRest } from '../../utils'; import { AuthenticatedContext } from '../../contexts/authentication'; +import { useI18nContext } from '../../i18n/i18n-react'; + export const isNtpActive = ({ status }: NTPStatus) => status === NTPSyncStatus.NTP_ACTIVE; export const isNtpEnabled = ({ status }: NTPStatus) => status !== NTPSyncStatus.NTP_DISABLED; @@ -68,6 +70,8 @@ const NTPStatusForm: FC = () => { const { enqueueSnackbar } = useSnackbar(); const { me } = useContext(AuthenticatedContext); + const { LL } = useI18nContext(); + const updateLocalTime = (event: React.ChangeEvent) => setLocalTime(event.target.value); const openSetTime = () => { @@ -83,11 +87,11 @@ const NTPStatusForm: FC = () => { await NTPApi.updateTime({ local_time: formatLocalDateTime(new Date(localTime)) }); - enqueueSnackbar('Time set', { variant: 'success' }); + enqueueSnackbar(LL.TIME_SET(), { variant: 'success' }); setSettingTime(false); loadData(); } catch (error: unknown) { - enqueueSnackbar(extractErrorMessage(error, 'Problem updating time'), { variant: 'error' }); + enqueueSnackbar(extractErrorMessage(error, LL.PROBLEM_UPDATING()), { variant: 'error' }); } finally { setProcessing(false); } diff --git a/interface/src/framework/system/GeneralFileUpload.tsx b/interface/src/framework/system/GeneralFileUpload.tsx index aa41d1e91..8da4835ef 100644 --- a/interface/src/framework/system/GeneralFileUpload.tsx +++ b/interface/src/framework/system/GeneralFileUpload.tsx @@ -14,6 +14,8 @@ import { extractErrorMessage } from '../../utils'; import * as EMSESP from '../../project/api'; +import { useI18nContext } from '../../i18n/i18n-react'; + interface UploadFileProps { uploadGeneralFile: (file: File, config?: FileUploadConfig) => AxiosPromise; } @@ -23,6 +25,8 @@ const GeneralFileUpload: FC = ({ uploadGeneralFile }) => { const { enqueueSnackbar } = useSnackbar(); + const { LL } = useI18nContext(); + const saveFile = (json: any, endpoint: string) => { const a = document.createElement('a'); const filename = 'emsesp_' + endpoint + '.json'; @@ -35,19 +39,19 @@ const GeneralFileUpload: FC = ({ uploadGeneralFile }) => { document.body.appendChild(a); a.click(); document.body.removeChild(a); - enqueueSnackbar('File downloaded', { variant: 'info' }); + enqueueSnackbar(LL.DOWNLOAD_SUCCESSFUL(), { variant: 'info' }); }; const downloadSettings = async () => { try { const response = await EMSESP.getSettings(); if (response.status !== 200) { - enqueueSnackbar('Unable to get settings', { variant: 'error' }); + enqueueSnackbar(LL.PROBLEM_LOADING(), { variant: 'error' }); } else { saveFile(response.data, 'settings'); } } catch (error: unknown) { - enqueueSnackbar(extractErrorMessage(error, 'Problem with downloading'), { variant: 'error' }); + enqueueSnackbar(extractErrorMessage(error, LL.PROBLEM_LOADING()), { variant: 'error' }); } }; @@ -55,47 +59,43 @@ const GeneralFileUpload: FC = ({ uploadGeneralFile }) => { try { const response = await EMSESP.getCustomizations(); if (response.status !== 200) { - enqueueSnackbar('Unable to get customizations', { variant: 'error' }); + enqueueSnackbar(LL.PROBLEM_LOADING(), { variant: 'error' }); } else { saveFile(response.data, 'customizations'); } } catch (error: unknown) { - enqueueSnackbar(extractErrorMessage(error, 'Problem with downloading'), { variant: 'error' }); + enqueueSnackbar(extractErrorMessage(error, LL.PROBLEM_LOADING()), { variant: 'error' }); } }; return ( <> - Upload + {LL.UPLOAD()} {!uploading && ( - - Upload a new firmware (.bin) file, settings or customizations (.json) file below - + {LL.UPLOAD_TEXT()} )} - Download + {LL.DOWNLOAD()} {!uploading && ( <> - Download the application settings. Be careful when sharing your settings as this file contains passwords - and other sensitive system information + {LL.DOWNLOAD_SETTINGS_TEXT()} - - Download the entity customizations + {LL.DOWNLOAD_CUSTOMIZATION_TEXT()}{' '} )} diff --git a/interface/src/framework/system/OTASettingsForm.tsx b/interface/src/framework/system/OTASettingsForm.tsx index cec00f8d2..a35ecc741 100644 --- a/interface/src/framework/system/OTASettingsForm.tsx +++ b/interface/src/framework/system/OTASettingsForm.tsx @@ -12,6 +12,7 @@ import { ValidatedPasswordField, ValidatedTextField } from '../../components'; + import { OTASettings } from '../../types'; import { numberValue, updateValue, useRest } from '../../utils'; @@ -19,12 +20,16 @@ import { ValidateFieldsError } from 'async-validator'; import { validate } from '../../validators'; import { OTA_SETTINGS_VALIDATOR } from '../../validators/system'; +import { useI18nContext } from '../../i18n/i18n-react'; + const OTASettingsForm: FC = () => { const { loadData, saving, data, setData, saveData, errorMessage } = useRest({ read: SystemApi.readOTASettings, update: SystemApi.updateOTASettings }); + const { LL } = useI18nContext(); + const updateFormValue = updateValue(setData); const [fieldErrors, setFieldErrors] = useState(); @@ -48,7 +53,7 @@ const OTASettingsForm: FC = () => { <> } - label="Enable OTA Updates" + label={LL.ENABLE_OTA()} /> { { type="submit" onClick={validateAndSubmit} > - Save + {LL.SAVE()} @@ -88,7 +93,7 @@ const OTASettingsForm: FC = () => { }; return ( - + {content()} ); diff --git a/interface/src/framework/system/RestartMonitor.tsx b/interface/src/framework/system/RestartMonitor.tsx index 3e832f302..c8eb8cb42 100644 --- a/interface/src/framework/system/RestartMonitor.tsx +++ b/interface/src/framework/system/RestartMonitor.tsx @@ -4,6 +4,8 @@ import { FC, useRef, useState } from 'react'; import * as SystemApi from '../../api/system'; import { FormLoader } from '../../components'; +import { useI18nContext } from '../../i18n/i18n-react'; + const RESTART_TIMEOUT = 2 * 60 * 1000; const POLL_TIMEOUT = 2000; const POLL_INTERVAL = 5000; @@ -12,6 +14,8 @@ const RestartMonitor: FC = () => { const [failed, setFailed] = useState(false); const [timeoutId, setTimeoutId] = useState(); + const { LL } = useI18nContext(); + const timeoutAt = useRef(new Date().getTime() + RESTART_TIMEOUT); const poll = useRef(async () => { try { @@ -32,12 +36,7 @@ const RestartMonitor: FC = () => { useEffect(() => () => timeoutId && clearTimeout(timeoutId), [timeoutId]); - return ( - - ); + return ; }; export default RestartMonitor; diff --git a/interface/src/framework/system/System.tsx b/interface/src/framework/system/System.tsx index e8e38e391..3d77ebd06 100644 --- a/interface/src/framework/system/System.tsx +++ b/interface/src/framework/system/System.tsx @@ -12,8 +12,13 @@ import OTASettingsForm from './OTASettingsForm'; import SystemLog from './SystemLog'; +import { useI18nContext } from '../../i18n/i18n-react'; + const System: FC = () => { - useLayoutTitle('System'); + + const { LL } = useI18nContext(); + + useLayoutTitle(LL.SYSTEM()); const { me } = useContext(AuthenticatedContext); const { features } = useContext(FeaturesContext); @@ -22,11 +27,11 @@ const System: FC = () => { return ( <> - - + + - {features.ota && } - {features.upload_firmware && } + {features.ota && } + {features.upload_firmware && } } /> diff --git a/interface/src/framework/system/SystemLog.tsx b/interface/src/framework/system/SystemLog.tsx index 9d5413aa6..dff0c3f1d 100644 --- a/interface/src/framework/system/SystemLog.tsx +++ b/interface/src/framework/system/SystemLog.tsx @@ -15,6 +15,9 @@ import DownloadIcon from '@mui/icons-material/GetApp'; import { useSnackbar } from 'notistack'; import { EVENT_SOURCE_ROOT } from '../../api/endpoints'; + +import { useI18nContext } from '../../i18n/i18n-react'; + export const LOG_EVENTSOURCE_URL = EVENT_SOURCE_ROOT + 'log'; const useWindowSize = () => { @@ -63,6 +66,8 @@ const levelLabel = (level: LogLevel) => { const SystemLog: FC = () => { useWindowSize(); + const { LL } = useI18nContext(); + const { loadData, data, setData } = useRest({ read: SystemApi.readLogSettings }); @@ -104,10 +109,10 @@ const SystemLog: FC = () => { compact: data.compact }); if (response.status !== 200) { - enqueueSnackbar('Problem applying log settings', { variant: 'error' }); + enqueueSnackbar(LL.PROBLEM_UPDATING(), { variant: 'error' }); } } catch (error: unknown) { - enqueueSnackbar(extractErrorMessage(error, 'Problem applying log settings'), { variant: 'error' }); + enqueueSnackbar(extractErrorMessage(error, LL.PROBLEM_UPDATING()), { variant: 'error' }); } } }; @@ -159,9 +164,9 @@ const SystemLog: FC = () => { try { setLogEntries((await SystemApi.readLogEntries()).data); } catch (error: unknown) { - setErrorMessage(extractErrorMessage(error, 'Failed to fetch log')); + setErrorMessage(extractErrorMessage(error, LL.PROBLEM_LOADING())); } - }, []); + }, [LL]); useEffect(() => { fetchLog(); @@ -214,7 +219,7 @@ const SystemLog: FC = () => { - Buffer size + {LL.BUFFER_SIZE()} { } - label="Compact" + label={LL.COMPACT()} /> @@ -273,7 +278,7 @@ const SystemLog: FC = () => { }; return ( - + {content()} ); diff --git a/interface/src/framework/system/SystemStatusForm.tsx b/interface/src/framework/system/SystemStatusForm.tsx index 52c1a3a4b..ffd889fa9 100644 --- a/interface/src/framework/system/SystemStatusForm.tsx +++ b/interface/src/framework/system/SystemStatusForm.tsx @@ -39,6 +39,8 @@ import { AuthenticatedContext } from '../../contexts/authentication'; import axios from 'axios'; +import { useI18nContext } from '../../i18n/i18n-react'; + export const VERSIONCHECK_ENDPOINT = 'https://api.github.com/repos/emsesp/EMS-ESP32/releases/latest'; export const VERSIONCHECK_DEV_ENDPOINT = 'https://api.github.com/repos/emsesp/EMS-ESP32/releases/tags/latest'; export const uploadURL = window.location.origin + '/system/upload'; @@ -48,6 +50,8 @@ function formatNumber(num: number) { } const SystemStatusForm: FC = () => { + const { LL } = useI18nContext(); + const { loadData, data, errorMessage } = useRest({ read: SystemApi.readSystemStatus }); const { me } = useContext(AuthenticatedContext); @@ -80,9 +84,9 @@ const SystemStatusForm: FC = () => { setProcessing(true); try { await SystemApi.restart(); - enqueueSnackbar('EMS-ESP is restarting...', { variant: 'info' }); + enqueueSnackbar(LL.APPLICATION_RESTARTING(), { variant: 'info' }); } catch (error: unknown) { - enqueueSnackbar(extractErrorMessage(error, 'Problem restarting device'), { variant: 'error' }); + enqueueSnackbar(extractErrorMessage(error, LL.PROBLEM_LOADING()), { variant: 'error' }); } finally { setConfirmRestart(false); setProcessing(false); @@ -92,7 +96,7 @@ const SystemStatusForm: FC = () => { const renderRestartDialog = () => ( setConfirmRestart(false)}> Restart - Are you sure you want to restart EMS-ESP? + {LL.RESTART_TEXT()} @@ -178,9 +178,9 @@ const SystemStatusForm: FC = () => { setProcessing(true); try { await SystemApi.factoryReset(); - enqueueSnackbar('Device has been factory reset and will now restart', { variant: 'info' }); + enqueueSnackbar(LL.SYSTEM_FACTORY_TEXT(), { variant: 'info' }); } catch (error: unknown) { - enqueueSnackbar(extractErrorMessage(error, 'Problem factory resetting the device'), { variant: 'error' }); + enqueueSnackbar(extractErrorMessage(error, LL.PROBLEM_UPDATING()), { variant: 'error' }); } finally { setConfirmFactoryReset(false); setProcessing(false); @@ -189,8 +189,8 @@ const SystemStatusForm: FC = () => { const renderFactoryResetDialog = () => ( setConfirmFactoryReset(false)}> - Factory Reset - Are you sure you want to reset the device to its factory defaults? + {LL.FACTORY_RESET()} + {LL.SYSTEM_FACTORY_TEXT_DIALOG()} @@ -231,7 +231,7 @@ const SystemStatusForm: FC = () => { {latestVersion && ( )} @@ -335,7 +335,7 @@ const SystemStatusForm: FC = () => { @@ -348,7 +348,7 @@ const SystemStatusForm: FC = () => { color="primary" onClick={() => setConfirmRestart(true)} > - Restart + {LL.RESTART()} @@ -370,7 +370,7 @@ const SystemStatusForm: FC = () => { }; return ( - + {content()} ); diff --git a/interface/src/framework/system/UploadFileForm.tsx b/interface/src/framework/system/UploadFileForm.tsx index 67db93083..5a5948217 100644 --- a/interface/src/framework/system/UploadFileForm.tsx +++ b/interface/src/framework/system/UploadFileForm.tsx @@ -7,9 +7,13 @@ import { FileUploadConfig } from '../../api/endpoints'; import GeneralFileUpload from './GeneralFileUpload'; import RestartMonitor from './RestartMonitor'; +import { useI18nContext } from '../../i18n/i18n-react'; + const UploadFileForm: FC = () => { const [restarting, setRestarting] = useState(); + const { LL } = useI18nContext(); + const uploadFile = useRef(async (file: File, config?: FileUploadConfig) => { const response = await SystemApi.uploadFile(file, config); setRestarting(true); @@ -17,7 +21,7 @@ const UploadFileForm: FC = () => { }); return ( - + {restarting ? : } ); diff --git a/interface/src/i18n/de/index.ts b/interface/src/i18n/de/index.ts index 3249d7f89..7c17858c4 100644 --- a/interface/src/i18n/de/index.ts +++ b/interface/src/i18n/de/index.ts @@ -14,6 +14,7 @@ const de: Translation = { LOGGED_IN: 'Eingeloggt als {name}', PLEASE_SIGNIN: 'Bitte einloggen, um fortzufahren', UPLOAD_SUCCESSFUL: 'Hochladen erfolgreich', + DOWNLOAD_SUCCESSFUL: 'DE_Download successful', INVALID_LOGIN: 'Ungültige Login Daten', NETWORK_CONNECTION: 'Netzwerkverbindung', SECURITY: 'Sicherheit', @@ -24,7 +25,7 @@ const de: Translation = { DESCRIPTION: 'Bezeichnung', ENTITIES: 'Entitäten', REFRESH: 'Aktualisierung', - EXPORT: 'Export', + EXPORT: 'DE_Export', ENTITY_NAME: 'Entitätsname', VALUE: 'Wert', SHOW_FAV: 'nur Favoriten anzeigen', @@ -145,9 +146,34 @@ const de: Translation = { HELP_INFORMATION_9: 'und hängen Sie Ihre Systemdetails für eine schnellere Antwort an', HELP_INFORMATION_10: 'EMS-ESP wird immer ein kostenloses Open-Source-Projekt sein. Bitte erwägen Sie, es mit einem', UPLOAD: 'Hochladen', + DOWNLOAD: 'DE_Download', ABORTED: 'abgebrochen', FAILED: 'gescheitert', - SUCCESSFUL: 'erfolgreich' + SUCCESSFUL: 'erfolgreich', + SYSTEM: 'DE_System', + LOG: 'DE_Log', + STATUS: 'DE_Status', + UPLOAD_DOWNLOAD: 'DE_Upload/Download', + SYSTEM_VERSION_RUNNING: 'DE_You are currently running version', + SYSTEM_APPLY_FIRMWARE: 'DE_to apply the new firmware', + CLOSE: 'DE_Close', + USE: 'DE_Use', + FACTORY_RESET: 'DE_Factory Reset', + SYSTEM_FACTORY_TEXT: 'DE_Device has been factory reset and will now restart', + SYSTEM_FACTORY_TEXT_DIALOG: 'DE_Are you sure you want to reset the device to its factory defaults?', + VERSION_CHECK: 'DE_Version Check', + THE_LATEST: 'DE_The latest', + BUFFER_SIZE: 'DE_Buffer Size', + COMPACT: 'DE_Compact', + ENABLE_OTA: 'DE_Enable OTA Updates', + DOWNLOAD_CUSTOMIZATION_TEXT: 'DE_Download the entity customizations', + DOWNLOAD_SETTINGS_TEXT: + 'DE_Download the application settings. Be careful when sharing your settings as this file contains passwords and other sensitive system information', + UPLOAD_TEXT: 'DE_Upload a new firmware (.bin) file, settings or customizations (.json) file below', + UPLOADING: 'DE_Uploading', + UPLOAD_DROP_TEXT: 'DE_Drop file or click here', + ERROR: 'DE_Unexpected Error, please try again', + TIME_SET: 'DE_Time set' }; export default de; diff --git a/interface/src/i18n/en/index.ts b/interface/src/i18n/en/index.ts index 6b43b07e8..fc27fe8a9 100644 --- a/interface/src/i18n/en/index.ts +++ b/interface/src/i18n/en/index.ts @@ -14,6 +14,7 @@ const en: BaseTranslation = { LOGGED_IN: 'Logged in as {name}', PLEASE_SIGNIN: 'Please sign in to continue', UPLOAD_SUCCESSFUL: 'Upload successful', + DOWNLOAD_SUCCESSFUL: 'Download successful', INVALID_LOGIN: 'Invalid login details', NETWORK_CONNECTION: 'Network Connection', SECURITY: 'Security', @@ -145,9 +146,34 @@ const en: BaseTranslation = { HELP_INFORMATION_9: 'and attach your system details for a faster response', HELP_INFORMATION_10: 'EMS-ESP will always be a free and open-source project. Please consider supporting it with a', UPLOAD: 'Upload', + DOWNLOAD: 'Download', ABORTED: 'aborted', FAILED: 'failed', - SUCCESSFUL: 'successful' + SUCCESSFUL: 'successful', + SYSTEM: 'System', + LOG: 'Log', + STATUS: 'Status', + UPLOAD_DOWNLOAD: 'Upload/Download', + SYSTEM_VERSION_RUNNING: 'You are currently running version', + SYSTEM_APPLY_FIRMWARE: 'to apply the new firmware', + CLOSE: 'Close', + USE: 'Use', + FACTORY_RESET: 'Factory Reset', + SYSTEM_FACTORY_TEXT: 'Device has been factory reset and will now restart', + SYSTEM_FACTORY_TEXT_DIALOG: 'Are you sure you want to reset the device to its factory defaults?', + VERSION_CHECK: 'Version Check', + THE_LATEST: 'The latest', + BUFFER_SIZE: 'Buffer Size', + COMPACT: 'Compact', + ENABLE_OTA: 'Enable OTA Updates', + DOWNLOAD_CUSTOMIZATION_TEXT: 'Download the entity customizations', + DOWNLOAD_SETTINGS_TEXT: + 'Download the application settings. Be careful when sharing your settings as this file contains passwords and other sensitive system information', + UPLOAD_TEXT: 'Upload a new firmware (.bin) file, settings or customizations (.json) file below', + UPLOADING: 'Uploading', + UPLOAD_DROP_TEXT: 'Drop file or click here', + ERROR: 'Unexpected Error, please try again', + TIME_SET: 'Time set' }; export default en; diff --git a/interface/src/i18n/i18n-types.ts b/interface/src/i18n/i18n-types.ts index 38d2a2e2e..9999086e7 100644 --- a/interface/src/i18n/i18n-types.ts +++ b/interface/src/i18n/i18n-types.ts @@ -67,6 +67,10 @@ type RootTranslation = { * Upload successful */ UPLOAD_SUCCESSFUL: string + /** + * Download successful + */ + DOWNLOAD_SUCCESSFUL: string /** * Invalid login details */ @@ -583,6 +587,10 @@ type RootTranslation = { * Upload */ UPLOAD: string + /** + * Download + */ + DOWNLOAD: string /** * aborted */ @@ -595,6 +603,98 @@ type RootTranslation = { * successful */ SUCCESSFUL: string + /** + * System + */ + SYSTEM: string + /** + * Log + */ + LOG: string + /** + * Status + */ + STATUS: string + /** + * Upload/Download + */ + UPLOAD_DOWNLOAD: string + /** + * You are currently running version + */ + SYSTEM_VERSION_RUNNING: string + /** + * to apply the new firmware + */ + SYSTEM_APPLY_FIRMWARE: string + /** + * Close + */ + CLOSE: string + /** + * Use + */ + USE: string + /** + * Factory Reset + */ + FACTORY_RESET: string + /** + * Device has been factory reset and will now restart + */ + SYSTEM_FACTORY_TEXT: string + /** + * Are you sure you want to reset the device to its factory defaults? + */ + SYSTEM_FACTORY_TEXT_DIALOG: string + /** + * Version Check + */ + VERSION_CHECK: string + /** + * The latest + */ + THE_LATEST: string + /** + * Buffer Size + */ + BUFFER_SIZE: string + /** + * Compact + */ + COMPACT: string + /** + * Enable OTA Updates + */ + ENABLE_OTA: string + /** + * Download the entity customizations + */ + DOWNLOAD_CUSTOMIZATION_TEXT: string + /** + * Download the application settings. Be careful when sharing your settings as this file contains passwords and other sensitive system information + */ + DOWNLOAD_SETTINGS_TEXT: string + /** + * Upload a new firmware (.bin) file, settings or customizations (.json) file below + */ + UPLOAD_TEXT: string + /** + * Uploading + */ + UPLOADING: string + /** + * Drop file or click here + */ + UPLOAD_DROP_TEXT: string + /** + * Unexpected Error, please try again + */ + ERROR: string + /** + * Time set + */ + TIME_SET: string } export type TranslationFunctions = { @@ -650,6 +750,10 @@ export type TranslationFunctions = { * Upload successful */ UPLOAD_SUCCESSFUL: () => LocalizedString + /** + * Download successful + */ + DOWNLOAD_SUCCESSFUL: () => LocalizedString /** * Invalid login details */ @@ -1156,6 +1260,10 @@ export type TranslationFunctions = { * Upload */ UPLOAD: () => LocalizedString + /** + * Download + */ + DOWNLOAD: () => LocalizedString /** * aborted */ @@ -1168,6 +1276,98 @@ export type TranslationFunctions = { * successful */ SUCCESSFUL: () => LocalizedString + /** + * System + */ + SYSTEM: () => LocalizedString + /** + * Log + */ + LOG: () => LocalizedString + /** + * Status + */ + STATUS: () => LocalizedString + /** + * Upload/Download + */ + UPLOAD_DOWNLOAD: () => LocalizedString + /** + * You are currently running version + */ + SYSTEM_VERSION_RUNNING: () => LocalizedString + /** + * to apply the new firmware + */ + SYSTEM_APPLY_FIRMWARE: () => LocalizedString + /** + * Close + */ + CLOSE: () => LocalizedString + /** + * Use + */ + USE: () => LocalizedString + /** + * Factory Reset + */ + FACTORY_RESET: () => LocalizedString + /** + * Device has been factory reset and will now restart + */ + SYSTEM_FACTORY_TEXT: () => LocalizedString + /** + * Are you sure you want to reset the device to its factory defaults? + */ + SYSTEM_FACTORY_TEXT_DIALOG: () => LocalizedString + /** + * Version Check + */ + VERSION_CHECK: () => LocalizedString + /** + * The latest + */ + THE_LATEST: () => LocalizedString + /** + * Buffer Size + */ + BUFFER_SIZE: () => LocalizedString + /** + * Compact + */ + COMPACT: () => LocalizedString + /** + * Enable OTA Updates + */ + ENABLE_OTA: () => LocalizedString + /** + * Download the entity customizations + */ + DOWNLOAD_CUSTOMIZATION_TEXT: () => LocalizedString + /** + * Download the application settings. Be careful when sharing your settings as this file contains passwords and other sensitive system information + */ + DOWNLOAD_SETTINGS_TEXT: () => LocalizedString + /** + * Upload a new firmware (.bin) file, settings or customizations (.json) file below + */ + UPLOAD_TEXT: () => LocalizedString + /** + * Uploading + */ + UPLOADING: () => LocalizedString + /** + * Drop file or click here + */ + UPLOAD_DROP_TEXT: () => LocalizedString + /** + * Unexpected Error, please try again + */ + ERROR: () => LocalizedString + /** + * Time set + */ + TIME_SET: () => LocalizedString } export type Formatters = {} diff --git a/interface/src/project/DashboardData.tsx b/interface/src/project/DashboardData.tsx index 532eef98c..d07c7b442 100644 --- a/interface/src/project/DashboardData.tsx +++ b/interface/src/project/DashboardData.tsx @@ -364,9 +364,9 @@ const DashboardData: FC = () => { try { setCoreData((await EMSESP.readCoreData()).data); } catch (error: unknown) { - enqueueSnackbar(extractErrorMessage(error, 'Failed to fetch core data'), { variant: 'error' }); + enqueueSnackbar(extractErrorMessage(error, LL.PROBLEM_LOADING()), { variant: 'error' }); } - }, [enqueueSnackbar]); + }, [enqueueSnackbar, LL]); useEffect(() => { fetchCoreData(); @@ -385,7 +385,7 @@ const DashboardData: FC = () => { try { setDeviceData((await EMSESP.readDeviceData({ id: unique_id })).data); } catch (error: unknown) { - enqueueSnackbar(extractErrorMessage(error, 'Problem fetching device data'), { variant: 'error' }); + enqueueSnackbar(extractErrorMessage(error, LL.PROBLEM_LOADING()), { variant: 'error' }); } }; @@ -393,7 +393,7 @@ const DashboardData: FC = () => { try { setSensorData((await EMSESP.readSensorData()).data); } catch (error: unknown) { - enqueueSnackbar(extractErrorMessage(error, 'Problem fetching sensor data'), { variant: 'error' }); + enqueueSnackbar(extractErrorMessage(error, LL.PROBLEM_LOADING()), { variant: 'error' }); } }; diff --git a/interface/src/project/HelpInformation.tsx b/interface/src/project/HelpInformation.tsx index 8c0f6562f..443d568be 100644 --- a/interface/src/project/HelpInformation.tsx +++ b/interface/src/project/HelpInformation.tsx @@ -35,7 +35,7 @@ const HelpInformation: FC = () => { document.body.appendChild(a); a.click(); document.body.removeChild(a); - enqueueSnackbar('System information downloaded', { variant: 'info' }); + enqueueSnackbar(LL.DOWNLOAD_SUCCESSFUL(), { variant: 'info' }); }; const callAPI = async (endpoint: string) => { @@ -46,7 +46,7 @@ const HelpInformation: FC = () => { id: 0 }); if (response.status !== 200) { - enqueueSnackbar('API call failed', { variant: 'error' }); + enqueueSnackbar(LL.PROBLEM_LOADING(), { variant: 'error' }); } else { saveFile(response.data, endpoint); }