From 73589623d42c0549bd12fc6f87f02702037adec9 Mon Sep 17 00:00:00 2001 From: Meier Lukas Date: Sat, 5 Aug 2023 17:18:05 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Add=20translations=20for?= =?UTF-8?q?=20board=20customize=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/locales/en/boards/common.json | 5 ++ public/locales/en/boards/customize.json | 26 ++++++++++ .../en/settings/customization/app-width.json | 3 -- .../customization/color-selector.json | 4 -- .../customization/page-appearance.json | 5 +- .../en/settings/general/color-schema.json | 3 -- .../en/settings/general/theme-selector.json | 3 -- .../Appearance/AppearanceCustomization.tsx | 10 ++-- .../Customize/Layout/LayoutCustomization.tsx | 3 +- .../layout/Templates/BoardLayout.tsx | 10 ++-- src/pages/board/[slug].tsx | 4 +- src/pages/board/[slug]/customize.tsx | 49 ++++++++++++++----- src/pages/board/index.tsx | 4 +- src/pages/docker.tsx | 4 +- src/tools/server/translation-namespaces.ts | 11 +---- 15 files changed, 87 insertions(+), 57 deletions(-) create mode 100644 public/locales/en/boards/common.json create mode 100644 public/locales/en/boards/customize.json delete mode 100644 public/locales/en/settings/customization/app-width.json delete mode 100644 public/locales/en/settings/customization/color-selector.json delete mode 100644 public/locales/en/settings/general/color-schema.json delete mode 100644 public/locales/en/settings/general/theme-selector.json diff --git a/public/locales/en/boards/common.json b/public/locales/en/boards/common.json new file mode 100644 index 000000000..18131dfb1 --- /dev/null +++ b/public/locales/en/boards/common.json @@ -0,0 +1,5 @@ +{ + "header": { + "customize": "Customize board" + } +} \ No newline at end of file diff --git a/public/locales/en/boards/customize.json b/public/locales/en/boards/customize.json new file mode 100644 index 000000000..58997d7a7 --- /dev/null +++ b/public/locales/en/boards/customize.json @@ -0,0 +1,26 @@ +{ + "metaTitle": "Customize {{name}} Board", + "pageTitle": "Customization for {{name}} Board", + "backToBoard": "Back to board", + "settings": { + "appearance": { + "primaryColor": "Primary color", + "secondaryColor": "Secondary color" + } + }, + "save": "Save changes", + "notifications": { + "pending": { + "title": "Saving customization", + "message": "Please wait while we save your customization" + }, + "success": { + "title": "Customization saved", + "message": "Your customization has been saved successfully" + }, + "error": { + "title": "Error", + "message": "Unable to save changes" + } + } +} \ No newline at end of file diff --git a/public/locales/en/settings/customization/app-width.json b/public/locales/en/settings/customization/app-width.json deleted file mode 100644 index e7636eef0..000000000 --- a/public/locales/en/settings/customization/app-width.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "label": "App Width" -} \ No newline at end of file diff --git a/public/locales/en/settings/customization/color-selector.json b/public/locales/en/settings/customization/color-selector.json deleted file mode 100644 index 19f42e95b..000000000 --- a/public/locales/en/settings/customization/color-selector.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "colors": "Colors", - "suffix": "{{color}} color" -} \ No newline at end of file diff --git a/public/locales/en/settings/customization/page-appearance.json b/public/locales/en/settings/customization/page-appearance.json index 6f2f9f204..36d24c33c 100644 --- a/public/locales/en/settings/customization/page-appearance.json +++ b/public/locales/en/settings/customization/page-appearance.json @@ -23,8 +23,5 @@ "description": "Further, customize your dashboard using CSS, only recommended for experienced users", "placeholder": "Custom CSS will be applied last", "applying": "Applying CSS..." - }, - "buttons": { - "submit": "Submit" } -} +} \ No newline at end of file diff --git a/public/locales/en/settings/general/color-schema.json b/public/locales/en/settings/general/color-schema.json deleted file mode 100644 index 16672bf7e..000000000 --- a/public/locales/en/settings/general/color-schema.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "label": "Switch to {{scheme}} mode" -} \ No newline at end of file diff --git a/public/locales/en/settings/general/theme-selector.json b/public/locales/en/settings/general/theme-selector.json deleted file mode 100644 index 4e04d5e54..000000000 --- a/public/locales/en/settings/general/theme-selector.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "label": "Switch to {{theme}} mode" -} \ No newline at end of file diff --git a/src/components/Board/Customize/Appearance/AppearanceCustomization.tsx b/src/components/Board/Customize/Appearance/AppearanceCustomization.tsx index eb1109131..257e4e248 100644 --- a/src/components/Board/Customize/Appearance/AppearanceCustomization.tsx +++ b/src/components/Board/Customize/Appearance/AppearanceCustomization.tsx @@ -18,11 +18,7 @@ import Editor from 'react-simple-code-editor'; import { useBoardCustomizationFormContext } from '../form'; export const AppearanceCustomization = () => { - const { t } = useTranslation([ - 'settings/customization/page-appearance', - 'settings/customization/color-selector', - ]); - const theme = useMantineTheme(); + const { t } = useTranslation('settings/customization/page-appearance'); const form = useBoardCustomizationFormContext(); return ( @@ -45,7 +41,7 @@ type ColorSelectorProps = { type: 'primaryColor' | 'secondaryColor'; }; const ColorSelector = ({ type }: ColorSelectorProps) => { - const { t } = useTranslation('settings/customization/color-selector'); + const { t } = useTranslation('boards/customize'); const theme = useMantineTheme(); const form = useBoardCustomizationFormContext(); @@ -55,7 +51,7 @@ const ColorSelector = ({ type }: ColorSelectorProps) => { })); return ( - + {colors.map(({ color, swatch }) => ( { const CustomizeBoardButton = () => { const { name } = useConfigContext(); - console.log('name', name); + const { t } = useTranslation('boards/common'); return ( - + @@ -158,7 +158,7 @@ const ToggleEditModeButton = () => { if (enabled) { return ( - + diff --git a/src/pages/board/[slug].tsx b/src/pages/board/[slug].tsx index 35930bbf0..fb2d30e29 100644 --- a/src/pages/board/[slug].tsx +++ b/src/pages/board/[slug].tsx @@ -7,7 +7,7 @@ import { useInitConfig } from '~/config/init'; import { configExists } from '~/tools/config/configExists'; import { getFrontendConfig } from '~/tools/config/getFrontendConfig'; import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations'; -import { dashboardNamespaces } from '~/tools/server/translation-namespaces'; +import { boardNamespaces } from '~/tools/server/translation-namespaces'; import { ConfigType } from '~/types/config'; export default function BoardPage({ @@ -52,7 +52,7 @@ export const getServerSideProps: GetServerSideProps = a } const config = await getFrontendConfig(routeParams.data.slug); - const translations = await getServerSideTranslations(dashboardNamespaces, locale, req, res); + const translations = await getServerSideTranslations(boardNamespaces, locale, req, res); return { props: { diff --git a/src/pages/board/[slug]/customize.tsx b/src/pages/board/[slug]/customize.tsx index 4627ce260..05a22cbbd 100644 --- a/src/pages/board/[slug]/customize.tsx +++ b/src/pages/board/[slug]/customize.tsx @@ -12,6 +12,7 @@ import { } from '@tabler/icons-react'; import { GetServerSideProps } from 'next'; import { useTranslation } from 'next-i18next'; +import Head from 'next/head'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { ReactNode } from 'react'; @@ -28,7 +29,8 @@ import { MainLayout } from '~/components/layout/Templates/MainLayout'; import { createTrpcServersideHelpers } from '~/server/api/helper'; import { getServerAuthSession } from '~/server/auth'; import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations'; -import { dashboardNamespaces } from '~/tools/server/translation-namespaces'; +import { boardNamespaces } from '~/tools/server/translation-namespaces'; +import { firstUpperCase } from '~/tools/shared/strings'; import { api } from '~/utils/api'; import { useI18nZodResolver } from '~/utils/i18n-zod-resolver'; import { boardCustomizationSchema } from '~/validations/dashboards'; @@ -41,6 +43,7 @@ export default function CustomizationPage() { const { data: config } = api.config.byName.useQuery({ name: query.slug }); const { mutateAsync: saveCusomization, isLoading } = api.config.saveCusomization.useMutation(); const { i18nZodResolver } = useI18nZodResolver(); + const { t } = useTranslation('boards/customize'); const form = useBoardCustomizationForm({ initialValues: { layout: { @@ -75,8 +78,8 @@ export default function CustomizationPage() { if (isLoading) return; showNotification({ id: notificationId, - title: 'Saving customization', - message: 'Please wait while we save your customization', + title: t('notifications.pending.title'), + message: t('notifications.pending.message'), loading: true, }); await saveCusomization( @@ -91,8 +94,8 @@ export default function CustomizationPage() { onSuccess() { updateNotification({ id: notificationId, - title: 'Customization saved', - message: 'Your customization has been saved', + title: t('notifications.success.title'), + message: t('notifications.success.message'), color: 'green', icon: , }); @@ -100,8 +103,8 @@ export default function CustomizationPage() { onError() { updateNotification({ id: notificationId, - title: 'Error', - message: 'Unable to save customization', + title: t('notifications.error.title'), + message: t('notifications.error.message'), color: 'red', icon: , }); @@ -110,20 +113,31 @@ export default function CustomizationPage() { ); }; + const metaTitle = `${t('metaTitle', { + name: firstUpperCase(query.slug), + })} • Homarr`; + return ( + + {metaTitle} + - Customization for {query.slug} Board + + {t('pageTitle', { + name: firstUpperCase(query.slug), + })} + @@ -146,7 +160,7 @@ export default function CustomizationPage() { @@ -200,7 +214,20 @@ export const getServerSideProps: GetServerSideProps = async ({ req, res, locale, helpers.config.byName.prefetch({ name: routeParams.data.slug }); - const translations = await getServerSideTranslations(dashboardNamespaces, locale, req, res); + const translations = await getServerSideTranslations( + [ + 'boards/customize', + 'settings/common', + 'settings/customization/general', + 'settings/customization/page-appearance', + 'settings/customization/shade-selector', + 'settings/customization/opacity-selector', + 'settings/customization/gridstack', + ], + locale, + req, + res + ); return { props: { diff --git a/src/pages/board/index.tsx b/src/pages/board/index.tsx index a367ddef2..f851b30b2 100644 --- a/src/pages/board/index.tsx +++ b/src/pages/board/index.tsx @@ -7,7 +7,7 @@ import { getServerAuthSession } from '~/server/auth'; import { prisma } from '~/server/db'; import { getFrontendConfig } from '~/tools/config/getFrontendConfig'; import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations'; -import { dashboardNamespaces } from '~/tools/server/translation-namespaces'; +import { boardNamespaces } from '~/tools/server/translation-namespaces'; import { ConfigType } from '~/types/config'; export default function BoardPage({ @@ -36,7 +36,7 @@ export const getServerSideProps: GetServerSideProps = a }); const translations = await getServerSideTranslations( - dashboardNamespaces, + boardNamespaces, ctx.locale, ctx.req, ctx.res diff --git a/src/pages/docker.tsx b/src/pages/docker.tsx index 6d6051906..c18faabf4 100644 --- a/src/pages/docker.tsx +++ b/src/pages/docker.tsx @@ -8,7 +8,7 @@ import ContainerActionBar from '~/modules/Docker/ContainerActionBar'; import DockerTable from '~/modules/Docker/DockerTable'; import { getServerAuthSession } from '~/server/auth'; import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations'; -import { dashboardNamespaces } from '~/tools/server/translation-namespaces'; +import { boardNamespaces } from '~/tools/server/translation-namespaces'; import { api } from '~/utils/api'; export default function DockerPage() { @@ -42,7 +42,7 @@ export const getServerSideProps: GetServerSideProps = async ({ locale, req, res }; } - const translations = await getServerSideTranslations(dashboardNamespaces, locale, req, res); + const translations = await getServerSideTranslations(boardNamespaces, locale, req, res); return { props: { ...translations, diff --git a/src/tools/server/translation-namespaces.ts b/src/tools/server/translation-namespaces.ts index 975f6c20a..896c0f759 100644 --- a/src/tools/server/translation-namespaces.ts +++ b/src/tools/server/translation-namespaces.ts @@ -1,4 +1,4 @@ -export const dashboardNamespaces = [ +export const boardNamespaces = [ 'common', 'zod', 'layout/element-selector/selector', @@ -9,18 +9,10 @@ export const dashboardNamespaces = [ 'layout/header/actions/toggle-edit-mode', 'layout/mobile/drawer', 'settings/common', - 'settings/general/theme-selector', 'settings/general/config-changer', 'settings/general/internationalization', 'settings/general/search-engine', 'settings/general/widget-positions', - 'settings/customization/general', - 'settings/customization/color-selector', - 'settings/customization/page-appearance', - 'settings/customization/shade-selector', - 'settings/customization/app-width', - 'settings/customization/opacity-selector', - 'settings/customization/gridstack', 'modules/common', 'modules/date', 'modules/calendar', @@ -46,6 +38,7 @@ export const dashboardNamespaces = [ 'widgets/error-boundary', 'widgets/draggable-list', 'widgets/location', + 'boards/common', ]; export const manageNamespaces = ['user/preferences', 'zod'];