mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
upload translations
This commit is contained in:
@@ -10,8 +10,12 @@
|
||||
|
||||
## Changed
|
||||
|
||||
- Discovery in HomeAssistant don't work with custom base topic. [#596](https://github.com/emsesp/EMS-ESP32/issues/596)
|
||||
|
||||
## **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]
|
||||
|
||||
## Added
|
||||
|
||||
@@ -5,11 +5,15 @@ import { useSnackbar } from 'notistack';
|
||||
import { extractErrorMessage } from '../../utils';
|
||||
import { FileUploadConfig } from '../../api/endpoints';
|
||||
|
||||
import { useI18nContext } from '../../i18n/i18n-react';
|
||||
|
||||
interface MediaUploadOptions {
|
||||
upload: (file: File, config?: FileUploadConfig) => AxiosPromise<void>;
|
||||
}
|
||||
|
||||
const useFileUpload = ({ upload }: MediaUploadOptions) => {
|
||||
const { LL } = useI18nContext();
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const [uploading, setUploading] = useState<boolean>(false);
|
||||
const [uploadProgress, setUploadProgress] = useState<ProgressEvent>();
|
||||
@@ -42,13 +46,13 @@ const useFileUpload = ({ upload }: MediaUploadOptions) => {
|
||||
cancelToken: cancelToken.token
|
||||
});
|
||||
resetUploadingStates();
|
||||
enqueueSnackbar('File uploaded', { variant: 'success' });
|
||||
enqueueSnackbar(LL.UPLOAD() + ' ' + LL.SUCCESSFUL(), { variant: 'success' });
|
||||
} catch (error: unknown) {
|
||||
if (axios.isCancel(error)) {
|
||||
enqueueSnackbar('Upload aborted', { variant: 'warning' });
|
||||
enqueueSnackbar(LL.UPLOAD() + ' ' + LL.ABORTED(), { variant: 'warning' });
|
||||
} else {
|
||||
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',
|
||||
DASHBOARD: 'Armaturenbrett',
|
||||
SETTINGS: 'Einstellungen',
|
||||
SAVED: 'gespeichert',
|
||||
HELP: 'Hilfe',
|
||||
LOGGED_IN: 'Eingeloggt als {name}',
|
||||
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_8: 'Überzeugen Sie sich auch',
|
||||
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;
|
||||
|
||||
@@ -9,6 +9,7 @@ const en: BaseTranslation = {
|
||||
PASSWORD: 'Password',
|
||||
DASHBOARD: 'Dashboard',
|
||||
SETTINGS: 'Settings',
|
||||
SAVED: 'saved',
|
||||
HELP: 'Help',
|
||||
LOGGED_IN: 'Logged in as {name}',
|
||||
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_8: 'Make sure you also',
|
||||
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;
|
||||
|
||||
@@ -46,6 +46,10 @@ type RootTranslation = {
|
||||
* Settings
|
||||
*/
|
||||
SETTINGS: string
|
||||
/**
|
||||
* saved
|
||||
*/
|
||||
SAVED: string
|
||||
/**
|
||||
* Help
|
||||
*/
|
||||
@@ -575,6 +579,22 @@ type RootTranslation = {
|
||||
* EMS-ESP will always be a free and open-source project. Please consider supporting it with a
|
||||
*/
|
||||
HELP_INFORMATION_10: string
|
||||
/**
|
||||
* Upload
|
||||
*/
|
||||
UPLOAD: string
|
||||
/**
|
||||
* aborted
|
||||
*/
|
||||
ABORTED: string
|
||||
/**
|
||||
* failed
|
||||
*/
|
||||
FAILED: string
|
||||
/**
|
||||
* successful
|
||||
*/
|
||||
SUCCESSFUL: string
|
||||
}
|
||||
|
||||
export type TranslationFunctions = {
|
||||
@@ -610,6 +630,10 @@ export type TranslationFunctions = {
|
||||
* Settings
|
||||
*/
|
||||
SETTINGS: () => LocalizedString
|
||||
/**
|
||||
* saved
|
||||
*/
|
||||
SAVED: () => LocalizedString
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
HELP_INFORMATION_10: () => LocalizedString
|
||||
/**
|
||||
* Upload
|
||||
*/
|
||||
UPLOAD: () => LocalizedString
|
||||
/**
|
||||
* aborted
|
||||
*/
|
||||
ABORTED: () => LocalizedString
|
||||
/**
|
||||
* failed
|
||||
*/
|
||||
FAILED: () => LocalizedString
|
||||
/**
|
||||
* successful
|
||||
*/
|
||||
SUCCESSFUL: () => LocalizedString
|
||||
}
|
||||
|
||||
export type Formatters = {}
|
||||
|
||||
@@ -114,7 +114,7 @@ const HelpInformation: FC = () => {
|
||||
|
||||
<Box border={1} p={1} mt={4}>
|
||||
<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">
|
||||
{'GitHub'}
|
||||
</Link>
|
||||
|
||||
@@ -4,12 +4,16 @@ import { AxiosPromise } from 'axios';
|
||||
|
||||
import { extractErrorMessage } from '.';
|
||||
|
||||
import { useI18nContext } from '../i18n/i18n-react';
|
||||
|
||||
export interface RestRequestOptions<D> {
|
||||
read: () => AxiosPromise<D>;
|
||||
update?: (value: D) => AxiosPromise<D>;
|
||||
}
|
||||
|
||||
export const useRest = <D>({ read, update }: RestRequestOptions<D>) => {
|
||||
const { LL } = useI18nContext();
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const [saving, setSaving] = useState<boolean>(false);
|
||||
@@ -23,11 +27,11 @@ export const useRest = <D>({ read, update }: RestRequestOptions<D>) => {
|
||||
try {
|
||||
setData((await read()).data);
|
||||
} catch (error: unknown) {
|
||||
const message = extractErrorMessage(error, 'Problem loading data');
|
||||
const message = extractErrorMessage(error, LL.PROBLEM_LOADING());
|
||||
enqueueSnackbar(message, { variant: 'error' });
|
||||
setErrorMessage(message);
|
||||
}
|
||||
}, [read, enqueueSnackbar]);
|
||||
}, [read, enqueueSnackbar, LL]);
|
||||
|
||||
const save = useCallback(
|
||||
async (toSave: D) => {
|
||||
@@ -43,17 +47,17 @@ export const useRest = <D>({ read, update }: RestRequestOptions<D>) => {
|
||||
if (response.status === 202) {
|
||||
setRestartNeeded(true);
|
||||
} else {
|
||||
enqueueSnackbar('Settings saved', { variant: 'success' });
|
||||
enqueueSnackbar(LL.SETTINGS() + ' ' + LL.SAVED(), { variant: 'success' });
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
const message = extractErrorMessage(error, 'Problem saving data');
|
||||
const message = extractErrorMessage(error, LL.PROBLEM_UPDATING());
|
||||
enqueueSnackbar(message, { variant: 'error' });
|
||||
setErrorMessage(message);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
},
|
||||
[update, enqueueSnackbar]
|
||||
[update, enqueueSnackbar, LL]
|
||||
);
|
||||
|
||||
const saveData = () => data && save(data);
|
||||
|
||||
Reference in New Issue
Block a user