Add translatios to addGroup

This commit is contained in:
Nicola Benaglia 2025-04-26 09:10:06 +02:00
parent 2327efa537
commit db211ee2b9
5 changed files with 43 additions and 15 deletions

View File

@ -15,6 +15,7 @@
"edit": "edit", "edit": "edit",
"export": "export", "export": "export",
"import": "import", "import": "import",
"join": "join",
"logout": "logout", "logout": "logout",
"refetch_page": "refetch page" "refetch_page": "refetch page"
}, },

View File

@ -2,6 +2,7 @@
"action": { "action": {
"create_group": "create group", "create_group": "create group",
"find_group": "find group", "find_group": "find group",
"join_group": "join group",
"return_to_thread": "return to threads" "return_to_thread": "return to threads"
}, },
"advanced_options": "advanced options", "advanced_options": "advanced options",
@ -21,6 +22,7 @@
}, },
"question": { "question": {
"create_group": "would you like to perform an CREATE_GROUP transaction?", "create_group": "would you like to perform an CREATE_GROUP transaction?",
"join_group": "would you like to perform an JOIN_GROUP transaction?",
"provide_thread": "please provide a thread title" "provide_thread": "please provide a thread title"
}, },
"result": { "result": {
@ -30,11 +32,14 @@
"group_info": "cannot access group information", "group_info": "cannot access group information",
"name_required": "please provide a name" "name_required": "please provide a name"
}, },
"loading_threads": "loading threads... please wait.",
"success": { "success": {
"group_creation": "successfully created group. It may take a couple of minutes for the changes to propagate", "group_creation": "successfully created group. It may take a couple of minutes for the changes to propagate",
"group_creation_name": "created group {{group_name}}: awaiting confirmation", "group_creation_name": "created group {{group_name}}: awaiting confirmation",
"group_creation_label": "created group {{name}}: success!" "group_creation_label": "created group {{name}}: success!",
"join_creation": "successfully requested to join group. It may take a couple of minutes for the changes to propagate",
"group_join_name": "joined group {{group_name}}: awaiting confirmation",
"group_join_label": "joined group {{name}}: success!",
"loading_threads": "loading threads... please wait."
} }
} }
} }

View File

