add translations for dropzone

This commit is contained in:
Manuel Ruwe
2022-08-24 18:38:28 +02:00
parent 2bf29172fc
commit 14924e4562
7 changed files with 65 additions and 18 deletions

View File

@@ -9,8 +9,12 @@
"label": "Konfigurations Name", "label": "Konfigurations Name",
"placeholder": "Dein neuer Konfigurtionsname" "placeholder": "Dein neuer Konfigurtionsname"
}, },
"buttons:": { "submitButton": "Bestätigen"
"submit": "Bestätigen" },
"events": {
"configSaved": {
"title": "Konfiguration gespeichert",
"message": "Konfiguration gespeichert als {{configName}}"
} }
} }
}, },
@@ -30,5 +34,22 @@
} }
}, },
"saveCopy": "Eine Kopie speichern" "saveCopy": "Eine Kopie speichern"
},
"dropzone": {
"notifications": {
"invalidConfig": {
"title": "Konfiguration konnte nicht geladen werden",
"message": "Konfiguration konnte nicht geladen werden. Invalides JSON"
},
"loadedSuccessfully": {
"title": "Konfiguration {{configName}} wurde erfolgreich geladen"
}
},
"accept": {
"text": "Ziehe Konfigurationen hier um sie hochzuladen. Es werden nur JSON Dateien unterstützt."
},
"reject": {
"text": "Dieses Dateiformat wird nicht unterstützt. Bitte lade nur JSON hoch."
}
} }
} }

View File

@@ -9,8 +9,12 @@
"label": "Config name", "label": "Config name",
"placeholder": "Your new config name" "placeholder": "Your new config name"
}, },
"buttons:": { "submitButton": "Confirm"
"submit": "Confirm" },
"events": {
"configSaved": {
"title": "Config saved",
"message": "Config saved as {{configName}}"
} }
} }
}, },
@@ -30,5 +34,22 @@
} }
}, },
"saveCopy": "Save a copy" "saveCopy": "Save a copy"
},
"dropzone": {
"notifications": {
"invalidConfig": {
"title": "Unable to load config",
"message": "Could not load your config. Invalid JSON format."
},
"loadedSuccessfully": {
"title": "Config {{configName}} loaded successfully"
}
},
"accept": {
"text": "Drag files here to upload a config. Support for JSON only."
},
"reject": {
"text": "This file format is not supported. Please only upload JSON."
}
} }
} }

View File

