Add some translations

This commit is contained in:
Nicola Benaglia
2025-04-24 20:15:13 +02:00
parent 7d45d54216
commit 6b1e15a58d
4 changed files with 51 additions and 35 deletions

View File

@@ -18,14 +18,25 @@
"version": "core version" "version": "core version"
}, },
"description": "description", "description": "description",
"page": {
"last": "last",
"first": "first",
"previous": "previous"
},
"downloading_qdn": "downloading from QDN",
"edit": "edit",
"export": "export",
"import": "import",
"last_height": "last height", "last_height": "last height",
"loading": "loading...", "loading": "loading...",
"loading_posts": "loading posts... please wait.",
"logout": "logout",
"minting_status": "minting status", "minting_status": "minting status",
"page": { "next": "next",
"last": "last"
},
"payment_notification": "payment notification", "payment_notification": "payment notification",
"price": "price", "price": "price",
"refetch_page": "refetch page",
"return_to_thread": "return to Threads",
"q_mail": "q-mail", "q_mail": "q-mail",
"result": { "result": {
"error": { "error": {

View File

@@ -193,6 +193,7 @@ export const NewThread = ({
postProcess: 'capitalize', postProcess: 'capitalize',
}); });
} }
if (!groupInfo) { if (!groupInfo) {
errorMsg = t('group:result.cannot.group_info', { errorMsg = t('group:result.cannot.group_info', {
postProcess: 'capitalize', postProcess: 'capitalize',

View File

@@ -3,7 +3,6 @@ import { Avatar, Box, IconButton } from '@mui/material';
import DOMPurify from 'dompurify'; import DOMPurify from 'dompurify';
import FormatQuoteIcon from '@mui/icons-material/FormatQuote'; import FormatQuoteIcon from '@mui/icons-material/FormatQuote';
import MoreSVG from '../../../assets/svgs/More.svg'; import MoreSVG from '../../../assets/svgs/More.svg';
import { import {
MoreImg, MoreImg,
MoreP, MoreP,
@@ -38,16 +37,16 @@ export const ShowMessage = ({ message, openNewPostWithQuote, myName }: any) => {
> >
<Box <Box
sx={{ sx={{
alignItems: 'flex-start',
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
alignItems: 'flex-start',
width: '100%', width: '100%',
}} }}
> >
<Box <Box
sx={{ sx={{
display: 'flex',
alignItems: 'flex-start', alignItems: 'flex-start',
display: 'flex',
gap: '10px', gap: '10px',
}} }}
> >
@@ -67,6 +66,7 @@ export const ShowMessage = ({ message, openNewPostWithQuote, myName }: any) => {
{message?.name?.charAt(0)} {message?.name?.charAt(0)}
</Avatar> </Avatar>
</WrapperUserAction> </WrapperUserAction>
<ThreadInfoColumn> <ThreadInfoColumn>
<WrapperUserAction <WrapperUserAction
disabled={myName === message?.name} disabled={myName === message?.name}
@@ -75,6 +75,7 @@ export const ShowMessage = ({ message, openNewPostWithQuote, myName }: any) => {
> >
<ThreadInfoColumnNameP>{message?.name}</ThreadInfoColumnNameP> <ThreadInfoColumnNameP>{message?.name}</ThreadInfoColumnNameP>
</WrapperUserAction> </WrapperUserAction>
<ThreadInfoColumnTime> <ThreadInfoColumnTime>
{formatTimestampForum(message?.created)} {formatTimestampForum(message?.created)}
</ThreadInfoColumnTime> </ThreadInfoColumnTime>
@@ -205,6 +206,7 @@ export const ShowMessage = ({ message, openNewPostWithQuote, myName }: any) => {
> >
{message?.reply?.name?.charAt(0)} {message?.reply?.name?.charAt(0)}
</Avatar> </Avatar>
<ThreadInfoColumn> <ThreadInfoColumn>
<ThreadInfoColumnNameP <ThreadInfoColumnNameP
sx={{ sx={{
@@ -215,6 +217,7 @@ export const ShowMessage = ({ message, openNewPostWithQuote, myName }: any) => {
</ThreadInfoColumnNameP> </ThreadInfoColumnNameP>
</ThreadInfoColumn> </ThreadInfoColumn>
</Box> </Box>
<MessageDisplay htmlContent={message?.reply?.textContentV2} /> <MessageDisplay htmlContent={message?.reply?.textContentV2} />
</Box> </Box>
<Spacer height="20px" /> <Spacer height="20px" />

View File

@@ -1,20 +1,11 @@
import React, { import React, {
FC,
useCallback, useCallback,
useEffect, useEffect,
useMemo, useMemo,
useRef, useRef,
useState, useState,
} from 'react'; } from 'react';
import { import { Avatar, Box, Button, ButtonBase, Typography } from '@mui/material';
Avatar,
Box,
Button,
ButtonBase,
IconButton,
Skeleton,
Typography,
} from '@mui/material';
import { ShowMessage } from './ShowMessageWithoutModal'; import { ShowMessage } from './ShowMessageWithoutModal';
import { import {
ComposeP, ComposeP,
@@ -51,8 +42,12 @@ import { RequestQueueWithPromise } from '../../../utils/queue/queue';
import { CustomLoader } from '../../../common/CustomLoader'; import { CustomLoader } from '../../../common/CustomLoader';
import { WrapperUserAction } from '../../WrapperUserAction'; import { WrapperUserAction } from '../../WrapperUserAction';
import { formatTimestampForum } from '../../../utils/time'; import { formatTimestampForum } from '../../../utils/time';
import { useTranslation } from 'react-i18next';
const requestQueueSaveToLocal = new RequestQueueWithPromise(1); const requestQueueSaveToLocal = new RequestQueueWithPromise(1);
const requestQueueDownloadPost = new RequestQueueWithPromise(3); const requestQueueDownloadPost = new RequestQueueWithPromise(3);
interface ThreadProps { interface ThreadProps {
currentThread: any; currentThread: any;
groupInfo: any; groupInfo: any;
@@ -120,6 +115,7 @@ export const Thread = ({
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const [postReply, setPostReply] = useState(null); const [postReply, setPostReply] = useState(null);
const [hasLastPage, setHasLastPage] = useState(false); const [hasLastPage, setHasLastPage] = useState(false);
const { t } = useTranslation(['core']);
// Update: Use a new ref for the scrollable container // Update: Use a new ref for the scrollable container
const threadContainerRef = useRef(null); const threadContainerRef = useRef(null);
@@ -251,6 +247,7 @@ export const Thread = ({
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
}); });
const responseData = await response.json(); const responseData = await response.json();
let fullArrayMsg = [...responseData]; let fullArrayMsg = [...responseData];
@@ -431,6 +428,7 @@ export const Thread = ({
} }
const newArray = responseData.slice(0, findMessage).reverse(); const newArray = responseData.slice(0, findMessage).reverse();
let fullArrayMsg = [...messages]; let fullArrayMsg = [...messages];
for (const message of newArray) { for (const message of newArray) {
try { try {
const responseDataMessage = await getEncryptedResource({ const responseDataMessage = await getEncryptedResource({
@@ -468,7 +466,6 @@ export const Thread = ({
setMessages(fullArrayMsg); setMessages(fullArrayMsg);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} finally {
} }
}, },
[messages] [messages]
@@ -565,20 +562,20 @@ export const Thread = ({
return ( return (
<GroupContainer <GroupContainer
sx={{ sx={{
position: 'relative',
width: '100%',
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
overflow: 'hidden', overflow: 'hidden',
position: 'relative',
width: '100%',
}} }}
// Removed the ref from here since the scrollable area has changed // Removed the ref from here since the scrollable area has changed
> >
<Box <Box
sx={{ sx={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center', alignItems: 'center',
display: 'flex',
flexShrink: 0, // Corrected property name flexShrink: 0, // Corrected property name
justifyContent: 'space-between',
}} }}
> >
<NewThread <NewThread
@@ -598,9 +595,9 @@ export const Thread = ({
/> />
<Box <Box
sx={{ sx={{
alignItems: 'center',
display: 'flex', display: 'flex',
gap: '35px', gap: '35px',
alignItems: 'center',
}} }}
> >
<ShowMessageReturnButton <ShowMessageReturnButton
@@ -610,7 +607,9 @@ export const Thread = ({
}} }}
> >
<MailIconImg src={ReturnSVG} /> <MailIconImg src={ReturnSVG} />
<ComposeP>Return to Threads</ComposeP> <ComposeP>
{t('core:return_to_thread', { postProcess: 'capitalize' })}
</ComposeP>
</ShowMessageReturnButton> </ShowMessageReturnButton>
{/* Conditionally render the scroll buttons */} {/* Conditionally render the scroll buttons */}
{showScrollButton && {showScrollButton &&
@@ -658,6 +657,7 @@ export const Thread = ({
> >
<GroupNameP>{currentThread?.threadData?.title}</GroupNameP> <GroupNameP>{currentThread?.threadData?.title}</GroupNameP>
</Box> </Box>
<Spacer height={'15px'} /> <Spacer height={'15px'} />
<Box <Box
@@ -685,8 +685,9 @@ export const Thread = ({
disabled={!hasFirstPage} disabled={!hasFirstPage}
variant="contained" variant="contained"
> >
First {t(core:page.first', { postProcess: 'capitalize' })}
</Button> </Button>
<Button <Button
sx={{ sx={{
textTransformation: 'capitalize', textTransformation: 'capitalize',
@@ -701,9 +702,9 @@ export const Thread = ({
); );
}} }}
disabled={!hasPreviousPage} disabled={!hasPreviousPage}
variant="contained" // TODO translate variant="contained"
> >
Previous {t(core:page.previous', { postProcess: 'capitalize' })}
</Button> </Button>
<Button <Button
sx={{ sx={{
@@ -721,7 +722,7 @@ export const Thread = ({
disabled={!hasNextPage} disabled={!hasNextPage}
variant="contained" variant="contained"
> >
Next {t('core:next', { postProcess: 'capitalize' })}
</Button> </Button>
<Button <Button
sx={{ sx={{
@@ -739,7 +740,7 @@ export const Thread = ({
disabled={!hasLastPage} disabled={!hasLastPage}
variant="contained" variant="contained"
> >
Last {t(core:page.last', { postProcess: 'capitalize' })}
</Button> </Button>
</Box> </Box>
@@ -925,7 +926,7 @@ export const Thread = ({
color: 'white', color: 'white',
}} }}
> >
Downloading from QDN {t('core:downloading_qdn', { postProcess: 'capitalize' })}
</Typography> </Typography>
</Box> </Box>
</Box> </Box>
@@ -959,7 +960,7 @@ export const Thread = ({
color: 'white', color: 'white',
}} }}
> >
Refetch page {t('core:refetch_page', { postProcess: 'capitalize' })}
</Button> </Button>
</Box> </Box>
</> </>
@@ -997,7 +998,7 @@ export const Thread = ({
disabled={!hasFirstPage} disabled={!hasFirstPage}
variant="contained" variant="contained"
> >
First {t(core:page.first', { postProcess: 'capitalize' })}
</Button> </Button>
<Button <Button
sx={{ sx={{
@@ -1015,7 +1016,7 @@ export const Thread = ({
disabled={!hasPreviousPage} disabled={!hasPreviousPage}
variant="contained" variant="contained"
> >
Previous {t(core:page.previous', { postProcess: 'capitalize' })}
</Button> </Button>
<Button <Button
sx={{ sx={{
@@ -1033,7 +1034,7 @@ export const Thread = ({
disabled={!hasNextPage} disabled={!hasNextPage}
variant="contained" variant="contained"
> >
Next {t('core:next', { postProcess: 'capitalize' })}
</Button> </Button>
<Button <Button
sx={{ sx={{
@@ -1051,7 +1052,7 @@ export const Thread = ({
disabled={!hasLastPage} disabled={!hasLastPage}
variant="contained" variant="contained"
> >
Last {t(core:page.last', { postProcess: 'capitalize' })}
</Button> </Button>
</Box> </Box>
<Spacer height="30px" /> <Spacer height="30px" />
@@ -1063,7 +1064,7 @@ export const Thread = ({
<LoadingSnackbar <LoadingSnackbar
open={isLoading} open={isLoading}
info={{ info={{
message: 'Loading posts... please wait.', message: t('core:loading_posts', { postProcess: 'capitalize' }),
}} }}
/> />
</GroupContainer> </GroupContainer>