mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
upload translations
This commit is contained in:
@@ -10,8 +10,12 @@
|
|||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
|
|
||||||
|
- Discovery in HomeAssistant don't work with custom base topic. [#596](https://github.com/emsesp/EMS-ESP32/issues/596)
|
||||||
|
|
||||||
## **BREAKING CHANGES:**
|
## **BREAKING CHANGES:**
|
||||||
|
|
||||||
|
- MQTT Discovery (Home Assistant) entity names are now prefixed with the hostname, e.g. `select.thermostat_hc1_mode` becomes `select.emsesp_thermostat_hc1_mode`. You will need to recreate any custom dashboards.
|
||||||
|
|
||||||
# [3.4.2]
|
# [3.4.2]
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
|||||||
@@ -5,11 +5,15 @@ import { useSnackbar } from 'notistack';
|
|||||||
import { extractErrorMessage } from '../../utils';
|
import { extractErrorMessage } from '../../utils';
|
||||||
import { FileUploadConfig } from '../../api/endpoints';
|
import { FileUploadConfig } from '../../api/endpoints';
|
||||||
|
|
||||||
|
import { useI18nContext } from '../../i18n/i18n-react';
|
||||||
|
|
||||||
interface MediaUploadOptions {
|
interface MediaUploadOptions {
|
||||||
upload: (file: File, config?: FileUploadConfig) => AxiosPromise<void>;
|
upload: (file: File, config?: FileUploadConfig) => AxiosPromise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useFileUpload = ({ upload }: MediaUploadOptions) => {
|
const useFileUpload = ({ upload }: MediaUploadOptions) => {
|
||||||
|
const { LL } = useI18nContext();
|
||||||
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
const [uploading, setUploading] = useState<boolean>(false);
|
const [uploading, setUploading] = useState<boolean>(false);
|
||||||
const [uploadProgress, setUploadProgress] = useState<ProgressEvent>();
|
const [uploadProgress, setUploadProgress] = useState<ProgressEvent>();
|
||||||
@@ -42,13 +46,13 @@ const useFileUpload = ({ upload }: MediaUploadOptions) => {
|
|||||||
cancelToken: cancelToken.token
|
cancelToken: cancelToken.token
|
||||||
});
|
});
|
||||||
resetUploadingStates();
|
resetUploadingStates();
|
||||||
enqueueSnackbar('File uploaded', { variant: 'success' });
|
enqueueSnackbar(LL.UPLOAD() + ' ' + LL.SUCCESSFUL(), { variant: 'success' });
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (axios.isCancel(error)) {
|
if (axios.isCancel(error)) {
|
||||||
enqueueSnackbar('Upload aborted', { variant: 'warning' });
|
enqueueSnackbar(LL.UPLOAD() + ' ' + LL.ABORTED(), { variant: 'warning' });
|
||||||
} else {
|
} else {
|
||||||
resetUploadingStates();
|
resetUploadingStates();
|
||||||
enqueueSnackbar(extractErrorMessage(error, 'Upload failed'), { variant: 'error' });
|
enqueueSnackbar(extractErrorMessage(error, LL.UPLOAD() + ' ' + LL.FAILED()), { variant: 'error' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const de: Translation = {
|
|||||||
PASSWORD: 'Passwort',
|
PASSWORD: 'Passwort',
|
||||||
DASHBOARD: 'Armaturenbrett',
|
DASHBOARD: 'Armaturenbrett',
|
||||||
SETTINGS: 'Einstellungen',
|
SETTINGS: 'Einstellungen',
|
||||||
|
SAVED: 'gespeichert',
|
||||||
HELP: 'Hilfe',
|
HELP: 'Hilfe',
|
||||||
LOGGED_IN: 'Eingeloggt als {name}',
|
LOGGED_IN: 'Eingeloggt als {name}',
|
||||||
PLEASE_SIGNIN: 'Bitte einloggen, um fortzufahren',
|
PLEASE_SIGNIN: 'Bitte einloggen, um fortzufahren',
|
||||||
@@ -142,7 +143,11 @@ const de: Translation = {
|
|||||||
HELP_INFORMATION_7: 'um eine neue Funktion anzufordern oder einen Fehler zu melden',
|
HELP_INFORMATION_7: 'um eine neue Funktion anzufordern oder einen Fehler zu melden',
|
||||||
HELP_INFORMATION_8: 'Überzeugen Sie sich auch',
|
HELP_INFORMATION_8: 'Überzeugen Sie sich auch',
|
||||||
HELP_INFORMATION_9: 'und hängen Sie Ihre Systemdetails für eine schnellere Antwort an',
|
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 '
|
HELP_INFORMATION_10: 'EMS-ESP wird immer ein kostenloses Open-Source-Projekt sein. Bitte erwägen Sie, es mit einem',
|
||||||
|
UPLOAD: 'Hochladen',
|
||||||
|
ABORTED: 'abgebrochen',
|
||||||
|
FAILED: 'gescheitert',
|
||||||
|
SUCCESSFUL: 'erfolgreich'
|
||||||
};
|
};
|
||||||
|
|
||||||
export default de;
|
export default de;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const en: BaseTranslation = {
|
|||||||
PASSWORD: 'Password',
|
PASSWORD: 'Password',
|
||||||
DASHBOARD: 'Dashboard',
|
DASHBOARD: 'Dashboard',
|
||||||
SETTINGS: 'Settings',
|
SETTINGS: 'Settings',
|
||||||
|
SAVED: 'saved',
|
||||||
HELP: 'Help',
|
HELP: 'Help',
|
||||||
LOGGED_IN: 'Logged in as {name}',
|
LOGGED_IN: 'Logged in as {name}',
|
||||||
PLEASE_SIGNIN: 'Please sign in to continue',
|
PLEASE_SIGNIN: 'Please sign in to continue',
|
||||||
@@ -142,7 +143,11 @@ const en: BaseTranslation = {
|
|||||||
HELP_INFORMATION_7: 'for requesting a new feature or reporting a bug',
|
HELP_INFORMATION_7: 'for requesting a new feature or reporting a bug',
|
||||||
HELP_INFORMATION_8: 'Make sure you also',
|
HELP_INFORMATION_8: 'Make sure you also',
|
||||||
HELP_INFORMATION_9: 'and attach your system details for a faster response',
|
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 '
|
HELP_INFORMATION_10: 'EMS-ESP will always be a free and open-source project. Please consider supporting it with a',
|
||||||
|
UPLOAD: 'Upload',
|
||||||
|
ABORTED: 'aborted',
|
||||||
|
FAILED: 'failed',
|
||||||
|
SUCCESSFUL: 'successful'
|
||||||
};
|
};
|
||||||
|
|
||||||
export default en;
|
export default en;
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ type RootTranslation = {
|
|||||||
* Settings
|
* Settings
|
||||||
*/
|
*/
|
||||||
SETTINGS: string
|
SETTINGS: string
|
||||||
|
/**
|
||||||
|
* saved
|
||||||
|
*/
|
||||||
|
SAVED: string
|
||||||
/**
|
/**
|
||||||
* Help
|
* Help
|
||||||
*/
|
*/
|
||||||
@@ -575,6 +579,22 @@ type RootTranslation = {
|
|||||||
* EMS-ESP will always be a free and open-source project. Please consider supporting it with a
|
* EMS-ESP will always be a free and open-source project. Please consider supporting it with a
|
||||||
*/
|
*/
|
||||||
HELP_INFORMATION_10: string
|
HELP_INFORMATION_10: string
|
||||||
|
/**
|
||||||
|
* Upload
|
||||||
|
*/
|
||||||
|
UPLOAD: string
|
||||||
|
/**
|
||||||
|
* aborted
|
||||||
|
*/
|
||||||
|
ABORTED: string
|
||||||
|
/**
|
||||||
|
* failed
|
||||||
|
*/
|
||||||
|
FAILED: string
|
||||||
|
/**
|
||||||
|
* successful
|
||||||
|
*/
|
||||||
|
SUCCESSFUL: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TranslationFunctions = {
|
export type TranslationFunctions = {
|
||||||
@@ -610,6 +630,10 @@ export type TranslationFunctions = {
|
|||||||
* Settings
|
* Settings
|
||||||
*/
|
*/
|
||||||
SETTINGS: () => LocalizedString
|
SETTINGS: () => LocalizedString
|
||||||
|
/**
|
||||||
|
* saved
|
||||||
|
*/
|
||||||
|
SAVED: () => LocalizedString
|
||||||
/**
|
/**
|
||||||
* Help
|
* Help
|
||||||
*/
|
*/
|
||||||
@@ -1128,6 +1152,22 @@ export type TranslationFunctions = {
|
|||||||
* EMS-ESP will always be a free and open-source project. Please consider supporting it with a
|
* EMS-ESP will always be a free and open-source project. Please consider supporting it with a
|
||||||
*/
|
*/
|
||||||
HELP_INFORMATION_10: () => LocalizedString
|
HELP_INFORMATION_10: () => LocalizedString
|
||||||
|
/**
|
||||||
|
* Upload
|
||||||
|
*/
|
||||||
|
UPLOAD: () => LocalizedString
|
||||||
|
/**
|
||||||
|
* aborted
|
||||||
|
*/
|
||||||
|
ABORTED: () => LocalizedString
|
||||||
|
/**
|
||||||
|
* failed
|
||||||
|
*/
|
||||||
|
FAILED: () => LocalizedString
|
||||||
|
/**
|
||||||
|
* successful
|
||||||
|
*/
|
||||||
|
SUCCESSFUL: () => LocalizedString
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Formatters = {}
|
export type Formatters = {}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ const HelpInformation: FC = () => {
|
|||||||
|
|
||||||
<Box border={1} p={1} mt={4}>
|
<Box border={1} p={1} mt={4}>
|
||||||
<Typography align="center" variant="h6" color="orange">
|
<Typography align="center" variant="h6" color="orange">
|
||||||
{LL.HELP_INFORMATION_10()}
|
{LL.HELP_INFORMATION_10()}
|
||||||
<Link href="https://github.com/emsesp/EMS-ESP32" color="primary">
|
<Link href="https://github.com/emsesp/EMS-ESP32" color="primary">
|
||||||
{'GitHub'}
|
{'GitHub'}
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -4,12 +4,16 @@ import { AxiosPromise } from 'axios';
|
|||||||
|
|
||||||
import { extractErrorMessage } from '.';
|
import { extractErrorMessage } from '.';
|
||||||
|
|
||||||
|
import { useI18nContext } from '../i18n/i18n-react';
|
||||||
|
|
||||||
export interface RestRequestOptions<D> {
|
export interface RestRequestOptions<D> {
|
||||||
read: () => AxiosPromise<D>;
|
read: () => AxiosPromise<D>;
|
||||||
update?: (value: D) => AxiosPromise<D>;
|
update?: (value: D) => AxiosPromise<D>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useRest = <D>({ read, update }: RestRequestOptions<D>) => {
|
export const useRest = <D>({ read, update }: RestRequestOptions<D>) => {
|
||||||
|
const { LL } = useI18nContext();
|
||||||
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
const [saving, setSaving] = useState<boolean>(false);
|
const [saving, setSaving] = useState<boolean>(false);
|
||||||
@@ -23,11 +27,11 @@ export const useRest = <D>({ read, update }: RestRequestOptions<D>) => {
|
|||||||
try {
|
try {
|
||||||
setData((await read()).data);
|
setData((await read()).data);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
const message = extractErrorMessage(error, 'Problem loading data');
|
const message = extractErrorMessage(error, LL.PROBLEM_LOADING());
|
||||||
enqueueSnackbar(message, { variant: 'error' });
|
enqueueSnackbar(message, { variant: 'error' });
|
||||||
setErrorMessage(message);
|
setErrorMessage(message);
|
||||||
}
|
}
|
||||||
}, [read, enqueueSnackbar]);
|
}, [read, enqueueSnackbar, LL]);
|
||||||
|
|
||||||
const save = useCallback(
|
const save = useCallback(
|
||||||
async (toSave: D) => {
|
async (toSave: D) => {
|
||||||
@@ -43,17 +47,17 @@ export const useRest = <D>({ read, update }: RestRequestOptions<D>) => {
|
|||||||
if (response.status === 202) {
|
if (response.status === 202) {
|
||||||
setRestartNeeded(true);
|
setRestartNeeded(true);
|
||||||
} else {
|
} else {
|
||||||
enqueueSnackbar('Settings saved', { variant: 'success' });
|
enqueueSnackbar(LL.SETTINGS() + ' ' + LL.SAVED(), { variant: 'success' });
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
const message = extractErrorMessage(error, 'Problem saving data');
|
const message = extractErrorMessage(error, LL.PROBLEM_UPDATING());
|
||||||
enqueueSnackbar(message, { variant: 'error' });
|
enqueueSnackbar(message, { variant: 'error' });
|
||||||
setErrorMessage(message);
|
setErrorMessage(message);
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[update, enqueueSnackbar]
|
[update, enqueueSnackbar, LL]
|
||||||
);
|
);
|
||||||
|
|
||||||
const saveData = () => data && save(data);
|
const saveData = () => data && save(data);
|
||||||
|
|||||||
Reference in New Issue
Block a user