From 95f35d4e30c48b54e2eb9e754dd92b8af5093462 Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Wed, 21 May 2025 20:22:10 +0200 Subject: [PATCH] Add theme translations --- src/components/Desktop/DesktopFooter.tsx | 17 +++++++++-- src/components/Group/AddGroup.tsx | 16 ++++++---- src/components/Group/Group.tsx | 4 ++- src/components/Group/Settings.tsx | 2 +- src/components/ReactionPicker.tsx | 2 -- src/components/Theme/ThemeManager.tsx | 37 ++++++++++++++++++------ src/i18n/locales/en/core.json | 18 +++++++++--- src/i18n/locales/en/group.json | 7 +++-- 8 files changed, 75 insertions(+), 28 deletions(-) diff --git a/src/components/Desktop/DesktopFooter.tsx b/src/components/Desktop/DesktopFooter.tsx index b5a1d1f..ac567ec 100644 --- a/src/components/Desktop/DesktopFooter.tsx +++ b/src/components/Desktop/DesktopFooter.tsx @@ -94,7 +94,10 @@ export const DesktopFooter = ({ goToHome(); }} > - + @@ -145,7 +148,12 @@ export const DesktopFooter = ({ setDesktopSideView('directs'); }} > - + - + diff --git a/src/components/Group/AddGroup.tsx b/src/components/Group/AddGroup.tsx index 9d86252..2028dea 100644 --- a/src/components/Group/AddGroup.tsx +++ b/src/components/Group/AddGroup.tsx @@ -388,7 +388,9 @@ export const AddGroup = ({ address, open, setOpen }) => { labelId="demo-simple-select-label" id="demo-simple-select" value={groupType} - label="Group Type" + label={t('group:group.type', { + postProcess: 'capitalizeFirstChar', + })} onChange={handleChangeGroupType} > @@ -469,7 +471,7 @@ export const AddGroup = ({ address, open, setOpen }) => { }} > @@ -478,7 +480,9 @@ export const AddGroup = ({ address, open, setOpen }) => { labelId="demo-simple-select-label" id="demo-simple-select" value={minBlock} - label="Minimum Block delay" + label={t('group:block_delay.minimum', { + postProcess: 'capitalizeFirstChar', + })} onChange={handleChangeMinBlock} > @@ -528,7 +532,7 @@ export const AddGroup = ({ address, open, setOpen }) => { }} > @@ -537,7 +541,9 @@ export const AddGroup = ({ address, open, setOpen }) => { labelId="demo-simple-select-label" id="demo-simple-select" value={maxBlock} - label="Maximum Block delay" + label={t('group:block_delay.minimum', { + postProcess: 'capitalizeFirstChar', + })} onChange={handleChangeMaxBlock} > diff --git a/src/components/Group/Group.tsx b/src/components/Group/Group.tsx index c4ff643..8283fce 100644 --- a/src/components/Group/Group.tsx +++ b/src/components/Group/Group.tsx @@ -1680,7 +1680,9 @@ export const Group = ({ ? theme.palette.text.primary : theme.palette.text.secondary } - label="Messaging" + label={t('group:group.messaging', { + postProcess: 'capitalizeFirstChar', + })} selected={desktopSideView === 'directs'} > { }} /> } - label={t('group:action.enable_dev_mode', { + label={t('core:action.enable_dev_mode', { postProcess: 'capitalizeFirstChar', })} /> diff --git a/src/components/ReactionPicker.tsx b/src/components/ReactionPicker.tsx index 0bba748..e7a4a43 100644 --- a/src/components/ReactionPicker.tsx +++ b/src/components/ReactionPicker.tsx @@ -105,8 +105,6 @@ export const ReactionPicker = ({ onReaction }) => { height={400} onEmojiClick={handlePicker} onReactionClick={handleReaction} - // reactionsDefaultOpen={true} - // open={true} theme={Theme.DARK} width={350} /> diff --git a/src/components/Theme/ThemeManager.tsx b/src/components/Theme/ThemeManager.tsx index badcb42..b8a51f6 100644 --- a/src/components/Theme/ThemeManager.tsx +++ b/src/components/Theme/ThemeManager.tsx @@ -1,4 +1,4 @@ -import React, { useState, useRef, useEffect } from 'react'; +import { useState, useRef, useEffect } from 'react'; import { Box, Button, @@ -29,6 +29,8 @@ import { rgbStringToHsva, rgbaStringToHsva } from '@uiw/color-convert'; import FileDownloadIcon from '@mui/icons-material/FileDownload'; import { saveFileToDiskGeneric } from '../../utils/generateWallet/generateWallet'; import { handleImportClick } from '../../utils/fileReading'; +import { useTranslation } from 'react-i18next'; + const uid = new ShortUniqueId({ length: 8 }); function detectColorFormat(color) { @@ -80,6 +82,7 @@ export default function ThemeManager() { }); const [currentTab, setCurrentTab] = useState('light'); const nameInputRef = useRef(null); + const { t } = useTranslation(['auth', 'core', 'group']); useEffect(() => { if (openEditor && nameInputRef.current) { @@ -208,7 +211,11 @@ export default function ThemeManager() { const fileContent = await handleImportClick('.json'); const importedTheme = JSON.parse(fileContent); if (!validateTheme(importedTheme)) { - throw new Error('Invalid theme format'); + throw new Error( + t('core:message.generic.invalid_theme_format', { + postProcess: 'capitalizeFirstChar', + }) + ); } const newTheme = { ...importedTheme, id: uid.rnd() }; const updatedThemes = [...userThemes, newTheme]; @@ -223,7 +230,7 @@ export default function ThemeManager() { return ( - Theme Manager + {t('core:theme.manager', { postProcess: 'capitalizeFirstChar' })} + + {userThemes?.map((theme, index) => ( - {themeDraft.id ? 'Edit Theme' : 'Add New Theme'} + {themeDraft.id + ? t('core:action.edit_theme', { + postProcess: 'capitalizeFirstChar', + }) + : t('core:action.new.theme', { + postProcess: 'capitalizeFirstChar', + })} + @@ -391,14 +407,17 @@ export default function ThemeManager() { )} + - + diff --git a/src/i18n/locales/en/core.json b/src/i18n/locales/en/core.json index 82dfda9..954b754 100644 --- a/src/i18n/locales/en/core.json +++ b/src/i18n/locales/en/core.json @@ -1,11 +1,12 @@ { "action": { - "add": "add", - "add_custom_framework": "add custom framework", - "add_reaction": "add reaction", "accept": "accept", "access": "access", "access_app": "access app", + "add": "add", + "add_custom_framework": "add custom framework", + "add_reaction": "add reaction", + "add_theme": "add theme", "backup_account": "backup account", "backup_wallet": "backup wallet", "cancel": "cancel", @@ -33,11 +34,14 @@ "download": "download", "download_file": "download file", "edit": "edit", + "edit_theme": "edit theme", + "enable_dev_mode": "enable dev mode", "enter_name": "enter a name", "export": "export", "get_qort": "get QORT at Q-Trade", "hide": "hide", "import": "import", + "import_theme": "import theme", "invite": "invite", "join": "join", "leave_comment": "leave comment", @@ -47,6 +51,7 @@ "new": { "chat": "new chat", "post": "new post", + "theme": "new theme", "thread": "new thread" }, "notify": "notify", @@ -115,6 +120,7 @@ }, "current_language": "current language: {{ language }}", "dev": "dev", + "dev_mode": "dev Mode", "domain": "domain", "ui": { "version": "UI version" @@ -134,6 +140,7 @@ "for": "for", "general": "general", "general_settings": "general settings", + "home": "home", "identifier": "identifier", "image_embed": "image embed", "last_height": "last height", @@ -164,6 +171,7 @@ "invalid_poll_embed_link_name": "invalid poll embed link. Missing name.", "invalid_image_embed_link_name": "invalid image embed link. Missing param.", "invalid_signature": "invalid signature", + "invalid_theme_format": "invalid theme format", "invalid_zip": "invalid zip", "message_loading": "error loading message.", "message_size": "your message size is of {{ size }} bytes out of a maximum of {{ maximum }}", @@ -326,7 +334,9 @@ "tags": "tags", "theme": { "dark": "dark mode", - "light": "light mode" + "light": "light mode", + "manager": "theme Manager", + "name": "theme name" }, "thread": "thread", "thread_other": "threads", diff --git a/src/i18n/locales/en/group.json b/src/i18n/locales/en/group.json index c58e88c..e96466a 100644 --- a/src/i18n/locales/en/group.json +++ b/src/i18n/locales/en/group.json @@ -6,7 +6,6 @@ "copy_private_key": "copy private key", "create_group": "create group", "disable_push_notifications": "disable all push notifications", - "enable_dev_mode": "enable dev mode", "export_password": "export password", "export_private_key": "export private key", "find_group": "find group", @@ -33,8 +32,8 @@ "approval_threshold": "group Approval Threshold (number / percentage of Admins that must approve a transaction)", "ban_list": "ban list", "block_delay": { - "minimum": "minimum Block delay for Group Transaction Approvals", - "maximum": "maximum Block delay for Group Transaction Approvals" + "minimum": "Minimum Block delay", + "maximum": "Maximum Block delay" }, "group": { "avatar": "group avatar", @@ -68,6 +67,8 @@ "avatar_registered_name": "a registered name is required to set an avatar", "admin_only": "only groups where you are an admin will be shown", "already_in_group": "you are already in this group!", + "block_delay_minimum": "minimum Block delay for Group Transaction Approvals", + "block_delay_maximum": "maximum Block delay for Group Transaction Approvals", "closed_group": "this is a closed/private group, so you will need to wait until an admin accepts your request", "descrypt_wallet": "decrypting wallet...", "encryption_key": "the group's first common encryption key is in the process of creation. Please wait a few minutes for it to be retrieved by the network. Checking every 2 minutes...",