Save translations

This commit is contained in:
Nicola Benaglia 2025-04-23 09:27:24 +02:00
parent 284a8d01f9
commit 0026b7c249
3 changed files with 46 additions and 16 deletions

View File

@ -7,7 +7,7 @@
"continue": "continue", "continue": "continue",
"description": "description", "description": "description",
"edit": "edit", "edit": "edit",
"error": "an error occurred",
"last_height": "last height", "last_height": "last height",
"loading": "loading...", "loading": "loading...",
"logout": "logout", "logout": "logout",
@ -15,7 +15,19 @@
"payment_notification": "payment notification", "payment_notification": "payment notification",
"price": "price", "price": "price",
"q_mail": "q-mail", "q_mail": "q-mail",
"save": "save", "result": {
"error": {
"generic": "an error occurred",
"save_qdn": "Unable to save to QDN"
},
"success": {
"publish_qdn": "Sucessfully published to QDN"
}
},
"save_options": {
"publish_qdn": "Would you like to publish your settings to QDN (encrypted) ?",
"save": "save"
},
"settings": "settings", "settings": "settings",
"supply": "supply", "supply": "supply",
"title": "title", "title": "title",

View File

@ -12,7 +12,7 @@
"initial": { "initial": {
"6_qort": "avere almeno 6 QORT nel proprio wallet", "6_qort": "avere almeno 6 QORT nel proprio wallet",
"explore": "esplora", "explore": "esplora",
"general_chat": "chat generaleat", "general_chat": "chat generale",
"getting_started": "come iniziare", "getting_started": "come iniziare",
"register_name": "registra un nome", "register_name": "registra un nome",
"see_apps": "vedi le apps", "see_apps": "vedi le apps",

View File

@ -1,6 +1,6 @@
import React, { useContext, useEffect, useMemo, useState } from 'react'; import { useContext, useEffect, useMemo, useState } from 'react';
import { useRecoilState, useSetRecoilState } from 'recoil'; import { useRecoilState, useSetRecoilState } from 'recoil';
import isEqual from 'lodash/isEqual'; // Import deep comparison utility import isEqual from 'lodash/isEqual'; // TODO Import deep comparison utility
import { import {
canSaveSettingToQdnAtom, canSaveSettingToQdnAtom,
hasSettingsChangedAtom, hasSettingsChangedAtom,
@ -26,6 +26,7 @@ import {
base64ToUint8Array, base64ToUint8Array,
uint8ArrayToObject, uint8ArrayToObject,
} from '../../backgroundFunctions/encryption'; } from '../../backgroundFunctions/encryption';
import { useTranslation } from 'react-i18next';
export const handleImportClick = async () => { export const handleImportClick = async () => {
const fileInput = document.createElement('input'); const fileInput = document.createElement('input');
@ -77,6 +78,8 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
const [anchorEl, setAnchorEl] = useState(null); const [anchorEl, setAnchorEl] = useState(null);
const { show } = useContext(MyContext); const { show } = useContext(MyContext);
const { t } = useTranslation(['core']);
const hasChanged = useMemo(() => { const hasChanged = useMemo(() => {
const newChanges = { const newChanges = {
sortablePinnedApps: pinnedApps.map((item) => { sortablePinnedApps: pinnedApps.map((item) => {
@ -146,8 +149,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
const fee = await getFee('ARBITRARY'); const fee = await getFee('ARBITRARY');
await show({ await show({
message: message: t('core:save.publish_qnd', { postProcess: 'capitalize' }),
'Would you like to publish your settings to QDN (encrypted) ?',
publishFee: fee.fee + ' QORT', publishFee: fee.fee + ' QORT',
}); });
const response = await new Promise((res, rej) => { const response = await new Promise((res, rej) => {
@ -165,7 +167,10 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
rej(response.error); rej(response.error);
}) })
.catch((error) => { .catch((error) => {
rej(error.message || 'An error occurred'); rej(
error.message ||
t('core:result.error.generic', { postProcess: 'capitalize' })
);
}); });
}); });
if (response?.identifier) { if (response?.identifier) {
@ -173,7 +178,9 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
setSettingsQdnLastUpdated(Date.now()); setSettingsQdnLastUpdated(Date.now());
setInfoSnack({ setInfoSnack({
type: 'success', type: 'success',
message: 'Sucessfully published to QDN', message: t('core:result.success.publish_qdn', {
postProcess: 'capitalize',
}),
}); });
setOpenSnack(true); setOpenSnack(true);
setAnchorEl(null); setAnchorEl(null);
@ -182,7 +189,11 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
} catch (error) { } catch (error) {
setInfoSnack({ setInfoSnack({
type: 'error', type: 'error',
message: error?.message || 'Unable to save to QDN', message:
error?.message ||
t('core:result.error.save_qdn', {
postProcess: 'capitalize',
}),
}); });
setOpenSnack(true); setOpenSnack(true);
} finally { } finally {
@ -214,7 +225,9 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
{isDesktop ? ( {isDesktop ? (
<IconWrapper <IconWrapper
disableWidth={disableWidth} disableWidth={disableWidth}
label="Save" label={t('core:save_options.save', {
postProcess: 'capitalize',
})}
selected={false} selected={false}
> >
<SaveIcon <SaveIcon
@ -225,6 +238,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
<SaveIcon color={hasChanged && !isLoading ? '#5EB049' : undefined} /> <SaveIcon color={hasChanged && !isLoading ? '#5EB049' : undefined} />
)} )}
</ButtonBase> </ButtonBase>
<Popover <Popover
open={!!anchorEl} open={!!anchorEl}
anchorEl={anchorEl} anchorEl={anchorEl}
@ -247,19 +261,19 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
{isUsingImportExportSettings && ( {isUsingImportExportSettings && (
<Box <Box
sx={{ sx={{
padding: '15px',
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
gap: 1, gap: 1,
padding: '15px',
width: '100%', width: '100%',
}} }}
> >
<Box <Box
sx={{ sx={{
width: '100%', alignItems: 'center',
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
alignItems: 'center', width: '100%',
}} }}
> >
<Typography <Typography
@ -268,7 +282,8 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
}} }}
> >
You are using the export/import way of saving settings. You are using the export/import way of saving settings.
</Typography> </Typography>{' '}
// TODO: translate
<Spacer height="40px" /> <Spacer height="40px" />
<Button <Button
size="small" size="small"
@ -302,10 +317,10 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
{!isUsingImportExportSettings && ( {!isUsingImportExportSettings && (
<Box <Box
sx={{ sx={{
padding: '15px',
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
gap: 1, gap: 1,
padding: '15px',
width: '100%', width: '100%',
}} }}
> >
@ -346,7 +361,9 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
You have unsaved changes to your pinned apps. Save them to You have unsaved changes to your pinned apps. Save them to
QDN. QDN.
</Typography> </Typography>
<Spacer height="10px" /> <Spacer height="10px" />
<LoadingButton <LoadingButton
sx={{ sx={{
backgroundColor: 'var(--green)', backgroundColor: 'var(--green)',
@ -535,6 +552,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
> >
Import Import
</ButtonBase> </ButtonBase>
<ButtonBase <ButtonBase
onClick={async () => { onClick={async () => {
try { try {