From 6b1e15a58df4b17304d547997714cc7a2777fbf1 Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Thu, 24 Apr 2025 20:15:13 +0200 Subject: [PATCH] Add some translations --- public/locales/en/core.json | 17 +++++- src/components/Group/Forum/NewThread.tsx | 1 + .../Group/Forum/ShowMessageWithoutModal.tsx | 9 ++- src/components/Group/Forum/Thread.tsx | 59 ++++++++++--------- 4 files changed, 51 insertions(+), 35 deletions(-) diff --git a/public/locales/en/core.json b/public/locales/en/core.json index ef134a7..d2caa8f 100644 --- a/public/locales/en/core.json +++ b/public/locales/en/core.json @@ -18,14 +18,25 @@ "version": "core version" }, "description": "description", + "page": { + "last": "last", + "first": "first", + "previous": "previous" + }, + "downloading_qdn": "downloading from QDN", + "edit": "edit", + "export": "export", + "import": "import", "last_height": "last height", "loading": "loading...", + "loading_posts": "loading posts... please wait.", + "logout": "logout", "minting_status": "minting status", - "page": { - "last": "last" - }, + "next": "next", "payment_notification": "payment notification", "price": "price", + "refetch_page": "refetch page", + "return_to_thread": "return to Threads", "q_mail": "q-mail", "result": { "error": { diff --git a/src/components/Group/Forum/NewThread.tsx b/src/components/Group/Forum/NewThread.tsx index 3909686..f83aed9 100644 --- a/src/components/Group/Forum/NewThread.tsx +++ b/src/components/Group/Forum/NewThread.tsx @@ -193,6 +193,7 @@ export const NewThread = ({ postProcess: 'capitalize', }); } + if (!groupInfo) { errorMsg = t('group:result.cannot.group_info', { postProcess: 'capitalize', diff --git a/src/components/Group/Forum/ShowMessageWithoutModal.tsx b/src/components/Group/Forum/ShowMessageWithoutModal.tsx index 7a4e594..914b9c5 100644 --- a/src/components/Group/Forum/ShowMessageWithoutModal.tsx +++ b/src/components/Group/Forum/ShowMessageWithoutModal.tsx @@ -3,7 +3,6 @@ import { Avatar, Box, IconButton } from '@mui/material'; import DOMPurify from 'dompurify'; import FormatQuoteIcon from '@mui/icons-material/FormatQuote'; import MoreSVG from '../../../assets/svgs/More.svg'; - import { MoreImg, MoreP, @@ -38,16 +37,16 @@ export const ShowMessage = ({ message, openNewPostWithQuote, myName }: any) => { > @@ -67,6 +66,7 @@ export const ShowMessage = ({ message, openNewPostWithQuote, myName }: any) => { {message?.name?.charAt(0)} + { > {message?.name} + {formatTimestampForum(message?.created)} @@ -205,6 +206,7 @@ export const ShowMessage = ({ message, openNewPostWithQuote, myName }: any) => { > {message?.reply?.name?.charAt(0)} + { + diff --git a/src/components/Group/Forum/Thread.tsx b/src/components/Group/Forum/Thread.tsx index 2bf2318..2d44b98 100644 --- a/src/components/Group/Forum/Thread.tsx +++ b/src/components/Group/Forum/Thread.tsx @@ -1,20 +1,11 @@ import React, { - FC, useCallback, useEffect, useMemo, useRef, useState, } from 'react'; -import { - Avatar, - Box, - Button, - ButtonBase, - IconButton, - Skeleton, - Typography, -} from '@mui/material'; +import { Avatar, Box, Button, ButtonBase, Typography } from '@mui/material'; import { ShowMessage } from './ShowMessageWithoutModal'; import { ComposeP, @@ -51,8 +42,12 @@ import { RequestQueueWithPromise } from '../../../utils/queue/queue'; import { CustomLoader } from '../../../common/CustomLoader'; import { WrapperUserAction } from '../../WrapperUserAction'; import { formatTimestampForum } from '../../../utils/time'; +import { useTranslation } from 'react-i18next'; + const requestQueueSaveToLocal = new RequestQueueWithPromise(1); + const requestQueueDownloadPost = new RequestQueueWithPromise(3); + interface ThreadProps { currentThread: any; groupInfo: any; @@ -120,6 +115,7 @@ export const Thread = ({ const [isLoading, setIsLoading] = useState(true); const [postReply, setPostReply] = useState(null); const [hasLastPage, setHasLastPage] = useState(false); + const { t } = useTranslation(['core']); // Update: Use a new ref for the scrollable container const threadContainerRef = useRef(null); @@ -251,6 +247,7 @@ export const Thread = ({ 'Content-Type': 'application/json', }, }); + const responseData = await response.json(); let fullArrayMsg = [...responseData]; @@ -431,6 +428,7 @@ export const Thread = ({ } const newArray = responseData.slice(0, findMessage).reverse(); let fullArrayMsg = [...messages]; + for (const message of newArray) { try { const responseDataMessage = await getEncryptedResource({ @@ -468,7 +466,6 @@ export const Thread = ({ setMessages(fullArrayMsg); } catch (error) { console.log(error); - } finally { } }, [messages] @@ -565,20 +562,20 @@ export const Thread = ({ return ( - Return to Threads + + {t('core:return_to_thread', { postProcess: 'capitalize' })} + {/* Conditionally render the scroll buttons */} {showScrollButton && @@ -658,6 +657,7 @@ export const Thread = ({ > {currentThread?.threadData?.title} + - First + {t(core:page.first', { postProcess: 'capitalize' })} + @@ -925,7 +926,7 @@ export const Thread = ({ color: 'white', }} > - Downloading from QDN + {t('core:downloading_qdn', { postProcess: 'capitalize' })} @@ -959,7 +960,7 @@ export const Thread = ({ color: 'white', }} > - Refetch page + {t('core:refetch_page', { postProcess: 'capitalize' })} @@ -997,7 +998,7 @@ export const Thread = ({ disabled={!hasFirstPage} variant="contained" > - First + {t(core:page.first', { postProcess: 'capitalize' })} @@ -1063,7 +1064,7 @@ export const Thread = ({