From a70d77c17e5e99ad4f262f707e16f36e79de69a3 Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Wed, 23 Apr 2025 23:57:55 +0200 Subject: [PATCH] Add group namespace --- i18n.js | 2 +- public/locales/en/core.json | 3 +++ public/locales/en/group.json | 34 ++++++++++++++++++++++++ src/components/Group/Forum/GroupMail.tsx | 30 ++++++++++++--------- src/components/Group/Forum/NewThread.tsx | 22 +++++++++------ 5 files changed, 69 insertions(+), 22 deletions(-) create mode 100644 public/locales/en/group.json diff --git a/i18n.js b/i18n.js index 78df3c1..376f28d 100644 --- a/i18n.js +++ b/i18n.js @@ -42,7 +42,7 @@ i18n escapeValue: false, }, lng: navigator.language, - ns: ['auth', 'core', 'tutorial'], + ns: ['auth', 'core', 'group', 'tutorial'], supportedLngs: ['en', 'it', 'es', 'fr', 'de', 'ru'], }); diff --git a/public/locales/en/core.json b/public/locales/en/core.json index 8988c4a..c2089a9 100644 --- a/public/locales/en/core.json +++ b/public/locales/en/core.json @@ -18,6 +18,9 @@ "loading": "loading...", "logout": "logout", "minting_status": "minting status", + "page": { + "last": "last" + }, "payment_notification": "payment notification", "price": "price", "q_mail": "q-mail", diff --git a/public/locales/en/group.json b/public/locales/en/group.json new file mode 100644 index 0000000..453c1f6 --- /dev/null +++ b/public/locales/en/group.json @@ -0,0 +1,34 @@ +{ + "provide_thread": "please provide a thread title", + "result": { + "cannot": { + "access_name": "Cannot send a message without a access to your name", + "group_info": "Cannot access group information" + } + }, + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "", + "": "" +} diff --git a/src/components/Group/Forum/GroupMail.tsx b/src/components/Group/Forum/GroupMail.tsx index 3c8972f..0de9921 100644 --- a/src/components/Group/Forum/GroupMail.tsx +++ b/src/components/Group/Forum/GroupMail.tsx @@ -1,5 +1,4 @@ import React, { - FC, useCallback, useEffect, useMemo, @@ -17,7 +16,6 @@ import { ComposeIcon, ComposeP, GroupContainer, - GroupNameP, InstanceFooter, InstanceListContainer, InstanceListContainerRow, @@ -58,10 +56,12 @@ import { executeEvent } from '../../../utils/events'; import RefreshIcon from '@mui/icons-material/Refresh'; import { getArbitraryEndpointReact, getBaseApiReact } from '../../../App'; import { addDataPublishesFunc, getDataPublishesFunc } from '../Group'; +import { useTranslation } from 'react-i18next'; const filterOptions = ['Recently active', 'Newest', 'Oldest']; export const threadIdentifier = 'DOCUMENT'; + export const GroupMail = ({ selectedGroup, userInfo, @@ -82,6 +82,7 @@ export const GroupMail = ({ const anchorElInstanceFilter = useRef(null); const [tempPublishedList, setTempPublishedList] = useState([]); const dataPublishes = useRef({}); + const { t } = useTranslation(['core']); const [isLoading, setIsLoading] = useState(false); const groupIdRef = useRef(null); @@ -627,9 +628,9 @@ export const GroupMail = ({ @@ -682,6 +683,7 @@ export const GroupMail = ({ }} /> + {combinedListTempAndReal.map((thread) => { @@ -754,8 +756,8 @@ export const GroupMail = ({ {filterMode === 'Recently active' && (
@@ -776,16 +778,16 @@ export const GroupMail = ({ }, 300); }} sx={{ - position: 'absolute', - bottom: '2px', - right: '2px', - borderRadius: '5px', + alignItems: 'center', backgroundColor: '#27282c', + borderRadius: '5px', + bottom: '2px', + cursor: 'pointer', display: 'flex', gap: '10px', - alignItems: 'center', padding: '5px', - cursor: 'pointer', + position: 'absolute', + right: '2px', '&:hover': { background: 'rgba(255, 255, 255, 0.60)', }, @@ -795,9 +797,11 @@ export const GroupMail = ({ sx={{ color: 'white', fontSize: '12px', - }} // TODO translate + }} > - Last page + {t('core:page.last', { + postProcess: 'capitalize', + })} { console.log(error); } }; + export const NewThread = ({ groupInfo, members, @@ -143,8 +143,8 @@ export const NewThread = ({ setPostReply, isPrivate, }: NewMessageProps) => { + const { t } = useTranslation(['core', 'group']); const { show } = React.useContext(MyContext); - const [isOpen, setIsOpen] = useState(false); const [value, setValue] = useState(''); const [isSending, setIsSending] = useState(false); @@ -183,21 +183,27 @@ export const NewThread = ({ const missingFields: string[] = []; if (!isMessage && !threadTitle) { - errorMsg = 'Please provide a thread title'; + errorMsg = t('group:provide_thread', { + postProcess: 'capitalize', + }); } if (!name) { - errorMsg = 'Cannot send a message without a access to your name'; + errorMsg = t('group:result.cannot.access_name', { + postProcess: 'capitalize', + }); } if (!groupInfo) { - errorMsg = 'Cannot access group information'; - } // TODO translate + errorMsg = t('group:result.cannot.group_info', { + postProcess: 'capitalize', + }); + } // if (!description) missingFields.push('subject') if (missingFields.length > 0) { const missingFieldsString = missingFields.join(', '); const errMsg = `Missing: ${missingFieldsString}`; - errorMsg = errMsg; + errorMsg = errMsg; // TODO translate } if (errorMsg) {