@ -350,6 +350,7 @@ export const AddGroup = ({ address, open, setOpen }) => {
onChange={(e) => setDescription(e.target.value)} onChange={(e) => setDescription(e.target.value)}
/> />
</Box> </Box>
<Box <Box
sx={{ sx={{
display: 'flex', display: 'flex',
@ -383,6 +384,7 @@ export const AddGroup = ({ address, open, setOpen }) => {
</MenuItem> </MenuItem>
</Select> </Select>
</Box> </Box>
<Box <Box
sx={{ sx={{
display: 'flex', display: 'flex',

View File

@ -1,6 +1,5 @@
import { import {
Box, Box,
Button,
ListItem, ListItem,
ListItemButton, ListItemButton,
ListItemText, ListItemText,
@ -8,7 +7,7 @@ import {
TextField, TextField,
Typography, Typography,
} from '@mui/material'; } from '@mui/material';
import React, { import {
useCallback, useCallback,
useContext, useContext,
useEffect, useEffect,
@ -25,10 +24,12 @@ import {
import _ from 'lodash'; import _ from 'lodash';
import { MyContext, getBaseApiReact } from '../../App'; import { MyContext, getBaseApiReact } from '../../App';
import { LoadingButton } from '@mui/lab'; import { LoadingButton } from '@mui/lab';
import { getBaseApi, getFee } from '../../background'; import { getFee } from '../../background';
import LockIcon from '@mui/icons-material/Lock'; import LockIcon from '@mui/icons-material/Lock';
import NoEncryptionGmailerrorredIcon from '@mui/icons-material/NoEncryptionGmailerrorred'; import NoEncryptionGmailerrorredIcon from '@mui/icons-material/NoEncryptionGmailerrorred';
import { Spacer } from '../../common/Spacer'; import { Spacer } from '../../common/Spacer';
import { useTranslation } from 'react-i18next';
const cache = new CellMeasurerCache({ const cache = new CellMeasurerCache({
fixedWidth: true, fixedWidth: true,
defaultHeight: 50, defaultHeight: 50,
@ -36,7 +37,7 @@ const cache = new CellMeasurerCache({
export const AddGroupList = ({ setInfoSnack, setOpenSnack }) => { export const AddGroupList = ({ setInfoSnack, setOpenSnack }) => {
const { memberGroups, show, setTxList } = useContext(MyContext); const { memberGroups, show, setTxList } = useContext(MyContext);
const { t } = useTranslation(['core', 'group']);
const [groups, setGroups] = useState([]); const [groups, setGroups] = useState([]);
const [popoverAnchor, setPopoverAnchor] = useState(null); // Track which list item the popover is anchored to const [popoverAnchor, setPopoverAnchor] = useState(null); // Track which list item the popover is anchored to
const [openPopoverIndex, setOpenPopoverIndex] = useState(null); // Track which list item has the popover open const [openPopoverIndex, setOpenPopoverIndex] = useState(null); // Track which list item has the popover open
@ -101,12 +102,17 @@ export const AddGroupList = ({ setInfoSnack, setOpenSnack }) => {
const handleJoinGroup = async (group, isOpen) => { const handleJoinGroup = async (group, isOpen) => {
try { try {
const groupId = group.groupId; const groupId = group.groupId;
const fee = await getFee('JOIN_GROUP'); // TODO translate
const fee = await getFee('JOIN_GROUP');
await show({ await show({
message: 'Would you like to perform an JOIN_GROUP transaction?', message: t('group:question.join_group', {
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT', publishFee: fee.fee + ' QORT',
}); });
setIsLoading(true); setIsLoading(true);
await new Promise((res, rej) => { await new Promise((res, rej) => {
window window
.sendMessage('joinGroup', { .sendMessage('joinGroup', {
@ -116,8 +122,9 @@ export const AddGroupList = ({ setInfoSnack, setOpenSnack }) => {
if (!response?.error) { if (!response?.error) {
setInfoSnack({ setInfoSnack({
type: 'success', type: 'success',
message: message: t('group:result.success.join_group', {
'Successfully requested to join group. It may take a couple of minutes for the changes to propagate', postProcess: 'capitalize',
}),
}); });
if (isOpen) { if (isOpen) {
@ -125,8 +132,14 @@ export const AddGroupList = ({ setInfoSnack, setOpenSnack }) => {
{ {
...response, ...response,
type: 'joined-group', type: 'joined-group',
label: `Joined Group ${group?.groupName}: awaiting confirmation`, label: t('group:result.success.group_join_label', {
labelDone: `Joined Group ${group?.groupName}: success!`, group_name: group?.groupName,
postProcess: 'capitalize',
}),
labelDone: t('group:result.success.group_join_label', {
group_name: group?.groupName,
postProcess: 'capitalize',
}),
done: false, done: false,
groupId, groupId,
}, },
@ -215,7 +228,10 @@ export const AddGroupList = ({ setInfoSnack, setOpenSnack }) => {
padding: '10px', padding: '10px',
}} }}
> >
<Typography>Join {group?.groupName}</Typography> <Typography>
{t('core:action.join', { postProcess: 'capitalize' })}{' '}
{group?.groupName}
</Typography>
<Typography> <Typography>
{group?.isOpen === false && {group?.isOpen === false &&
'This is a closed/private group, so you will need to wait until an admin accepts your request'} 'This is a closed/private group, so you will need to wait until an admin accepts your request'}
@ -226,7 +242,9 @@ export const AddGroupList = ({ setInfoSnack, setOpenSnack }) => {
variant="contained" variant="contained"
onClick={() => handleJoinGroup(group, group?.isOpen)} onClick={() => handleJoinGroup(group, group?.isOpen)}
> >
Join group {t('group:action.join_group', {
postProcess: 'capitalize',
})}
</LoadingButton> </LoadingButton>
</Box> </Box>
</Popover> </Popover>

View File

@ -834,7 +834,9 @@ export const GroupMail = ({
<LoadingSnackbar <LoadingSnackbar
open={isLoading} open={isLoading}
info={{ info={{
message: 'Loading threads... please wait.', message: t('group:result.success.loading_threads', {
postProcess: 'capitalize',
}),
}} }}
/> />
</GroupContainer> </GroupContainer>