From 8bffe20914050bfb3a27eb6b8e2b8bb2d57dfbf4 Mon Sep 17 00:00:00 2001 From: bjarneo Date: Mon, 22 Jan 2024 09:49:43 +0100 Subject: [PATCH] fix: make the header translateable --- public/locales/en/translation.json | 11 +++++++++++ src/client/components/header/index.jsx | 27 +++++++++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index f7d4a267..3b4bd505 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -7,6 +7,17 @@ "instance_settings": "Instance settings", "copied": "Copied", "copy": "Copy", + "header": { + "nav": { + "close": "Close navigation", + "open": "Open navigation" + }, + "session": { + "auth": "Authentication", + "expire": "Your session is about to expire. Do you want to extend it?", + "update": "Update session" + } + }, "home": { "app_subtitle": "Paste a password, confidential message, or private data.", "welcome": "Ensure your sensitive data remains encrypted, secure, and confidential.", diff --git a/src/client/components/header/index.jsx b/src/client/components/header/index.jsx index 4eb01573..07a2996e 100644 --- a/src/client/components/header/index.jsx +++ b/src/client/components/header/index.jsx @@ -4,6 +4,7 @@ import { useDispatch, useSelector } from 'react-redux'; import { Navigate } from 'react-router-dom'; import { Anchor, Burger, Container, Group, Grid, Modal, Button } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; +import { useTranslation } from 'react-i18next'; import Nav from './nav'; import { userLoginChanged, userLogin } from '../../actions/'; @@ -14,12 +15,13 @@ import style from './style.module.css'; import { refresh } from '../../api/authentication.js'; const Header = () => { + const { t } = useTranslation(); const dispatch = useDispatch(); const isLoggedIn = useSelector((state) => state.isLoggedIn); const username = useSelector((state) => state.username); - const [opened, { toggle }] = useDisclosure(false); + const [isMenuOpened, { toggle }] = useDisclosure(false); const [openRefreshModal, { open, close }] = useDisclosure(false); const [redirect, setRedirect] = useState(false); @@ -58,7 +60,9 @@ const Header = () => { return () => clearInterval(interval); }, [openRefreshModal]); - const label = opened ? 'Close navigation' : 'Open navigation'; + const label = isMenuOpened + ? t('header.nav.close', 'Close navigation') + : t('header.nav.open', 'Open navigation'); const handleRefreshCookie = async () => { const cookie = getCookie(); @@ -84,10 +88,19 @@ const Header = () => { <> {redirect && } - -

Your session is about to expire. Do you want to extend it?

+ +

+ {t( + 'header.session.expire', + 'Your session is about to expire. Do you want to extend it?' + )} +

@@ -101,11 +114,11 @@ const Header = () => { - + -