Translate register_name page

This commit is contained in:
Nicola Benaglia 2025-05-15 08:55:57 +02:00
parent d3ac43ab81
commit 2907587626
3 changed files with 99 additions and 20 deletions

View File

@ -25,6 +25,7 @@ import CheckIcon from '@mui/icons-material/Check';
import ErrorIcon from '@mui/icons-material/Error'; import ErrorIcon from '@mui/icons-material/Error';
import { useSetAtom } from 'jotai'; import { useSetAtom } from 'jotai';
import { txListAtom } from '../atoms/global'; import { txListAtom } from '../atoms/global';
import { useTranslation } from 'react-i18next';
enum Availability { enum Availability {
NULL = 'null', NULL = 'null',
@ -50,6 +51,7 @@ export const RegisterName = ({
); );
const [nameFee, setNameFee] = useState(null); const [nameFee, setNameFee] = useState(null);
const theme = useTheme(); const theme = useTheme();
const { t } = useTranslation(['core', 'auth', 'group']);
const checkIfNameExisits = async (name) => { const checkIfNameExisits = async (name) => {
if (!name?.trim()) { if (!name?.trim()) {
setIsNameAvailable(Availability.NULL); setIsNameAvailable(Availability.NULL);
@ -110,12 +112,24 @@ export const RegisterName = ({
const registerName = async () => { const registerName = async () => {
try { try {
if (!userInfo?.address) throw new Error('Your address was not found'); if (!userInfo?.address)
if (!registerNameValue) throw new Error('Enter a name'); throw new Error(
t('core:message.error.address_not_found', {
postProcess: 'capitalize',
})
);
if (!registerNameValue)
throw new Error(
t('core:action.enter_name', {
postProcess: 'capitalize',
})
);
const fee = await getFee('REGISTER_NAME'); const fee = await getFee('REGISTER_NAME');
await show({ await show({
message: 'Would you like to register this name?', message: t('group:question.register_name', {
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT', publishFee: fee.fee + ' QORT',
}); });
setIsLoadingRegisterName(true); setIsLoadingRegisterName(true);
@ -130,8 +144,9 @@ export const RegisterName = ({
setIsLoadingRegisterName(false); setIsLoadingRegisterName(false);
setInfoSnack({ setInfoSnack({
type: 'success', type: 'success',
message: message: t('group:message.success.registered_name', {
'Successfully registered. It may take a couple of minutes for the changes to propagate', postProcess: 'capitalize',
}),
}); });
setIsOpen(false); setIsOpen(false);
setRegisterNameValue(''); setRegisterNameValue('');
@ -140,8 +155,15 @@ export const RegisterName = ({
{ {
...response, ...response,
type: 'register-name', type: 'register-name',
label: `Registered name: awaiting confirmation. This may take a couple minutes.`, label: t('group:message.success.registered_name_label', {
labelDone: `Registered name: success!`, postProcess: 'capitalize',
}),
labelDone: t(
'group:message.success.registered_name_success',
{
postProcess: 'capitalize',
}
),
done: false, done: false,
}, },
...prev.filter((item) => !item.done), ...prev.filter((item) => !item.done),
@ -158,7 +180,9 @@ export const RegisterName = ({
.catch((error) => { .catch((error) => {
setInfoSnack({ setInfoSnack({
type: 'error', type: 'error',
message: error.message || 'An error occurred', message:
error.message ||
t('core:message.error.generic', { postProcess: 'capitalize' }),
}); });
setOpenSnack(true); setOpenSnack(true);
rej(error); rej(error);
@ -199,7 +223,9 @@ export const RegisterName = ({
width: '400px', width: '400px',
}} }}
> >
<Label>Choose a name</Label> // TODO: translate <Label>
{t('core:action.choose_name', { postProcess: 'capitalize' })}
</Label>
<TextField <TextField
autoComplete="off" autoComplete="off"
autoFocus autoFocus
@ -210,6 +236,7 @@ export const RegisterName = ({
{(!balance || (nameFee && balance && balance < nameFee)) && ( {(!balance || (nameFee && balance && balance < nameFee)) && (
<> <>
<Spacer height="10px" /> <Spacer height="10px" />
<Box <Box
sx={{ sx={{
display: 'flex', display: 'flex',
@ -223,15 +250,20 @@ export const RegisterName = ({
}} }}
/> />
<Typography> <Typography>
Your balance is {balance ?? 0} QORT. A name registration {t('core:message.generic.name_registration', {
requires a {nameFee} QORT fee balance: balance ?? 0,
fee: { nameFee },
postProcess: 'capitalize',
})}
</Typography> </Typography>
</Box> </Box>
<Spacer height="10px" /> <Spacer height="10px" />
</> </>
)} )}
<Spacer height="5px" /> <Spacer height="5px" />
{isNameAvailable === Availability.AVAILABLE && ( {isNameAvailable === Availability.AVAILABLE && (
<Box <Box
sx={{ sx={{
@ -245,9 +277,15 @@ export const RegisterName = ({
color: theme.palette.text.primary, color: theme.palette.text.primary,
}} }}
/> />
<Typography>{registerNameValue} is available</Typography> <Typography>
{t('core:message.generic.name_available', {
name: registerNameValue,
postProcess: 'capitalize',
})}
</Typography>
</Box> </Box>
)} )}
{isNameAvailable === Availability.NOT_AVAILABLE && ( {isNameAvailable === Availability.NOT_AVAILABLE && (
<Box <Box
sx={{ sx={{
@ -261,9 +299,15 @@ export const RegisterName = ({
color: theme.palette.text.primary, color: theme.palette.text.primary,
}} }}
/> />
<Typography>{registerNameValue} is unavailable</Typography> <Typography>
{t('core:message.generic.name_unavailable', {
name: registerNameValue,
postProcess: 'capitalize',
})}
</Typography>
</Box> </Box>
)} )}
{isNameAvailable === Availability.LOADING && ( {isNameAvailable === Availability.LOADING && (
<Box <Box
sx={{ sx={{
@ -273,17 +317,27 @@ export const RegisterName = ({
}} }}
> >
<BarSpinner width="16px" color={theme.palette.text.primary} /> <BarSpinner width="16px" color={theme.palette.text.primary} />
<Typography>Checking if name already existis</Typography>
<Typography>
{t('core:message.generic.name_checking', {
postProcess: 'capitalize',
})}
</Typography>
</Box> </Box>
)} )}
<Spacer height="25px" /> <Spacer height="25px" />
<Typography <Typography
sx={{ sx={{
textDecoration: 'underline', textDecoration: 'underline',
}} }}
> >
Benefits of a name {t('core:message.generic.name_benefits', {
postProcess: 'capitalize',
})}
</Typography> </Typography>
<List <List
sx={{ width: '100%', maxWidth: 360, bgcolor: 'background.paper' }} sx={{ width: '100%', maxWidth: 360, bgcolor: 'background.paper' }}
aria-label="contacts" aria-label="contacts"
@ -296,7 +350,11 @@ export const RegisterName = ({
}} }}
/> />
</ListItemIcon> </ListItemIcon>
<ListItemText primary="Publish data to Qortal: anything from apps to videos. Fully decentralized!" /> <ListItemText
primary={t('core:message.generic.publish_data', {
postProcess: 'capitalize',
})}
/>
</ListItem> </ListItem>
<ListItem disablePadding> <ListItem disablePadding>
@ -307,7 +365,11 @@ export const RegisterName = ({
}} }}
/> />
</ListItemIcon> </ListItemIcon>
<ListItemText primary="Secure ownership of data published by your name. You can even sell your name, along with your data to a third party." /> <ListItemText
primary={t('core:message.generic.secure_ownership', {
postProcess: 'capitalize',
})}
/>
</ListItem> </ListItem>
</List> </List>
</Box> </Box>
@ -322,7 +384,7 @@ export const RegisterName = ({
setRegisterNameValue(''); setRegisterNameValue('');
}} }}
> >
Close {t('core:action.close', { postProcess: 'capitalize' })}
</Button> </Button>
<Button <Button
@ -337,7 +399,7 @@ export const RegisterName = ({
onClick={registerName} onClick={registerName}
autoFocus autoFocus
> >
Register Name {t('core:action.register_name', { postProcess: 'capitalize' })}
</Button> </Button>
</DialogActions> </DialogActions>
</Dialog> </Dialog>

View File

@ -13,9 +13,11 @@
"continue": "continue", "continue": "continue",
"continue_logout": "continue to logout", "continue_logout": "continue to logout",
"create_thread": "create thread", "create_thread": "create thread",
"choose_name": "choose a name",
"decline": "decline", "decline": "decline",
"decrypt": "decrypt", "decrypt": "decrypt",
"edit": "edit", "edit": "edit",
"enter_name": "enter a name",
"export": "export", "export": "export",
"import": "import", "import": "import",
"invite": "invite", "invite": "invite",
@ -30,6 +32,7 @@
"post": "post", "post": "post",
"post_message": "post message", "post_message": "post message",
"publish": "publish", "publish": "publish",
"register_name": "register name",
"remove": "remove", "remove": "remove",
"save": "save", "save": "save",
"start_minting": "start minting" "start_minting": "start minting"
@ -67,6 +70,7 @@
"message_us": "please message us on Telegram or Discord if you need 4 QORT to start chatting without any limitations", "message_us": "please message us on Telegram or Discord if you need 4 QORT to start chatting without any limitations",
"message": { "message": {
"error": { "error": {
"address_not_found": "your address was not found",
"generic": "an error occurred", "generic": "an error occurred",
"incorrect_password": "incorrect password", "incorrect_password": "incorrect password",
"minting_account_add": "unable to add minting account", "minting_account_add": "unable to add minting account",
@ -74,6 +78,15 @@
"missing_field": "missing: {{ field }}", "missing_field": "missing: {{ field }}",
"save_qdn": "unable to save to QDN" "save_qdn": "unable to save to QDN"
}, },
"generic": {
"name_available": "{{ name }} is available",
"name_benefits": "benefits of a name",
"name_checking": "checking if name already exists",
"name_registration": "your balance is {{ balance }} QORT. A name registration requires a {{ fee }} QORT fee",
"name_unavailable": "{{ name }} is unavailable",
"publish_data": "publish data to Qortal: anything from apps to videos. Fully decentralized!",
"secure_ownership": "secure ownership of data published by your name. You can even sell your name, along with your data to a third party."
},
"question": { "question": {
"new_user": "are you a new user?" "new_user": "are you a new user?"
}, },

View File

@ -118,6 +118,9 @@
"invitation_request": "accepted join request: awaiting confirmation", "invitation_request": "accepted join request: awaiting confirmation",
"loading_threads": "loading threads... please wait.", "loading_threads": "loading threads... please wait.",
"post_creation": "successfully created post. It may take some time for the publish to propagate", "post_creation": "successfully created post. It may take some time for the publish to propagate",
"registered_name": "successfully registered. It may take a couple of minutes for the changes to propagate",
"registered_name_label": "registered name: awaiting confirmation. This may take a couple minutes.",
"registered_name_success": "registered name: success!",
"rewardshare_add": "add rewardshare: awaiting confirmation", "rewardshare_add": "add rewardshare: awaiting confirmation",
"rewardshare_add_label": "add rewardshare: success!", "rewardshare_add_label": "add rewardshare: success!",
"rewardshare_creation": "confirming creation of rewardshare on chain. Please be patient, this could take up to 90 seconds.", "rewardshare_creation": "confirming creation of rewardshare on chain. Please be patient, this could take up to 90 seconds.",
@ -131,7 +134,8 @@
}, },
"question": { "question": {
"perform_transaction": "would you like to perform a {{action}} transaction?", "perform_transaction": "would you like to perform a {{action}} transaction?",
"provide_thread": "please provide a thread title" "provide_thread": "please provide a thread title",
"register_name": "would you like to register this name?"
}, },
"thread_posts": "new thread posts" "thread_posts": "new thread posts"
} }