mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-19 07:55:25 +02:00
refactor: Improve i18n for settings alias preferences
This commit is contained in:
parent
76b3fc640d
commit
2b6364478b
@ -52,7 +52,8 @@
|
|||||||
"yesLabel": "Yes",
|
"yesLabel": "Yes",
|
||||||
"noLabel": "No",
|
"noLabel": "No",
|
||||||
"continueLabel": "Continue",
|
"continueLabel": "Continue",
|
||||||
"unavailableValue": "Unavailable"
|
"unavailableValue": "Unavailable",
|
||||||
|
"experimentalFeatureExplanation": "This is an experimental feature."
|
||||||
},
|
},
|
||||||
"noSearchResults": {
|
"noSearchResults": {
|
||||||
"title": "Nothing found",
|
"title": "Nothing found",
|
||||||
|
5
public/locales/en-US/settings-preferences.json
Normal file
5
public/locales/en-US/settings-preferences.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"title": "Alias Preferences",
|
||||||
|
"description": "Select default values for your aliases. This only affects aliases you haven't set a custom value for.",
|
||||||
|
"continueActionLabel": "Save preferences"
|
||||||
|
}
|
7
public/locales/en-US/settings.json
Normal file
7
public/locales/en-US/settings.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"title": "Settings",
|
||||||
|
"actions": {
|
||||||
|
"enable2fa": "Two-Factor-Authentication",
|
||||||
|
"aliasPreferences": "Alias Preferences"
|
||||||
|
}
|
||||||
|
}
|
@ -90,18 +90,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"SettingsRoute": {
|
"SettingsRoute": {
|
||||||
"title": "Settings",
|
|
||||||
"forms": {
|
"forms": {
|
||||||
"aliasPreferences": {
|
"aliasPreferences": {
|
||||||
"title": "Alias Preferences",
|
|
||||||
"description": "Select default values for your aliases. This only affects aliases you haven't set a custom value for.",
|
|
||||||
"saveAction": "Save preferences"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"actions": {
|
|
||||||
"enable2fa": "Two-Factor-Authentication",
|
|
||||||
"aliasPreferences": "Alias Preferences"
|
|
||||||
},
|
|
||||||
"2fa": {
|
"2fa": {
|
||||||
"title": "Two-Factor-Authentication",
|
"title": "Two-Factor-Authentication",
|
||||||
"alreadyEnabled": "You have successfully enabled 2FA!",
|
"alreadyEnabled": "You have successfully enabled 2FA!",
|
||||||
|
@ -44,30 +44,26 @@ interface Form {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function SettingsAliasPreferencesRoute(): ReactElement {
|
export default function SettingsAliasPreferencesRoute(): ReactElement {
|
||||||
|
const {t} = useTranslation(["aliases", "settings-preferences", "common"])
|
||||||
const {_updateUser} = useContext(AuthContext)
|
const {_updateUser} = useContext(AuthContext)
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
const {showError, showSuccess} = useErrorSuccessSnacks()
|
const {showError, showSuccess} = useErrorSuccessSnacks()
|
||||||
const {t} = useTranslation()
|
|
||||||
|
|
||||||
const schema = yup.object().shape({
|
const schema = yup.object().shape({
|
||||||
removeTrackers: yup.boolean().label(t("relations.alias.settings.removeTrackers.label")),
|
removeTrackers: yup.boolean().label(t("settings.fields.removeTrackers.label")),
|
||||||
createMailReport: yup
|
createMailReport: yup.boolean().label(t("settings.fields.createMailReport.label")),
|
||||||
.boolean()
|
proxyImages: yup.boolean().label(t("settings.fields.proxyImages.label")),
|
||||||
.label(t("relations.alias.settings.createMailReports.label")),
|
|
||||||
proxyImages: yup.boolean().label(t("relations.alias.settings.proxyImages.label")),
|
|
||||||
imageProxyFormat: yup
|
imageProxyFormat: yup
|
||||||
.mixed<ImageProxyFormatType>()
|
.mixed<ImageProxyFormatType>()
|
||||||
.oneOf(Object.values(ImageProxyFormatType))
|
.oneOf(Object.values(ImageProxyFormatType))
|
||||||
.required()
|
.required()
|
||||||
.label(t("relations.alias.settings.imageProxyFormat.label")),
|
.label(t("settings.fields.imageProxyFormat.label")),
|
||||||
proxyUserAgent: yup
|
proxyUserAgent: yup
|
||||||
.mixed<ProxyUserAgentType>()
|
.mixed<ProxyUserAgentType>()
|
||||||
.oneOf(Object.values(ProxyUserAgentType))
|
.oneOf(Object.values(ProxyUserAgentType))
|
||||||
.required()
|
.required()
|
||||||
.label(t("relations.alias.settings.proxyUserAgent.label")),
|
.label(t("settings.fields.proxyUserAgent.label")),
|
||||||
expandUrlShorteners: yup
|
expandUrlShorteners: yup.boolean().label(t("settings.fields.expandUrlShorteners.label")),
|
||||||
.boolean()
|
|
||||||
.label(t("relations.alias.settings.expandUrlShorteners.label")),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const {mutateAsync} = useMutation<SimpleDetailResponse, AxiosError, UpdatePreferencesData>(
|
const {mutateAsync} = useMutation<SimpleDetailResponse, AxiosError, UpdatePreferencesData>(
|
||||||
@ -121,8 +117,8 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<SimplePageBuilder.Page
|
<SimplePageBuilder.Page
|
||||||
title={t("routes.SettingsRoute.forms.aliasPreferences.title")}
|
title={t("title", {ns: "settings-preferences"})}
|
||||||
description={t("routes.SettingsRoute.forms.aliasPreferences.description")}
|
description={t("description", {ns: "settings-preferences"})}
|
||||||
>
|
>
|
||||||
<form onSubmit={formik.handleSubmit}>
|
<form onSubmit={formik.handleSubmit}>
|
||||||
<Grid
|
<Grid
|
||||||
@ -146,7 +142,7 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
labelPlacement="start"
|
labelPlacement="start"
|
||||||
label={t("relations.alias.settings.removeTrackers.label")}
|
label={t("settings.fields.removeTrackers.label")}
|
||||||
/>
|
/>
|
||||||
<FormHelperText
|
<FormHelperText
|
||||||
error={Boolean(
|
error={Boolean(
|
||||||
@ -156,7 +152,7 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
>
|
>
|
||||||
{(formik.touched.createMailReport &&
|
{(formik.touched.createMailReport &&
|
||||||
formik.errors.createMailReport) ||
|
formik.errors.createMailReport) ||
|
||||||
t("relations.alias.settings.removeTrackers.helperText")}
|
t("settings.fields.removeTrackers.helperText")}
|
||||||
</FormHelperText>
|
</FormHelperText>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -174,7 +170,7 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
labelPlacement="start"
|
labelPlacement="start"
|
||||||
label={t("relations.alias.settings.createMailReports.label")}
|
label={t("settings.fields.createMailReport.label")}
|
||||||
/>
|
/>
|
||||||
<FormHelperText
|
<FormHelperText
|
||||||
error={Boolean(
|
error={Boolean(
|
||||||
@ -184,7 +180,7 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
>
|
>
|
||||||
{(formik.touched.createMailReport &&
|
{(formik.touched.createMailReport &&
|
||||||
formik.errors.createMailReport) ||
|
formik.errors.createMailReport) ||
|
||||||
t("relations.alias.settings.createMailReports.helperText")}
|
t("settings.fields.createMailReport.helperText")}
|
||||||
</FormHelperText>
|
</FormHelperText>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -202,7 +198,7 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
labelPlacement="start"
|
labelPlacement="start"
|
||||||
label={t("relations.alias.settings.proxyImages.label")}
|
label={t("settings.fields.proxyImages.label")}
|
||||||
/>
|
/>
|
||||||
<FormHelperText
|
<FormHelperText
|
||||||
error={Boolean(
|
error={Boolean(
|
||||||
@ -210,13 +206,13 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{(formik.touched.proxyImages && formik.errors.proxyImages) ||
|
{(formik.touched.proxyImages && formik.errors.proxyImages) ||
|
||||||
t("relations.alias.settings.proxyImages.helperText")}
|
t("settings.fields.proxyImages.helperText")}
|
||||||
</FormHelperText>
|
</FormHelperText>
|
||||||
<Alert
|
<Alert
|
||||||
sx={{width: "fit-content", alignSelf: "end", marginTop: 1}}
|
sx={{width: "fit-content", alignSelf: "end", marginTop: 1}}
|
||||||
severity="warning"
|
severity="warning"
|
||||||
>
|
>
|
||||||
{t("general.experimentalFeature")}
|
{t("general.experimentalFeatureExplanation", {ns: "common"})}
|
||||||
</Alert>
|
</Alert>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<Collapse in={formik.values.proxyImages}>
|
<Collapse in={formik.values.proxyImages}>
|
||||||
@ -242,9 +238,7 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
}}
|
}}
|
||||||
name="imageProxyFormat"
|
name="imageProxyFormat"
|
||||||
id="imageProxyFormat"
|
id="imageProxyFormat"
|
||||||
label={t(
|
label={t("settings.fields.imageProxyFormat.label")}
|
||||||
"relations.alias.settings.imageProxyFormat.label",
|
|
||||||
)}
|
|
||||||
value={formik.values.imageProxyFormat}
|
value={formik.values.imageProxyFormat}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
disabled={formik.isSubmitting}
|
disabled={formik.isSubmitting}
|
||||||
@ -286,7 +280,7 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
select
|
select
|
||||||
name="proxyUserAgent"
|
name="proxyUserAgent"
|
||||||
id="proxyUserAgent"
|
id="proxyUserAgent"
|
||||||
label={t("relations.alias.settings.proxyUserAgent.label")}
|
label={t("settings.fields.proxyUserAgent.label")}
|
||||||
value={formik.values.proxyUserAgent}
|
value={formik.values.proxyUserAgent}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
disabled={formik.isSubmitting}
|
disabled={formik.isSubmitting}
|
||||||
@ -312,7 +306,7 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{(formik.touched.proxyUserAgent && formik.errors.proxyUserAgent) ||
|
{(formik.touched.proxyUserAgent && formik.errors.proxyUserAgent) ||
|
||||||
t("relations.alias.settings.proxyUserAgent.helperText")}
|
t("settings.fields.proxyUserAgent.helperText")}
|
||||||
</FormHelperText>
|
</FormHelperText>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -330,7 +324,7 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
labelPlacement="start"
|
labelPlacement="start"
|
||||||
label={t("relations.alias.settings.expandUrlShorteners.label")}
|
label={t("settings.fields.expandUrlShorteners.label")}
|
||||||
/>
|
/>
|
||||||
<FormHelperText
|
<FormHelperText
|
||||||
error={Boolean(
|
error={Boolean(
|
||||||
@ -340,13 +334,13 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
>
|
>
|
||||||
{(formik.touched.expandUrlShorteners &&
|
{(formik.touched.expandUrlShorteners &&
|
||||||
formik.errors.expandUrlShorteners) ||
|
formik.errors.expandUrlShorteners) ||
|
||||||
t("relations.alias.settings.expandUrlShorteners.helperText")}
|
t("settings.fields.expandUrlShorteners.helperText")}
|
||||||
</FormHelperText>
|
</FormHelperText>
|
||||||
<Alert
|
<Alert
|
||||||
sx={{width: "fit-content", alignSelf: "end", marginTop: 1}}
|
sx={{width: "fit-content", alignSelf: "end", marginTop: 1}}
|
||||||
severity="warning"
|
severity="warning"
|
||||||
>
|
>
|
||||||
{t("general.experimentalFeature")}
|
{t("general.experimentalFeatureExplanation", {ns: "common"})}
|
||||||
</Alert>
|
</Alert>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -357,7 +351,7 @@ export default function SettingsAliasPreferencesRoute(): ReactElement {
|
|||||||
type="submit"
|
type="submit"
|
||||||
startIcon={<MdCheckCircle />}
|
startIcon={<MdCheckCircle />}
|
||||||
>
|
>
|
||||||
{t("routes.SettingsRoute.forms.aliasPreferences.saveAction")}
|
{t("continueActionLabel", {ns: "settings-preferences"})}
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</form>
|
</form>
|
||||||
</SimplePageBuilder.Page>
|
</SimplePageBuilder.Page>
|
||||||
|
@ -9,22 +9,22 @@ import {List, ListItemButton, ListItemIcon, ListItemText} from "@mui/material"
|
|||||||
import {SimplePageBuilder} from "~/components"
|
import {SimplePageBuilder} from "~/components"
|
||||||
|
|
||||||
export default function SettingsRoute(): ReactElement {
|
export default function SettingsRoute(): ReactElement {
|
||||||
const {t} = useTranslation()
|
const {t} = useTranslation("settings")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SimplePageBuilder.Page title={t("routes.SettingsRoute.title")}>
|
<SimplePageBuilder.Page title={t("title")}>
|
||||||
<List>
|
<List>
|
||||||
<ListItemButton component={Link} to="/settings/alias-preferences">
|
<ListItemButton component={Link} to="/settings/alias-preferences">
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<GoSettings />
|
<GoSettings />
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText primary={t("routes.SettingsRoute.actions.aliasPreferences")} />
|
<ListItemText primary={t("actions.aliasPreferences")} />
|
||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
<ListItemButton component={Link} to="/settings/2fa">
|
<ListItemButton component={Link} to="/settings/2fa">
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<BsShieldLockFill />
|
<BsShieldLockFill />
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText primary={t("routes.SettingsRoute.actions.enable2fa")} />
|
<ListItemText primary={t("actions.enable2fa")} />
|
||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
</List>
|
</List>
|
||||||
</SimplePageBuilder.Page>
|
</SimplePageBuilder.Page>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user