From b4a0e00dae864152817e082a3f8b1b2a54b99102 Mon Sep 17 00:00:00 2001 From: lukas Date: Fri, 15 Dec 2023 15:11:37 +0100 Subject: [PATCH] Translate components --- public/locales/de.json | 57 ++++++++++++++++++- public/locales/en.json | 57 ++++++++++++++++++- src/app/atoms/tabs/Tabs.jsx | 5 +- .../molecules/room-options/RoomOptions.jsx | 19 ++++--- .../molecules/space-options/SpaceOptions.jsx | 25 ++++---- src/app/organisms/settings/Settings.jsx | 32 +++++------ src/app/organisms/welcome/Welcome.jsx | 7 ++- 7 files changed, 162 insertions(+), 40 deletions(-) diff --git a/public/locales/de.json b/public/locales/de.json index a6edb507c4..0d84c3107a 100644 --- a/public/locales/de.json +++ b/public/locales/de.json @@ -3,12 +3,46 @@ "options": "Optionen" }, "Organisms": { + "Welcome": { + "heading": "Willkommen in Cinny!", + "subheading": "Noch ein weiterer Matrix Client" + }, + "SpaceSettings": { + "categorize_subspaces": "Unter-Spaces kategorisieren", + "uncategorize_subspaces": "Unter-Spaces nicht kategorisieren", + "pin_sidebar": "An Seitenleiste anheften", + "unpin_sidebar": "Von Seitenleiste lösen" + }, "Settings": { "theme": { "follow_system": { "title": "System-Theme verwenden", "description": "Verwende den hellen oder dunklen Modus basierend auf den Systemeinstellungen." - } + }, + "title": "Theme", + "theme_light": "Hell", + "theme_silver": "Silber", + "theme_dark": "Dunkel", + "theme_butter": "Butter" + }, + "markdown": { + "title": "Markdown-Formatierung", + "description": "Nachrichten vor dem Senden mit Markdown formatieren" + }, + "hide_membership_events": { + "title": "Mitgliedschaftsereignisse ausblenden", + "description": "Nachrichten zu Änderungen von Mitgliedschaften in der Zeitleiste ausblenden (Beitreten, Verlassen, Einladen, Entfernen und Bannen)" + }, + "hide_nickname_avatar_events": { + "title": "Spitzname/Avatar Ereignisse ausblenden", + "description": "Nachrichten zu Änderungen von Spitznamen und Avataren in der Zeitleiste ausblenden." + }, + "tabs": { + "appearance": "Auftretten", + "notifications": "Benachrichtungen", + "emoji": "Emoji", + "security": "Sicherheit", + "about": "Über" } }, "DrawerBreadcrumb": { @@ -41,6 +75,27 @@ "Molecules": { "ConfirmDialog": { "cancel": "Abbrechen" + }, + "RoomOptions": { + "title": "Optionen für {{room_name}}", + "leave": { + "title": "Raum verlassen", + "subtitle": "Bist du sicher, dass du den Raum {{room_name}} verlassen möchtest?", + "button_text": "Verlassen" + }, + "mark_as_read": "Als gelesen markieren", + "notifications_heading": "Benachrichtigungen", + "invite": "Einladen" + }, + "SpaceOptions": { + "leave_space": "Space verlassen", + "leave_space_confirmation": "Bist du sicher, dass du den Space {{space}} verlassen möchtest?", + "leave_space_confirm": "Verlassen", + "mark_as_read": "Als gelesen markieren", + "invite": "Einladen", + "manage_rooms": "Räume verwalten", + "settings": "Einstellungen", + "leave": "Verlassen" } } } diff --git a/public/locales/en.json b/public/locales/en.json index 7ceaa34b89..86ab77f635 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -3,12 +3,46 @@ "options": "Options" }, "Organisms": { + "Welcome": { + "heading": "Welcome to Cinny!", + "subheading": "Yet another Matrix client" + }, + "SpaceSettings": { + "categorize_subspaces": "Categorize subspaces", + "uncategorize_subspaces": "Uncategorize subspaces", + "pin_sidebar": "Pin to sidebar", + "unpin_sidebar": "Unpin from sidebar" + }, "Settings": { "theme": { "follow_system": { "title": "Follow system theme", "description": "Use light or dark mode based on the system settings." - } + }, + "title": "Theme", + "theme_light": "Light", + "theme_silver": "Silver", + "theme_dark": "Dark", + "theme_butter": "Butter" + }, + "markdown": { + "title": "Markdown formatting", + "description": "Format messages with markdown before sending" + }, + "hide_membership_events": { + "title": "Hide membership events", + "description": "Hide membership change messages from room timeline. (Join, Leave, Invite, Kick and Ban)" + }, + "hide_nickname_avatar_events": { + "title": "Hide nick/avatar events", + "description": "Hide nickname and avatar change messages from the room timeline." + }, + "tabs": { + "appearance": "Appearance", + "notifications": "Notifications", + "emoji": "Emoji", + "security": "Security", + "about": "About" } }, "DrawerBreadcrumb": { @@ -41,6 +75,27 @@ "Molecules": { "ConfirmDialog": { "cancel": "Cancel" + }, + "RoomOptions": { + "title": "Options for {{room_name}}", + "leave": { + "title": "Leave room", + "subtitle": "Are you sure you want to leave the {{room_name}} room?", + "button_text": "Leave" + }, + "mark_as_read": "Mark as read", + "notifications_heading": "Notifications", + "invite": "Invite" + }, + "SpaceOptions": { + "leave_space": "Leave Space", + "leave_space_confirmation": "Are you sure that you want to leave the {{space}} space?", + "leave_space_confirm": "Leave", + "mark_as_read": "Mark as read", + "invite": "Invite", + "manage_rooms": "Manage rooms", + "settings": "Settings", + "leave": "Leave" } } } diff --git a/src/app/atoms/tabs/Tabs.jsx b/src/app/atoms/tabs/Tabs.jsx index 39800ce350..794ce8ddb6 100644 --- a/src/app/atoms/tabs/Tabs.jsx +++ b/src/app/atoms/tabs/Tabs.jsx @@ -1,6 +1,7 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; import './Tabs.scss'; +import { useTranslation } from 'react-i18next'; import Button from '../button/Button'; import ScrollView from '../scroll/ScrollView'; @@ -41,6 +42,8 @@ TabItem.propTypes = { function Tabs({ items, defaultSelected, onSelect }) { const [selectedItem, setSelectedItem] = useState(items[defaultSelected]); + const { t } = useTranslation(); + const handleTabSelection = (item, index) => { if (selectedItem === item) return; setSelectedItem(item); @@ -59,7 +62,7 @@ function Tabs({ items, defaultSelected, onSelect }) { disabled={item.disabled} onClick={() => handleTabSelection(item, index)} > - {item.text} + {t(item.text)} ))} diff --git a/src/app/molecules/room-options/RoomOptions.jsx b/src/app/molecules/room-options/RoomOptions.jsx index af18d71206..f23820608c 100644 --- a/src/app/molecules/room-options/RoomOptions.jsx +++ b/src/app/molecules/room-options/RoomOptions.jsx @@ -1,6 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; @@ -22,6 +23,8 @@ function RoomOptions({ roomId, afterOptionSelect }) { const room = mx.getRoom(roomId); const canInvite = room?.canInvite(mx.getUserId()); + const { t } = useTranslation(); + const handleMarkAsRead = () => { markAsRead(roomId); afterOptionSelect(); @@ -34,9 +37,9 @@ function RoomOptions({ roomId, afterOptionSelect }) { const handleLeaveClick = async () => { afterOptionSelect(); const isConfirmed = await confirmDialog( - 'Leave room', - `Are you sure that you want to leave "${room.name}" room?`, - 'Leave', + t('Molecules.RoomOptions.leave.title'), + t('Molecules.RoomOptions.leave.subtitle', { room_name: room.name }), + t('Molecules.RoomOptions.leave.button_text'), 'danger', ); if (!isConfirmed) return; @@ -45,17 +48,17 @@ function RoomOptions({ roomId, afterOptionSelect }) { return (
- {twemojify(`Options for ${initMatrix.matrixClient.getRoom(roomId)?.name}`)} - Mark as read + {twemojify(t('Molecules.RoomOptions.title', { room_name: initMatrix.matrixClient.getRoom(roomId)?.name }))} + {t('Molecules.RoomOptions.mark_as_read')} - Invite + {t('Molecules.RoomOptions.invite')} - Leave - Notification + {t('Molecules.RoomOptions.leave.button_text')} + {t('Molecules.RoomOptions.notifications_heading')}
); diff --git a/src/app/molecules/space-options/SpaceOptions.jsx b/src/app/molecules/space-options/SpaceOptions.jsx index 0c166c6a90..dd0971c728 100644 --- a/src/app/molecules/space-options/SpaceOptions.jsx +++ b/src/app/molecules/space-options/SpaceOptions.jsx @@ -1,6 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; @@ -36,6 +37,8 @@ function SpaceOptions({ roomId, afterOptionSelect }) { const isPinned = initMatrix.accountData.spaceShortcut.has(roomId); const isCategorized = initMatrix.accountData.categorizedSpaces.has(roomId); + const { t } = useTranslation(); + const handleMarkAsRead = () => { const spaceChildren = roomList.getCategorizedSpaces([roomId]); spaceChildren?.forEach((childIds) => { @@ -71,9 +74,9 @@ function SpaceOptions({ roomId, afterOptionSelect }) { const handleLeaveClick = async () => { afterOptionSelect(); const isConfirmed = await confirmDialog( - 'Leave space', - `Are you sure that you want to leave "${room.name}" space?`, - 'Leave', + t('Molecules.SpaceOptions.leave_space'), + t('Molecules.SpaceOptions.leave_space_confirmation', { space: room.name }), + t('Molecules.SpaceOptions.leave_space_confirmation'), 'danger', ); if (!isConfirmed) return; @@ -82,35 +85,35 @@ function SpaceOptions({ roomId, afterOptionSelect }) { return (
- {twemojify(`Options for ${initMatrix.matrixClient.getRoom(roomId)?.name}`)} - Mark as read + {twemojify(t('Molecules.RoomOptions.title', { room_name: initMatrix.matrixClient.getRoom(roomId)?.name }))} + {t('Molecules.SpaceOptions.mark_as_read')} - {isCategorized ? 'Uncategorize subspaces' : 'Categorize subspaces'} + {isCategorized ? t('Organisms.SpaceSettings.uncategorize_subspaces') : t('Organisms.SpaceSettings.categorize_subspaces')} - {isPinned ? 'Unpin from sidebar' : 'Pin to sidebar'} + {isPinned ? t('Organisms.SpaceSettings.unpin_sidebar') : t('Organisms.SpaceSettings.pin_sidebar')} - Invite + {t('Molecules.SpaceOptions.invite')} - Manage rooms - Settings + {t('Molecules.SpaceOptions.manage_rooms')} + {t('Molecules.SpaceOptions.settings')} - Leave + {t('Molecules.SpaceOptions.leave')}
); diff --git a/src/app/organisms/settings/Settings.jsx b/src/app/organisms/settings/Settings.jsx index f164d56bc0..c270690469 100644 --- a/src/app/organisms/settings/Settings.jsx +++ b/src/app/organisms/settings/Settings.jsx @@ -82,15 +82,15 @@ function AppearanceSection() { content={{t('Organisms.Settings.theme.follow_system.description')}} /> { if (settings.useSystemTheme) toggleSystemTheme(); @@ -157,34 +157,34 @@ function AppearanceSection() { content={{`Use ${isMacOS() ? KeySymbol.Command : 'Ctrl'} + ENTER to send message and ENTER for newline.`}} /> setIsMarkdown(!isMarkdown) } /> )} - content={Format messages with markdown syntax before sending.} + content={{t('Organisms.Settings.markdown.description')}} /> setHideMembershipEvents(!hideMembershipEvents)} /> )} - content={Hide membership change messages from room timeline. (Join, Leave, Invite, Kick and Ban)} + content={{t('Organisms.Settings.hide_membership_events.description')}} /> setHideNickAvatarEvents(!hideNickAvatarEvents)} /> )} - content={Hide nick and avatar change messages from room timeline.} + content={{t('Organisms.Settings.hide_nickname_avatar_events.description')}} />
Cinny logo - Welcome to Cinny - Yet another matrix client + {t('Organisms.Welcome.heading')} + {t('Organisms.Welcome.subheading')}
);