@@ -3,6 +3,7 @@ import { IconX as X, IconCheck as Check, IconX, IconPhoto, IconUpload } from '@t
import { showNotification } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications';
import { setCookie } from 'cookies-next'; import { setCookie } from 'cookies-next';
import { Dropzone } from '@mantine/dropzone'; import { Dropzone } from '@mantine/dropzone';
import { useTranslation } from 'next-i18next';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
import { Config } from '../../tools/types'; import { Config } from '../../tools/types';
import { migrateToIdConfig } from '../../tools/migrate'; import { migrateToIdConfig } from '../../tools/migrate';
@@ -10,6 +11,7 @@ import { migrateToIdConfig } from '../../tools/migrate';
export default function LoadConfigComponent(props: any) { export default function LoadConfigComponent(props: any) {
const { setConfig } = useConfig(); const { setConfig } = useConfig();
const theme = useMantineTheme(); const theme = useMantineTheme();
const { t } = useTranslation('settings/general/config-changer');
return ( return (
<Dropzone.FullScreen <Dropzone.FullScreen
@@ -20,10 +22,10 @@ export default function LoadConfigComponent(props: any) {
} catch (e) { } catch (e) {
showNotification({ showNotification({
autoClose: 5000, autoClose: 5000,
title: <Text>Error</Text>, title: <Text>{t('dropzone.notifications.invalidConfig.title')}</Text>,
color: 'red', color: 'red',
icon: <X />, icon: <X />,
message: 'could not load your config. Invalid JSON format.', message: t('dropzone.notifications.invalidConfig.message'),
}); });
return; return;
} }
@@ -33,7 +35,9 @@ export default function LoadConfigComponent(props: any) {
radius: 'md', radius: 'md',
title: ( title: (
<Text> <Text>
Config <b>{newConfig.name}</b> loaded successfully {t('dropzone.notifications.loadedSuccessfully.title', {
configName: newConfig.name,
})}
</Text> </Text>
), ),
color: 'green', color: 'green',
@@ -58,7 +62,7 @@ export default function LoadConfigComponent(props: any) {
stroke={1.5} stroke={1.5}
color={theme.colors[theme.primaryColor][theme.colorScheme === 'dark' ? 4 : 6]} color={theme.colors[theme.primaryColor][theme.colorScheme === 'dark' ? 4 : 6]}
/> />
Drag files here to upload a config. Support for JSON only. {t('dropzone.accept.text')}
</Text> </Text>
</Dropzone.Accept> </Dropzone.Accept>
<Dropzone.Reject> <Dropzone.Reject>
@@ -68,7 +72,7 @@ export default function LoadConfigComponent(props: any) {
stroke={1.5} stroke={1.5}
color={theme.colors.red[theme.colorScheme === 'dark' ? 4 : 6]} color={theme.colors.red[theme.colorScheme === 'dark' ? 4 : 6]}
/> />
This file format is not supported. Please only upload JSON. {t('dropzone.reject.text')}
</Text> </Text>
</Dropzone.Reject> </Dropzone.Reject>
<Dropzone.Idle> <Dropzone.Idle>

View File

@@ -36,12 +36,12 @@ export default function SaveConfigComponent(props: any) {
setConfig({ ...config, name: values.configName }); setConfig({ ...config, name: values.configName });
setOpened(false); setOpened(false);
showNotification({ showNotification({
title: 'Config saved', title: t('modal.events.configSaved.title'),
icon: <Check />, icon: <Check />,
color: 'green', color: 'green',
autoClose: 1500, autoClose: 1500,
radius: 'md', radius: 'md',
message: `Config saved as ${values.configName}`, message: t('modal.events.configSaved.message', { configName: values.configName }),
}); });
})} })}
> >
@@ -52,7 +52,7 @@ export default function SaveConfigComponent(props: any) {
{...form.getInputProps('configName')} {...form.getInputProps('configName')}
/> />
<Group position="right" mt="md"> <Group position="right" mt="md">
<Button type="submit">{t('modal.form.buttons.submit')}</Button> <Button type="submit">{t('modal.form.submitButton')}</Button>
</Group> </Group>
</form> </form>
</Modal> </Modal>
@@ -68,22 +68,22 @@ export default function SaveConfigComponent(props: any) {
.delete(`/api/configs/${config.name}`) .delete(`/api/configs/${config.name}`)
.then(() => { .then(() => {
showNotification({ showNotification({
title: t('buttons.delete.deleted.title'), title: t('buttons.delete.notifications.deleted.title'),
icon: <Check />, icon: <Check />,
color: 'green', color: 'green',
autoClose: 1500, autoClose: 1500,
radius: 'md', radius: 'md',
message: t('buttons.delete.deleted.message'), message: t('buttons.delete.notifications.deleted.message'),
}); });
}) })
.catch(() => { .catch(() => {
showNotification({ showNotification({
title: t('buttons.delete.deleteFailed.title'), title: t('buttons.delete.notifications.deleteFailed.title'),
icon: <X />, icon: <X />,
color: 'red', color: 'red',
autoClose: 1500, autoClose: 1500,
radius: 'md', radius: 'md',
message: t('buttons.delete.deleteFailed.message'), message: t('buttons.delete.notifications.deleteFailed.message'),
}); });
}); });
setConfig({ ...config, name: 'default' }); setConfig({ ...config, name: 'default' });

View File

@@ -5,7 +5,7 @@ import { useConfig } from '../../tools/state';
export function OpacitySelector() { export function OpacitySelector() {
const { config, setConfig } = useConfig(); const { config, setConfig } = useConfig();
const { t } = useTranslation('settings/customization/shade-selector'); const { t } = useTranslation('settings/customization/opacity-selector');
const MARKS = [ const MARKS = [
{ value: 10, label: '10' }, { value: 10, label: '10' },

View File

@@ -16,7 +16,7 @@ import { useColorTheme } from '../../tools/color';
export function ShadeSelector() { export function ShadeSelector() {
const { config, setConfig } = useConfig(); const { config, setConfig } = useConfig();
const [opened, setOpened] = useState(false); const [opened, setOpened] = useState(false);
const { t } = useTranslation('settings/general/shade-selector'); const { t } = useTranslation('settings/customization/shade-selector');
const { primaryColor, secondaryColor, primaryShade, setPrimaryShade } = useColorTheme(); const { primaryColor, secondaryColor, primaryShade, setPrimaryShade } = useColorTheme();

View File

@@ -44,6 +44,7 @@ export async function getServerSideProps({
'settings/customization/page-appearance', 'settings/customization/page-appearance',
'settings/customization/shade-selector', 'settings/customization/shade-selector',
'settings/customization/app-width', 'settings/customization/app-width',
'settings/customization/opacity-selector',
'modules/search-module', 'modules/search-module',
'modules/downloads-module', 'modules/downloads-module',
'modules/weather-module', 'modules/weather-module',