diff --git a/src/app/molecules/confirm-dialog/ConfirmDialog.jsx b/src/app/molecules/confirm-dialog/ConfirmDialog.jsx index da8f60e1..2e4f8ee9 100644 --- a/src/app/molecules/confirm-dialog/ConfirmDialog.jsx +++ b/src/app/molecules/confirm-dialog/ConfirmDialog.jsx @@ -2,25 +2,24 @@ import React from 'react'; import PropTypes from 'prop-types'; import './ConfirmDialog.scss'; +import { useTranslation } from 'react-i18next'; import { openReusableDialog } from '../../../client/action/navigation'; import Text from '../../atoms/text/Text'; import Button from '../../atoms/button/Button'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function ConfirmDialog({ desc, actionTitle, actionType, onComplete, }) { - const { t } = useTranslation(); return (
{desc}
- +
); diff --git a/src/app/molecules/dialog/ReusableDialog.jsx b/src/app/molecules/dialog/ReusableDialog.jsx index ace3b5c6..6e0fa9fd 100644 --- a/src/app/molecules/dialog/ReusableDialog.jsx +++ b/src/app/molecules/dialog/ReusableDialog.jsx @@ -1,4 +1,5 @@ import React, { useState, useEffect } from 'react'; +import { useTranslation } from 'react-i18next'; import cons from '../../../client/state/cons'; @@ -8,8 +9,7 @@ import Dialog from './Dialog'; import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function ReusableDialog() { const [isOpen, setIsOpen] = useState(false); @@ -43,7 +43,7 @@ function ReusableDialog() { title={data?.title || ''} onAfterClose={handleAfterClose} onRequestClose={handleRequestClose} - contentOptions={} + contentOptions={} invisibleScroll > {data?.render(handleRequestClose) ||
} diff --git a/src/app/molecules/following-members/FollowingMembers.jsx b/src/app/molecules/following-members/FollowingMembers.jsx index 81893e34..758335c3 100644 --- a/src/app/molecules/following-members/FollowingMembers.jsx +++ b/src/app/molecules/following-members/FollowingMembers.jsx @@ -3,6 +3,7 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import './FollowingMembers.scss'; +import { Trans } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import { openReadReceipts } from '../../../client/action/navigation'; @@ -11,15 +12,10 @@ import Text from '../../atoms/text/Text'; import RawIcon from '../../atoms/system-icons/RawIcon'; import TickMarkIC from '../../../../public/res/ic/outlined/tick-mark.svg'; -import { getUsersActionJsx } from '../../organisms/room/common'; - import { twemojify } from '../../../util/twemojify'; +import '../../i18n'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; - -import { Trans } from 'react-i18next'; import { getUserDisplayName } from '../../../util/matrixUtil'; function FollowingMembers({ roomTimeline }) { @@ -65,9 +61,9 @@ function FollowingMembers({ roomTimeline }) { user_one: twemojify(getUserDisplayName(room, filteredM?.[0])), user_two: twemojify(getUserDisplayName(room, filteredM?.[1])), user_three: twemojify(getUserDisplayName(room, filteredM?.[2])), - other_count: filteredM.length - 3 - }} - components={{bold: }} + other_count: filteredM.length - 3, + }} + components={{ bold: }} /> diff --git a/src/app/molecules/image-upload/ImageUpload.jsx b/src/app/molecules/image-upload/ImageUpload.jsx index 48da76d5..9dacf877 100644 --- a/src/app/molecules/image-upload/ImageUpload.jsx +++ b/src/app/molecules/image-upload/ImageUpload.jsx @@ -2,14 +2,14 @@ import React, { useState, useRef } from 'react'; import PropTypes from 'prop-types'; import './ImageUpload.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import Text from '../../atoms/text/Text'; import Avatar from '../../atoms/avatar/Avatar'; import Spinner from '../../atoms/spinner/Spinner'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function ImageUpload({ text, bgColor, imageSrc, onUpload, onRequestRemove, @@ -58,7 +58,7 @@ function ImageUpload({ size="large" />
- {uploadPromise === null && {t("Molecules.ImageUpload.prompt")}} + {uploadPromise === null && {t('Molecules.ImageUpload.prompt')}} {uploadPromise !== null && }
@@ -68,7 +68,7 @@ function ImageUpload({ type="button" onClick={uploadPromise === null ? onRequestRemove : cancelUpload} > - {uploadPromise ? t("Molecules.ImageUpload.cancel") : t("Molecules.ImageUpload.remove")} + {uploadPromise ? t('Molecules.ImageUpload.cancel') : t('Molecules.ImageUpload.remove')} )} diff --git a/src/app/molecules/import-export-e2e-room-keys/ExportE2ERoomKeys.jsx b/src/app/molecules/import-export-e2e-room-keys/ExportE2ERoomKeys.jsx index bc223bfd..3f9665ef 100644 --- a/src/app/molecules/import-export-e2e-room-keys/ExportE2ERoomKeys.jsx +++ b/src/app/molecules/import-export-e2e-room-keys/ExportE2ERoomKeys.jsx @@ -3,6 +3,7 @@ import './ExportE2ERoomKeys.scss'; import FileSaver from 'file-saver'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import { encryptMegolmKeyFile } from '../../../util/cryptE2ERoomKeys'; @@ -14,8 +15,7 @@ import Spinner from '../../atoms/spinner/Spinner'; import { useStore } from '../../hooks/useStore'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function ExportE2ERoomKeys() { const isMountStore = useStore(); @@ -34,14 +34,14 @@ function ExportE2ERoomKeys() { if (password !== confirmPasswordRef.current.value) { setStatus({ isOngoing: false, - msg: t("Molecules.ExportE2ERoomKeys.password_does_not_match"), + msg: t('Molecules.ExportE2ERoomKeys.password_does_not_match'), type: cons.status.ERROR, }); return; } setStatus({ isOngoing: true, - msg: t("Molecules.ExportE2ERoomKeys.getting_keys"), + msg: t('Molecules.ExportE2ERoomKeys.getting_keys'), type: cons.status.IN_FLIGHT, }); try { @@ -49,7 +49,7 @@ function ExportE2ERoomKeys() { if (isMountStore.getItem()) { setStatus({ isOngoing: true, - msg: t("Molecules.ExportE2ERoomKeys.encrypting_keys"), + msg: t('Molecules.ExportE2ERoomKeys.encrypting_keys'), type: cons.status.IN_FLIGHT, }); } @@ -61,7 +61,7 @@ function ExportE2ERoomKeys() { if (isMountStore.getItem()) { setStatus({ isOngoing: false, - msg: t("Molecules.ExportE2ERoomKeys.export_success"), + msg: t('Molecules.ExportE2ERoomKeys.export_success'), type: cons.status.SUCCESS, }); } @@ -69,7 +69,7 @@ function ExportE2ERoomKeys() { if (isMountStore.getItem()) { setStatus({ isOngoing: false, - msg: e.friendlyText || t("Molecules.ExportE2ERoomKeys.export_failed"), + msg: e.friendlyText || t('Molecules.ExportE2ERoomKeys.export_failed'), type: cons.status.ERROR, }); } @@ -88,7 +88,7 @@ function ExportE2ERoomKeys() {
{ e.preventDefault(); exportE2ERoomKeys(); }}> - +
{ status.type === cons.status.IN_FLIGHT && (
diff --git a/src/app/molecules/import-export-e2e-room-keys/ImportE2ERoomKeys.jsx b/src/app/molecules/import-export-e2e-room-keys/ImportE2ERoomKeys.jsx index 66d8c04d..4321ffcb 100644 --- a/src/app/molecules/import-export-e2e-room-keys/ImportE2ERoomKeys.jsx +++ b/src/app/molecules/import-export-e2e-room-keys/ImportE2ERoomKeys.jsx @@ -1,6 +1,7 @@ import React, { useState, useEffect, useRef } from 'react'; import './ImportE2ERoomKeys.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import { decryptMegolmKeyFile } from '../../../util/cryptE2ERoomKeys'; @@ -15,8 +16,7 @@ import CirclePlusIC from '../../../../public/res/ic/outlined/circle-plus.svg'; import { useStore } from '../../hooks/useStore'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function ImportE2ERoomKeys() { const isMountStore = useStore(); @@ -27,7 +27,7 @@ function ImportE2ERoomKeys() { type: cons.status.PRE_FLIGHT, }); const inputRef = useRef(null); - const passwordRef = useRef(null); + const passwordRef = useRef(null); const { t } = useTranslation(); @@ -37,7 +37,7 @@ function ImportE2ERoomKeys() { if (isMountStore.getItem()) { setStatus({ isOngoing: true, - msg: t("Molecules.ImportE2ERoomKeys.decrypting_file"), + msg: t('Molecules.ImportE2ERoomKeys.decrypting_file'), type: cons.status.IN_FLIGHT, }); } @@ -46,7 +46,7 @@ function ImportE2ERoomKeys() { if (isMountStore.getItem()) { setStatus({ isOngoing: true, - msg: t("Molecules.ImportE2ERoomKeys.decrypting_messages"), + msg: t('Molecules.ImportE2ERoomKeys.decrypting_messages'), type: cons.status.IN_FLIGHT, }); } @@ -54,7 +54,7 @@ function ImportE2ERoomKeys() { if (isMountStore.getItem()) { setStatus({ isOngoing: false, - msg: t("Molecules.ImportE2ERoomKeys.import_success"), + msg: t('Molecules.ImportE2ERoomKeys.import_success'), type: cons.status.SUCCESS, }); inputRef.current.value = null; @@ -64,7 +64,7 @@ function ImportE2ERoomKeys() { if (isMountStore.getItem()) { setStatus({ isOngoing: false, - msg: e.friendlyText || t("Molecules.ImportE2ERoomKeys.import_failed"), + msg: e.friendlyText || t('Molecules.ImportE2ERoomKeys.import_failed'), type: cons.status.ERROR, }); } @@ -119,9 +119,9 @@ function ImportE2ERoomKeys() { {keyFile.name}
)} - {keyFile === null && } + {keyFile === null && } - + { status.type === cons.status.IN_FLIGHT && (
diff --git a/src/app/molecules/media/Media.jsx b/src/app/molecules/media/Media.jsx index 449b6dfd..49f6783b 100644 --- a/src/app/molecules/media/Media.jsx +++ b/src/app/molecules/media/Media.jsx @@ -4,6 +4,7 @@ import './Media.scss'; import encrypt from 'browser-encrypt-attachment'; +import { useTranslation } from 'react-i18next'; import Text from '../../atoms/text/Text'; import IconButton from '../../atoms/button/IconButton'; import Spinner from '../../atoms/spinner/Spinner'; @@ -12,8 +13,7 @@ import DownloadSVG from '../../../../public/res/ic/outlined/download.svg'; import ExternalSVG from '../../../../public/res/ic/outlined/external.svg'; import PlaySVG from '../../../../public/res/ic/outlined/play.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; // https://github.com/matrix-org/matrix-react-sdk/blob/a9e28db33058d1893d964ec96cd247ecc3d92fc3/src/utils/blobs.ts#L73 const ALLOWED_BLOB_MIMETYPES = [ @@ -99,7 +99,7 @@ function FileHeader({ external && ( window.open(url || link)} /> @@ -108,7 +108,7 @@ function FileHeader({ @@ -155,7 +155,6 @@ function Image({ name, width, height, link, file, type, }) { const [url, setUrl] = useState(null); - useEffect(() => { let unmounted = false; @@ -217,7 +216,7 @@ function Audio({
{ url === null && isLoading && } - { url === null && !isLoading && } + { url === null && !isLoading && } { url !== null && ( /* eslint-disable-next-line jsx-a11y/media-has-caption */
- { isEdited && } + { isEdited && }
); }); @@ -297,14 +295,14 @@ function MessageEdit({ body, onSave, onCancel }) { forwardRef={editInputRef} onKeyDown={handleKeyDown} value={body} - placeholder={t("Molecules.Message.edit_placeholder")} + placeholder={t('Molecules.Message.edit_placeholder')} required resizable autoFocus />
- - + +
); @@ -351,20 +349,17 @@ function pickEmoji(e, roomId, eventId, roomTimeline) { function genReactionMsg(userIds, reaction) { console.log(reaction); return ( - <> - , emoji: reaction}} - - /> - + , emoji: reaction }} + /> ); } @@ -520,6 +515,8 @@ const MessageOptions = React.memo(({ const canIRedact = room.currentState.hasSufficientPowerLevelFor('redact', myPowerlevel); const canSendReaction = room.currentState.maySendEvent('m.reaction', mx.getUserId()); + const { t } = useTranslation(); + return (
{canSendReaction && ( @@ -527,38 +524,38 @@ const MessageOptions = React.memo(({ onClick={(e) => pickEmoji(e, roomId, mEvent.getId(), roomTimeline)} src={EmojiAddIC} size="extra-small" - tooltip={t("Molecules.Message.add_reaction_tooltip")} + tooltip={t('Molecules.Message.add_reaction_tooltip')} /> )} reply()} src={ReplyArrowIC} size="extra-small" - tooltip={t("Molecules.Message.reply_tooltip")} + tooltip={t('Molecules.Message.reply_tooltip')} /> {(senderId === mx.getUserId() && !isMedia(mEvent)) && ( edit(true)} src={PencilIC} size="extra-small" - tooltip={t("Molecules.Message.edit_tooltip")} + tooltip={t('Molecules.Message.edit_tooltip')} /> )} ( <> - {t("Molecules.Message.options_header")} + {t('Molecules.Message.options_header')} openReadReceipts(roomId, roomTimeline.getEventReaders(mEvent))} > - {t("Molecules.Message.read_receipts")} + {t('Molecules.Message.read_receipts')} handleOpenViewSource(mEvent, roomTimeline)} > - {t("Molecules.Message.view_source")} + {t('Molecules.Message.view_source')} {(canIRedact || senderId === mx.getUserId()) && ( <> @@ -568,9 +565,9 @@ const MessageOptions = React.memo(({ iconSrc={BinIC} onClick={async () => { const isConfirmed = await confirmDialog( - t("Molecules.Message.delete_message_prompt"), - t("Molecules.Message.delete_message_confirmation"), - t("Molecules.Message.delete_message_button"), + t('Molecules.Message.delete_message_prompt'), + t('Molecules.Message.delete_message_confirmation'), + t('Molecules.Message.delete_message_button'), 'danger', ); if (!isConfirmed) return; @@ -588,7 +585,7 @@ const MessageOptions = React.memo(({ onClick={toggleMenu} src={VerticalMenuIC} size="extra-small" - tooltip={t("Molecules.Message.options_tooltip")} + tooltip={t('Molecules.Message.options_tooltip')} /> )} /> diff --git a/src/app/molecules/popup-window/PopupWindow.jsx b/src/app/molecules/popup-window/PopupWindow.jsx index 90c26642..ea5973da 100644 --- a/src/app/molecules/popup-window/PopupWindow.jsx +++ b/src/app/molecules/popup-window/PopupWindow.jsx @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import './PopupWindow.scss'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import Text from '../../atoms/text/Text'; @@ -13,8 +14,7 @@ import RawModal from '../../atoms/modal/RawModal'; import ChevronLeftIC from '../../../../public/res/ic/outlined/chevron-left.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function PWContentSelector({ selected, variant, iconSrc, @@ -74,7 +74,7 @@ function PopupWindow({ {haveDrawer && (
- + { typeof title === 'string' diff --git a/src/app/molecules/power-level-selector/PowerLevelSelector.jsx b/src/app/molecules/power-level-selector/PowerLevelSelector.jsx index e60438b9..1bdee441 100644 --- a/src/app/molecules/power-level-selector/PowerLevelSelector.jsx +++ b/src/app/molecules/power-level-selector/PowerLevelSelector.jsx @@ -2,13 +2,13 @@ import React from 'react'; import PropTypes from 'prop-types'; import './PowerLevelSelector.scss'; +import { useTranslation } from 'react-i18next'; import IconButton from '../../atoms/button/IconButton'; import { MenuHeader, MenuItem } from '../../atoms/context-menu/ContextMenu'; import CheckIC from '../../../../public/res/ic/outlined/check.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function PowerLevelSelector({ value, max, onSelect, @@ -30,7 +30,7 @@ function PowerLevelSelector({ defaultValue={value} type="number" name="power-level" - placeholder={t("Molecules.PowerLevelIndicator.placeholder")} + placeholder={t('Molecules.PowerLevelIndicator.placeholder')} max={max} autoComplete="off" required diff --git a/src/app/molecules/room-aliases/RoomAliases.jsx b/src/app/molecules/room-aliases/RoomAliases.jsx index ae4e78a6..1745f6eb 100644 --- a/src/app/molecules/room-aliases/RoomAliases.jsx +++ b/src/app/molecules/room-aliases/RoomAliases.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import './RoomAliases.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import { Debounce } from '../../../util/common'; @@ -17,14 +18,12 @@ import SettingTile from '../setting-tile/SettingTile'; import { useStore } from '../../hooks/useStore'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function useValidate(hsString) { const [debounce] = useState(new Debounce()); const [validate, setValidate] = useState({ alias: null, status: cons.status.PRE_FLIGHT }); - const { t } = useTranslation(); const setValidateToDefault = () => { @@ -43,7 +42,7 @@ function useValidate(hsString) { setValidate({ alias: null, status: cons.status.ERROR, - msg: t("Molecules.RoomAliases.invalid_characters") + msg: t('Molecules.RoomAliases.invalid_characters'), }); return false; } @@ -65,7 +64,7 @@ function useValidate(hsString) { setValidate({ alias, status: cons.status.IN_FLIGHT, - msg: t("Molecules.RoomAliases.validating_alias", {alias: alias}), + msg: t('Molecules.RoomAliases.validating_alias', { alias }), }); const isValid = await isRoomAliasAvailable(alias); @@ -76,7 +75,7 @@ function useValidate(hsString) { return { alias, status: isValid ? cons.status.SUCCESS : cons.status.ERROR, - msg: t( isValid ? "Molecules.RoomAliases.alias_available": "Molecules.RoomAliases.alias_unavailable", {alias: alias}), + msg: t(isValid ? 'Molecules.RoomAliases.alias_available' : 'Molecules.RoomAliases.alias_unavailable', { alias }), }; }); }, 600)(); @@ -233,7 +232,7 @@ function RoomAliases({ roomId }) { const handleDeleteAlias = async (alias) => { try { - setDeleteAlias({ alias, status: cons.status.IN_FLIGHT, msg: t("Molecules.RoomAliases.deleting_alias")}); + setDeleteAlias({ alias, status: cons.status.IN_FLIGHT, msg: t('Molecules.RoomAliases.deleting_alias') }); await mx.deleteAlias(alias); let { main, published, local } = aliases; if (published.includes(alias)) { @@ -267,10 +266,10 @@ function RoomAliases({ roomId }) { return (
- {canPublishAlias && !isMain && } - {!isPublished && canPublishAlias && } - {isPublished && canPublishAlias && } - + {canPublishAlias && !isMain && } + {!isPublished && canPublishAlias && } + {isPublished && canPublishAlias && } +
); }; @@ -286,7 +285,7 @@ function RoomAliases({ roomId }) { handleAliasSelect(alias)} /> {alias} - {isMain && {t("Molecules.RoomAliases.main_alias")}} + {isMain && {t('Molecules.RoomAliases.main_alias')}}
{isActive && renderAliasBtns(alias)} @@ -300,8 +299,8 @@ function RoomAliases({ roomId }) { return (
{t(room.isSpaceRoom() ? "Molecules.RoomAliases.publish_to_room_directory.publish_space_message" : "Molecules.RoomAliases.publish_to_room_directory.publish_room_message", {homeserver: hsString})}} + title={t('Molecules.RoomAliases.publish_to_room_directory.title')} + content={{t(room.isSpaceRoom() ? 'Molecules.RoomAliases.publish_to_room_directory.publish_space_message' : 'Molecules.RoomAliases.publish_to_room_directory.publish_room_message', { homeserver: hsString })}} options={(
- {t("Molecules.RoomAliases.published_addresses.title")} - {(aliases.published.length === 0) && {t("Molecules.RoomAliases.published_addresses.none")}} - {(aliases.published.length > 0 && !aliases.main) && {t("Molecules.RoomAliases.published_addresses.no_main_address")}} + {t('Molecules.RoomAliases.published_addresses.title')} + {(aliases.published.length === 0) && {t('Molecules.RoomAliases.published_addresses.none')}} + {(aliases.published.length > 0 && !aliases.main) && {t('Molecules.RoomAliases.published_addresses.no_main_address')}} {aliases.published.map(renderAlias)} - {t(room.isSpaceRoom() ? "Molecules.RoomAliases.published_addresses.message_space" : "Molecules.RoomAliases.published_addresses.message_room")} + {t(room.isSpaceRoom() ? 'Molecules.RoomAliases.published_addresses.message_space' : 'Molecules.RoomAliases.published_addresses.message_room')}
{ isLocalVisible && (
- {t("Molecules.RoomAliases.local_addresses.title")} - {(aliases.local.length === 0) && {t("Molecules.RoomAliases.local_addresses.none")}} + {t('Molecules.RoomAliases.local_addresses.title')} + {(aliases.local.length === 0) && {t('Molecules.RoomAliases.local_addresses.none')}} {aliases.local.map(renderAlias)} - {t(room.isSpaceRoom() ? "Molecules.RoomAliases.local_addresses.message_space" : "Molecules.RoomAliases.local_addresses.message_room" )} + {t(room.isSpaceRoom() ? 'Molecules.RoomAliases.local_addresses.message_space' : 'Molecules.RoomAliases.local_addresses.message_room')} - {t("Molecules.RoomAliases.local_addresses.add")} + {t('Molecules.RoomAliases.local_addresses.add')}
- +
{validate.status === cons.status.SUCCESS && {validate.msg}} @@ -350,7 +349,7 @@ function RoomAliases({ roomId }) { )}
diff --git a/src/app/molecules/room-encryption/RoomEncryption.jsx b/src/app/molecules/room-encryption/RoomEncryption.jsx index 33737171..2cf99831 100644 --- a/src/app/molecules/room-encryption/RoomEncryption.jsx +++ b/src/app/molecules/room-encryption/RoomEncryption.jsx @@ -2,6 +2,7 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; import './RoomEncryption.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import Text from '../../atoms/text/Text'; @@ -10,8 +11,8 @@ import SettingTile from '../setting-tile/SettingTile'; import { confirmDialog } from '../confirm-dialog/ConfirmDialog'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; + function RoomEncryption({ roomId }) { const mx = initMatrix.matrixClient; @@ -24,14 +25,14 @@ function RoomEncryption({ roomId }) { const handleEncryptionEnable = async () => { const joinRule = room.getJoinRule(); - const confirmMsg1 = t("Molecules.RoomEncryption.encryption_public_room_message"); - const confirmMsg2 = t("Molecules.RoomEncryption.encryption_message"); + const confirmMsg1 = t('Molecules.RoomEncryption.encryption_public_room_message'); + const confirmMsg2 = t('Molecules.RoomEncryption.encryption_message'); const isConfirmed1 = (joinRule === 'public') - ? await confirmDialog(t("Molecules.RoomEncryption.enable_encryption_prompt"), confirmMsg1, t("Molecules.RoomEncryption.continue_button"), 'caution') + ? await confirmDialog(t('Molecules.RoomEncryption.enable_encryption_prompt'), confirmMsg1, t('Molecules.RoomEncryption.continue_button'), 'caution') : true; if (!isConfirmed1) return; - if (await confirmDialog(t("Molecules.RoomEncryption.enable_encryption_prompt"), confirmMsg2, t("Molecules.RoomEncryption.enable_encryption_button"), 'caution')) { + if (await confirmDialog(t('Molecules.RoomEncryption.enable_encryption_prompt'), confirmMsg2, t('Molecules.RoomEncryption.enable_encryption_button'), 'caution')) { setIsEncrypted(true); mx.sendStateEvent(roomId, 'm.room.encryption', { algorithm: 'm.megolm.v1.aes-sha2', @@ -42,9 +43,9 @@ function RoomEncryption({ roomId }) { return (
{t("Molecules.RoomEncryption.encryption_cannot_be_disabled")} + {t('Molecules.RoomEncryption.encryption_cannot_be_disabled')} )} options={( )) } - {t("Molecules.RoomHistoryVisibility.changes_only_affect_future")} + {t('Molecules.RoomHistoryVisibility.changes_only_affect_future')}
); } diff --git a/src/app/molecules/room-members/RoomMembers.jsx b/src/app/molecules/room-members/RoomMembers.jsx index aa506210..65b47835 100644 --- a/src/app/molecules/room-members/RoomMembers.jsx +++ b/src/app/molecules/room-members/RoomMembers.jsx @@ -4,6 +4,7 @@ import React, { import PropTypes from 'prop-types'; import './RoomMembers.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import colorMXID from '../../../util/colorMXID'; import { openProfileViewer } from '../../../client/action/navigation'; @@ -18,8 +19,7 @@ import { MenuHeader } from '../../atoms/context-menu/ContextMenu'; import SegmentedControls from '../../atoms/segmented-controls/SegmentedControls'; import PeopleSelector from '../people-selector/PeopleSelector'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; const PER_PAGE_MEMBER = 50; @@ -129,14 +129,14 @@ function RoomMembers({ roomId }) { const mList = searchMembers ? searchMembers.data : members.slice(0, itemCount); return (
- {t("Molecules.RoomMembers.search_title")} + {t('Molecules.RoomMembers.search_title')}
- {t("Molecules.RoomMembers.found_members", {count: mList.length})} + {t('Molecules.RoomMembers.found_members', { count: mList.length })} { @@ -144,7 +144,7 @@ function RoomMembers({ roomId }) { return getSegmentIndex[membership]; })() } - segments={[{ text: t("Molecules.RoomMembers.joined") }, { text: t("Molecules.RoomMembers.invited") }, { text: t("Molecules.RoomMembers.banned") }]} + segments={[{ text: t('Molecules.RoomMembers.joined') }, { text: t('Molecules.RoomMembers.invited') }, { text: t('Molecules.RoomMembers.banned') }]} onSelect={(index) => { const memberships = ['join', 'invite', 'ban']; setMembership(memberships[index]); @@ -167,7 +167,7 @@ function RoomMembers({ roomId }) { && (
- {searchMembers ? t("Molecules.RoomMembers.invited", {term: searchMembers.term}) : t("Molecules.RoomMembers.no_members")} + {searchMembers ? t('Molecules.RoomMembers.invited', { term: searchMembers.term }) : t('Molecules.RoomMembers.no_members')}
) @@ -176,7 +176,7 @@ function RoomMembers({ roomId }) { mList.length !== 0 && members.length > itemCount && searchMembers === null - && + && }
diff --git a/src/app/molecules/room-notification/RoomNotification.jsx b/src/app/molecules/room-notification/RoomNotification.jsx index 3051a66a..b5e7cfe5 100644 --- a/src/app/molecules/room-notification/RoomNotification.jsx +++ b/src/app/molecules/room-notification/RoomNotification.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect, useCallback } from 'react'; import PropTypes from 'prop-types'; import './RoomNotification.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; @@ -14,8 +15,7 @@ import BellRingIC from '../../../../public/res/ic/outlined/bell-ring.svg'; import BellPingIC from '../../../../public/res/ic/outlined/bell-ping.svg'; import BellOffIC from '../../../../public/res/ic/outlined/bell-off.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; const items = [{ iconSrc: BellIC, @@ -117,7 +117,6 @@ function useNotifications(roomId) { } function RoomNotification({ roomId }) { - const { t } = useTranslation(); const [activeType, setNotification] = useNotifications(roomId); diff --git a/src/app/molecules/room-options/RoomOptions.jsx b/src/app/molecules/room-options/RoomOptions.jsx index fd2bf3cf..48596152 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'; @@ -17,8 +18,7 @@ import LeaveArrowIC from '../../../../public/res/ic/outlined/leave-arrow.svg'; import { confirmDialog } from '../confirm-dialog/ConfirmDialog'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function RoomOptions({ roomId, afterOptionSelect }) { const mx = initMatrix.matrixClient; @@ -39,9 +39,9 @@ function RoomOptions({ roomId, afterOptionSelect }) { const handleLeaveClick = async () => { afterOptionSelect(); const isConfirmed = await confirmDialog( - t("Molecules.RoomOptions.leave.title"), - t("Molecules.RoomOptions.leave.subtitle", {room_name: room.name}), - t("Molecules.RoomOptions.leave.button_text"), + t('Molecules.RoomOptions.leave.title'), + t('Molecules.RoomOptions.leave.subtitle', { room_name: room.name }), + t('Molecules.RoomOptions.leave.button_text'), 'danger', ); if (!isConfirmed) return; @@ -50,17 +50,17 @@ function RoomOptions({ roomId, afterOptionSelect }) { return (
- {twemojify(t("Molecules.RoomOptions.title", {room_name: initMatrix.matrixClient.getRoom(roomId)?.name}))} - {t("Molecules.RoomOptions.mark_as_read")} + {twemojify(t('Molecules.RoomOptions.title', { room_name: initMatrix.matrixClient.getRoom(roomId)?.name }))} + {t('Molecules.RoomOptions.mark_as_read')} - {t("Molecules.RoomOptions.invite")} + {t('Molecules.RoomOptions.invite')} - {t("Molecules.RoomOptions.leave.button_text")} - {t("Molecules.RoomOptions.notifications_heading")} + {t('Molecules.RoomOptions.leave.button_text')} + {t('Molecules.RoomOptions.notifications_heading')}
); diff --git a/src/app/molecules/room-permissions/RoomPermissions.jsx b/src/app/molecules/room-permissions/RoomPermissions.jsx index def9c173..79ec2215 100644 --- a/src/app/molecules/room-permissions/RoomPermissions.jsx +++ b/src/app/molecules/room-permissions/RoomPermissions.jsx @@ -2,6 +2,7 @@ import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; import './RoomPermissions.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import { getPowerLabel } from '../../../util/matrixUtil'; import { openReusableContextMenu } from '../../../client/action/navigation'; @@ -17,8 +18,7 @@ import ChevronBottomIC from '../../../../public/res/ic/outlined/chevron-bottom.s import { useForceUpdate } from '../../hooks/useForceUpdate'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; const permissionsInfo = { users_default: { diff --git a/src/app/molecules/room-profile/RoomProfile.jsx b/src/app/molecules/room-profile/RoomProfile.jsx index d20cbbee..9e982017 100644 --- a/src/app/molecules/room-profile/RoomProfile.jsx +++ b/src/app/molecules/room-profile/RoomProfile.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import './RoomProfile.scss'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; @@ -21,8 +22,7 @@ import { useStore } from '../../hooks/useStore'; import { useForceUpdate } from '../../hooks/useForceUpdate'; import { confirmDialog } from '../confirm-dialog/ConfirmDialog'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function RoomProfile({ roomId }) { const isMountStore = useStore(); @@ -81,7 +81,7 @@ function RoomProfile({ roomId }) { const newName = roomNameInput.value; if (newName !== roomName && roomName.trim() !== '') { setStatus({ - msg: t("Molecules.RoomProfile.saving_room_name"), + msg: t('Molecules.RoomProfile.saving_room_name'), type: cons.status.IN_FLIGHT, }); await mx.setRoomName(roomId, newName); @@ -92,7 +92,7 @@ function RoomProfile({ roomId }) { if (newTopic !== roomTopic) { if (isMountStore.getItem()) { setStatus({ - msg: t("Molecules.RoomProfile.saving_room_topic"), + msg: t('Molecules.RoomProfile.saving_room_topic'), type: cons.status.IN_FLIGHT, }); } @@ -101,13 +101,13 @@ function RoomProfile({ roomId }) { } if (!isMountStore.getItem()) return; setStatus({ - msg: t("Molecules.RoomProfile.save_success"), + msg: t('Molecules.RoomProfile.save_success'), type: cons.status.SUCCESS, }); } catch (err) { if (!isMountStore.getItem()) return; setStatus({ - msg: err.message || t("Molecules.RoomProfile.save_failed"), + msg: err.message || t('Molecules.RoomProfile.save_failed'), type: cons.status.ERROR, }); } @@ -124,9 +124,9 @@ function RoomProfile({ roomId }) { const handleAvatarUpload = async (url) => { if (url === null) { const isConfirmed = await confirmDialog( - t("Molecules.RoomProfile.remove_avatar_title"), - t("Molecules.RoomProfile.remove_avatar_subtitle"), - t("Molecules.RoomProfile.remove_avatar_button"), + t('Molecules.RoomProfile.remove_avatar_title'), + t('Molecules.RoomProfile.remove_avatar_subtitle'), + t('Molecules.RoomProfile.remove_avatar_button'), 'caution', ); if (isConfirmed) { @@ -137,20 +137,25 @@ function RoomProfile({ roomId }) { const renderEditNameAndTopic = () => (
- {canChangeName && } - {canChangeTopic && } - {(!canChangeName || !canChangeTopic) && { - room.isSpaceRoom() ? - canChangeName ? "Molecules.RoomProfile.permission_change_space_name" : "Molecules.RoomProfile.permission_change_space_topic" : - canChangeName ? "Molecules.RoomProfile.permission_change_room_name": "Molecules.RoomProfile.permission_change_room_topic" - }} + {canChangeName && } + {canChangeTopic && } + {(!canChangeName || !canChangeTopic) && ( + + { + // eslint-disable-next-line no-nested-ternary + room.isSpaceRoom() + ? canChangeName ? 'Molecules.RoomProfile.permission_change_space_name' : 'Molecules.RoomProfile.permission_change_space_topic' + : canChangeName ? 'Molecules.RoomProfile.permission_change_room_name' : 'Molecules.RoomProfile.permission_change_room_topic' + } + + )} { status.type === cons.status.IN_FLIGHT && {status.msg}} { status.type === cons.status.SUCCESS && {status.msg}} { status.type === cons.status.ERROR && {status.msg}} { status.type !== cons.status.IN_FLIGHT && (
- - + +
)}
@@ -164,7 +169,7 @@ function RoomProfile({ roomId }) { setIsEditing(true)} /> )} diff --git a/src/app/molecules/room-search/RoomSearch.jsx b/src/app/molecules/room-search/RoomSearch.jsx index 30977c16..703f108c 100644 --- a/src/app/molecules/room-search/RoomSearch.jsx +++ b/src/app/molecules/room-search/RoomSearch.jsx @@ -4,6 +4,7 @@ import './RoomSearch.scss'; import dateFormat from 'dateformat'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import { selectRoom } from '../../../client/action/navigation'; @@ -20,8 +21,7 @@ import SearchIC from '../../../../public/res/ic/outlined/search.svg'; import { useStore } from '../../hooks/useStore'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; const roomIdToBackup = new Map(); @@ -144,37 +144,37 @@ function RoomSearch({ roomId }) { return (
- {t("Molecules.RoomSearch.title")} + {t('Molecules.RoomSearch.title')}
- +
{searchData?.results.length > 0 && ( - {t("Molecules.RoomSearch.results", {count: searchData.count, term: searchTerm})} + {t('Molecules.RoomSearch.results', { count: searchData.count, term: searchTerm })} )} {!isRoomEncrypted && searchData === null && (
{status.type === cons.status.IN_FLIGHT && } - {status.type === cons.status.IN_FLIGHT && {t("Molecules.RoomSearch.searching")}} + {status.type === cons.status.IN_FLIGHT && {t('Molecules.RoomSearch.searching')}} {status.type === cons.status.PRE_FLIGHT && } - {status.type === cons.status.PRE_FLIGHT && {t("Molecules.RoomSearch.subtitle")}} - {status.type === cons.status.ERROR && {t("Molecules.RoomSearch.failed")}} + {status.type === cons.status.PRE_FLIGHT && {t('Molecules.RoomSearch.subtitle')}} + {status.type === cons.status.ERROR && {t('Molecules.RoomSearch.failed')}}
)} {!isRoomEncrypted && searchData?.results.length === 0 && (
- {t("Molecules.RoomSearch.no_results")} + {t('Molecules.RoomSearch.no_results')}
)} {isRoomEncrypted && (
- {t("Molecules.RoomSearch.encrypted_room")} + {t('Molecules.RoomSearch.encrypted_room')}
)}
@@ -189,7 +189,7 @@ function RoomSearch({ roomId }) { {searchData?.next_batch && (
{status.type !== cons.status.IN_FLIGHT && ( - + )} {status.type === cons.status.IN_FLIGHT && }
diff --git a/src/app/molecules/room-tile/RoomTile.jsx b/src/app/molecules/room-tile/RoomTile.jsx index 5bc10fab..61d170df 100644 --- a/src/app/molecules/room-tile/RoomTile.jsx +++ b/src/app/molecules/room-tile/RoomTile.jsx @@ -2,18 +2,22 @@ import React from 'react'; import PropTypes from 'prop-types'; import './RoomTile.scss'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import colorMXID from '../../../util/colorMXID'; import Text from '../../atoms/text/Text'; import Avatar from '../../atoms/avatar/Avatar'; -import { t } from 'i18next'; + +import '../../i18n'; function RoomTile({ avatarSrc, name, id, inviterName, memberCount, desc, options, }) { + const { t } = useTranslation(); + return (
@@ -28,8 +32,8 @@ function RoomTile({ { inviterName !== null - ? t("Molecules.RoomTile.invited_by_user", {inviter: inviterName, count: memberCount || 0, id: id}) - : t("Molecules.RoomTile.invited", {count: memberCount || 0, id: id}) + ? t('Molecules.RoomTile.invited_by_user', { inviter: inviterName, count: memberCount || 0, id }) + : t('Molecules.RoomTile.invited', { count: memberCount || 0, id }) } { diff --git a/src/app/molecules/room-visibility/RoomVisibility.jsx b/src/app/molecules/room-visibility/RoomVisibility.jsx index f8cc732e..e4019c2d 100644 --- a/src/app/molecules/room-visibility/RoomVisibility.jsx +++ b/src/app/molecules/room-visibility/RoomVisibility.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect, useCallback } from 'react'; import PropTypes from 'prop-types'; import './RoomVisibility.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import Text from '../../atoms/text/Text'; @@ -15,8 +16,7 @@ import SpaceIC from '../../../../public/res/ic/outlined/space.svg'; import SpaceLockIC from '../../../../public/res/ic/outlined/space-lock.svg'; import SpaceGlobeIC from '../../../../public/res/ic/outlined/space-globe.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; const visibility = { INVITE: 'invite', diff --git a/src/app/molecules/space-add-existing/SpaceAddExisting.jsx b/src/app/molecules/space-add-existing/SpaceAddExisting.jsx index 664f218a..57b9aba5 100644 --- a/src/app/molecules/space-add-existing/SpaceAddExisting.jsx +++ b/src/app/molecules/space-add-existing/SpaceAddExisting.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import './SpaceAddExisting.scss'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; @@ -25,9 +26,7 @@ import SearchIC from '../../../../public/res/ic/outlined/search.svg'; import { useStore } from '../../hooks/useStore'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; -import { t } from 'i18next'; +import '../../i18n'; function SpaceAddExistingContent({ roomId }) { const mountStore = useStore(roomId); @@ -41,7 +40,6 @@ function SpaceAddExistingContent({ roomId }) { spaces, rooms, directs, roomIdToParents, } = initMatrix.roomList; - const { t } = useTranslation(); useEffect(() => { @@ -66,7 +64,7 @@ function SpaceAddExistingContent({ roomId }) { }; const handleAdd = async () => { - setProcess(t("Molecules.SpaceAddExisting.adding_items", {count: selected.length})); + setProcess(t('Molecules.SpaceAddExisting.adding_items', { count: selected.length })); const promises = selected.map((rId) => { const room = mx.getRoom(rId); @@ -126,12 +124,12 @@ function SpaceAddExistingContent({ roomId }) { - {searchIds?.length === 0 && {t("Molecules.SpaceAddExisting.no_results")}} + {searchIds?.length === 0 && {t('Molecules.SpaceAddExisting.no_results')}} { (searchIds || allRoomIds).map((rId) => { const room = mx.getRoom(rId); @@ -178,9 +176,9 @@ function SpaceAddExistingContent({ roomId }) { {selected.length !== 0 && (
{process && } - {t("Molecules.SpaceAddExisting.items_selected", {count: selected.length})} + {t('Molecules.SpaceAddExisting.items_selected', { count: selected.length })} { !process && ( - + )}
)} @@ -212,6 +210,8 @@ function SpaceAddExisting() { const mx = initMatrix.matrixClient; const room = mx.getRoom(roomId); + const { t } = useTranslation(); + return ( {roomId && twemojify(room.name)} - — {t("Molecules.SpaceAddExisting.subtitle")} + + {' '} + — + {' '} + {t('Molecules.SpaceAddExisting.subtitle')} + )} - contentOptions={} + contentOptions={} onRequestClose={requestClose} > { diff --git a/src/app/molecules/space-options/SpaceOptions.jsx b/src/app/molecules/space-options/SpaceOptions.jsx index 13a1029c..85eecabb 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'; @@ -26,8 +27,7 @@ import PinFilledIC from '../../../../public/res/ic/filled/pin.svg'; import { confirmDialog } from '../confirm-dialog/ConfirmDialog'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function SpaceOptions({ roomId, afterOptionSelect }) { const mx = initMatrix.matrixClient; @@ -64,9 +64,9 @@ function SpaceOptions({ roomId, afterOptionSelect }) { const handleLeaveClick = async () => { afterOptionSelect(); const isConfirmed = await confirmDialog( - t("Molecules.SpaceOptions.leave_space"), - t("Molecules.SpaceOptions.leave_space_confirmation", {space: room.name}), - t("Molecules.SpaceOptions.leave_space_confirmation"), + t('Molecules.SpaceOptions.leave_space'), + t('Molecules.SpaceOptions.leave_space_confirmation', { space: room.name }), + t('Molecules.SpaceOptions.leave_space_confirmation'), 'danger', ); if (!isConfirmed) return; @@ -80,29 +80,29 @@ function SpaceOptions({ roomId, afterOptionSelect }) { onClick={handleCategorizeClick} iconSrc={isCategorized ? CategoryFilledIC : CategoryIC} > - {isCategorized ? t("Organisms.SpaceSettings.uncategorize_subspaces") : t("Organisms.SpaceSettings.categorize_subspaces")} + {isCategorized ? t('Organisms.SpaceSettings.uncategorize_subspaces') : t('Organisms.SpaceSettings.categorize_subspaces')} - {isPinned ? t("Organisms.SpaceSettings.unpin_sidebar") : t("Organisms.SpaceSettings.pin_sidebar")} + {isPinned ? t('Organisms.SpaceSettings.unpin_sidebar') : t('Organisms.SpaceSettings.pin_sidebar')} - {t("Molecules.SpaceOptions.invite")} + {t('Molecules.SpaceOptions.invite')} - {t("Molecules.SpaceOptions.manage_rooms")} - {t("Molecules.SpaceOptions.settings")} + {t('Molecules.SpaceOptions.manage_rooms')} + {t('Molecules.SpaceOptions.settings')} - {t("Molecules.SpaceOptions.leave")} + {t('Molecules.SpaceOptions.leave')}
); diff --git a/src/app/molecules/sso-buttons/SSOButtons.jsx b/src/app/molecules/sso-buttons/SSOButtons.jsx index ebc724d1..6076964c 100644 --- a/src/app/molecules/sso-buttons/SSOButtons.jsx +++ b/src/app/molecules/sso-buttons/SSOButtons.jsx @@ -2,15 +2,15 @@ import React from 'react'; import PropTypes from 'prop-types'; import './SSOButtons.scss'; +import { useTranslation } from 'react-i18next'; import { createTemporaryClient, startSsoLogin } from '../../../client/action/auth'; import Button from '../../atoms/button/Button'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function SSOButtons({ type, identityProviders, baseUrl }) { - const tempClient = createTemporaryClient(baseUrl); + const tempClient = createTemporaryClient(baseUrl); const { t } = useTranslation(); function handleClick(id) { startSsoLogin(baseUrl, type, id); @@ -28,7 +28,7 @@ function SSOButtons({ type, identityProviders, baseUrl }) { - ) : + ) : ))}
); diff --git a/src/app/organisms/create-room/CreateRoom.jsx b/src/app/organisms/create-room/CreateRoom.jsx index 5c10618d..79359465 100644 --- a/src/app/organisms/create-room/CreateRoom.jsx +++ b/src/app/organisms/create-room/CreateRoom.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect, useRef } from 'react'; import PropTypes from 'prop-types'; import './CreateRoom.scss'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; @@ -33,12 +34,9 @@ import SpaceGlobeIC from '../../../../public/res/ic/outlined/space-globe.svg'; import ChevronBottomIC from '../../../../public/res/ic/outlined/chevron-bottom.svg'; import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; -import { t } from 'i18next'; +import '../../i18n'; function CreateRoomContent({ isSpace, parentId, onRequestClose }) { - const { t } = useTranslation(); const [joinRule, setJoinRule] = useState(parentId ? 'restricted' : 'invite'); @@ -137,8 +135,8 @@ function CreateRoomContent({ isSpace, parentId, onRequestClose }) { }; const joinRules = ['invite', 'restricted', 'public']; - const joinRuleShortText = [ t("Organisms.CreateRoom.private_room_short"), t("Organisms.CreateRoom.restricted_room_short"), t("Organisms.CreateRoom.public_room_short")]; - const joinRuleText = [ t("Organisms.CreateRoom.private_room_long"), t("Organisms.CreateRoom.restricted_room_long"), t("Organisms.CreateRoom.public_room_long")]; + const joinRuleShortText = [t('Organisms.CreateRoom.private_room_short'), t('Organisms.CreateRoom.restricted_room_short'), t('Organisms.CreateRoom.public_room_short')]; + const joinRuleText = [t('Organisms.CreateRoom.private_room_long'), t('Organisms.CreateRoom.restricted_room_long'), t('Organisms.CreateRoom.public_room_long')]; const jrRoomIC = [HashLockIC, HashIC, HashGlobeIC]; const jrSpaceIC = [SpaceLockIC, SpaceIC, SpaceGlobeIC]; const handleJoinRule = (evt) => { @@ -147,7 +145,7 @@ function CreateRoomContent({ isSpace, parentId, onRequestClose }) { getEventCords(evt, '.btn-surface'), (closeMenu) => ( <> - {t("Organisms.CreateRoom.visibility_message")} + {t('Organisms.CreateRoom.visibility_message')} { joinRules.map((rule) => (
{joinRuleShortText[joinRules.indexOf(joinRule)]} )} - content={{isSpace ? t("Organisms.CreateRoom.select_who_can_join_space") : t("Organisms.CreateRoom.select_who_can_join_room")}} + content={{isSpace ? t('Organisms.CreateRoom.select_who_can_join_space') : t('Organisms.CreateRoom.select_who_can_join_room')}} /> {joinRule === 'public' && (
- {isSpace ? t("Organisms.CreateRoom.space_address") : t("Organisms.CreateRoom.room_address")} + {isSpace ? t('Organisms.CreateRoom.space_address') : t('Organisms.CreateRoom.room_address')}
# {`:${userHs}`}
- {isValidAddress === false && { t("Organisms.CreateRoom.room_address_already_in_use", {room_address: `#${addressValue}:${userHs}`})}} + {isValidAddress === false && { t('Organisms.CreateRoom.room_address_already_in_use', { room_address: `#${addressValue}:${userHs}` })}}
)} {!isSpace && joinRule !== 'public' && ( } - content={ {t("Organisms.CreateRoom.e2e_message")}} + content={( + + {' '} + {t('Organisms.CreateRoom.e2e_message')} + +)} /> )} )} content={( - {t("Organisms.CreateRoom.role_message")} + + {' '} + {t('Organisms.CreateRoom.role_message')} + )} /> - +
- +
)} {typeof creatingError === 'string' && {creatingError}} @@ -279,18 +285,20 @@ function CreateRoom() { const mx = initMatrix.matrixClient; const room = mx.getRoom(parentId); + const { t } = useTranslation(); + return ( - {parentId ? twemojify(room.name) : t("Organisms.CreateRoom.home")} + {parentId ? twemojify(room.name) : t('Organisms.CreateRoom.home')} - {` — ${isSpace ? t("Organisms.CreateRoom.create_space") : t("Organisms.CreateRoom.create_room")}`} + {` — ${isSpace ? t('Organisms.CreateRoom.create_space') : t('Organisms.CreateRoom.create_room')}`} )} - contentOptions={} + contentOptions={} onRequestClose={onRequestClose} > { diff --git a/src/app/organisms/drag-drop/DragDrop.jsx b/src/app/organisms/drag-drop/DragDrop.jsx index aae8c1c5..7e3df19b 100644 --- a/src/app/organisms/drag-drop/DragDrop.jsx +++ b/src/app/organisms/drag-drop/DragDrop.jsx @@ -2,14 +2,14 @@ import React from 'react'; import PropTypes from 'prop-types'; import './DragDrop.scss'; +import { useTranslation } from 'react-i18next'; + import RawModal from '../../atoms/modal/RawModal'; import Text from '../../atoms/text/Text'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function DragDrop({ isOpen }) { - const { t } = useTranslation(); return ( @@ -18,7 +18,7 @@ function DragDrop({ isOpen }) { overlayClassName="drag-drop__overlay" isOpen={isOpen} > - {t("Organisms.DragDrop.drop_file_to_upload_prompt")} + {t('Organisms.DragDrop.drop_file_to_upload_prompt')} ); } diff --git a/src/app/organisms/emoji-verification/EmojiVerification.jsx b/src/app/organisms/emoji-verification/EmojiVerification.jsx index 5fa6e080..d0613fa2 100644 --- a/src/app/organisms/emoji-verification/EmojiVerification.jsx +++ b/src/app/organisms/emoji-verification/EmojiVerification.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import './EmojiVerification.scss'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; @@ -20,9 +21,7 @@ import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; import { useStore } from '../../hooks/useStore'; import { accessSecretStorage } from '../settings/SecretStorageAccess'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; -import { t } from 'i18next'; +import '../../i18n'; function EmojiVerificationContent({ data, requestClose }) { const [sas, setSas] = useState(null); @@ -100,14 +99,14 @@ function EmojiVerificationContent({ data, requestClose }) { const renderWait = () => ( <> - {t("Organisms.EmojiVerification.waiting_for_response")} + {t('Organisms.EmojiVerification.waiting_for_response')} ); if (sas !== null) { return (
- {t("Organisms.EmojiVerification.confirmation_prompt")} + {t('Organisms.EmojiVerification.confirmation_prompt')}
{sas.sas.emoji.map((emoji, i) => ( // eslint-disable-next-line react/no-array-index-key @@ -120,8 +119,8 @@ function EmojiVerificationContent({ data, requestClose }) {
{process ? renderWait() : ( <> - - + + )}
@@ -132,7 +131,7 @@ function EmojiVerificationContent({ data, requestClose }) { if (targetDevice) { return (
- {t("Organisms.EmojiVerification.accept_request_from_other_device_message")} + {t('Organisms.EmojiVerification.accept_request_from_other_device_message')}
{renderWait()}
@@ -142,12 +141,12 @@ function EmojiVerificationContent({ data, requestClose }) { return (
- {t("Organisms.EmojiVerification.begin_verification_process_message")} + {t('Organisms.EmojiVerification.begin_verification_process_message')}
{ process ? renderWait() - : + : }
@@ -182,16 +181,18 @@ function useVisibilityToggle() { function EmojiVerification() { const [data, requestClose] = useVisibilityToggle(); + const { t } = useTranslation(); + return ( - {t("Organisms.EmojiVerification.title")} + {t('Organisms.EmojiVerification.title')} )} - contentOptions={} + contentOptions={} onRequestClose={requestClose} > { diff --git a/src/app/organisms/invite-list/InviteList.jsx b/src/app/organisms/invite-list/InviteList.jsx index e0e8553e..387b057f 100644 --- a/src/app/organisms/invite-list/InviteList.jsx +++ b/src/app/organisms/invite-list/InviteList.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import './InviteList.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import * as roomActions from '../../../client/action/room'; @@ -16,11 +17,7 @@ import RoomTile from '../../molecules/room-tile/RoomTile'; import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; -import { t } from 'i18next'; - - +import '../../i18n'; function InviteList({ isOpen, onRequestClose }) { const [procInvite, changeProcInvite] = useState(new Set()); @@ -81,8 +78,8 @@ function InviteList({ isOpen, onRequestClose }) { ? () : (
- - + +
) } @@ -93,14 +90,14 @@ function InviteList({ isOpen, onRequestClose }) { return ( } + title={t('Organisms.InviteList.title')} + contentOptions={} onRequestClose={onRequestClose} >
{ initMatrix.roomList.inviteDirects.size !== 0 && (
- {t("Organisms.InviteList.direct_messages_title")} + {t('Organisms.InviteList.direct_messages_title')}
)} { @@ -118,8 +115,8 @@ function InviteList({ isOpen, onRequestClose }) { ? () : (
- - + +
) } @@ -129,14 +126,14 @@ function InviteList({ isOpen, onRequestClose }) { } { initMatrix.roomList.inviteSpaces.size !== 0 && (
- {t("Organisms.InviteList.spaces_title")} + {t('Organisms.InviteList.spaces_title')}
)} { Array.from(initMatrix.roomList.inviteSpaces).map(renderRoomTile) } { initMatrix.roomList.inviteRooms.size !== 0 && (
- {t("Organisms.InviteList.rooms_title")} + {t('Organisms.InviteList.rooms_title')}
)} { Array.from(initMatrix.roomList.inviteRooms).map(renderRoomTile) } diff --git a/src/app/organisms/invite-user/InviteUser.jsx b/src/app/organisms/invite-user/InviteUser.jsx index db52b2ec..8e4965c1 100644 --- a/src/app/organisms/invite-user/InviteUser.jsx +++ b/src/app/organisms/invite-user/InviteUser.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect, useRef } from 'react'; import PropTypes from 'prop-types'; import './InviteUser.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import * as roomActions from '../../../client/action/room'; @@ -19,9 +20,7 @@ import RoomTile from '../../molecules/room-tile/RoomTile'; import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; import UserIC from '../../../../public/res/ic/outlined/user.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; - +import '../../i18n'; function InviteUser({ isOpen, roomId, searchTerm, onRequestClose, @@ -88,7 +87,7 @@ function InviteUser({ avatar_url: result.avatar_url, }]); } catch (e) { - updateSearchQuery({error: t("Organisms.InviteUser.user_not_found", {user_name: inputUsername})}); + updateSearchQuery({ error: t('Organisms.InviteUser.user_not_found', { user_name: inputUsername }) }); } } else { try { @@ -97,13 +96,13 @@ function InviteUser({ limit: 20, }); if (result.results.length === 0) { - updateSearchQuery({ error: t("Organisms.InviteUser.no_matches_found", {user_name: inputUsername})}); + updateSearchQuery({ error: t('Organisms.InviteUser.no_matches_found', { user_name: inputUsername }) }); updateIsSearching(false); return; } updateUsers(result.results); } catch (e) { - updateSearchQuery({ error: t("errors.generic")}); + updateSearchQuery({ error: t('errors.generic') }); } } updateIsSearching(false); @@ -112,9 +111,7 @@ function InviteUser({ async function hasDevices(userId) { try { const usersDeviceMap = await mx.downloadKeys([userId, mx.getUserId()]); - return Object.values(usersDeviceMap).every((userDevices) => - Object.keys(userDevices).length > 0, - ); + return Object.values(usersDeviceMap).every((userDevices) => Object.keys(userDevices).length > 0); } catch (e) { console.error("Error determining if it's possible to encrypt to all users: ", e); return false; @@ -141,7 +138,7 @@ function InviteUser({ } catch (e) { deleteUserFromProc(userId); if (typeof e.message === 'string') procUserError.set(userId, e.message); - else procUserError.set(userId, t("errors.generic")); + else procUserError.set(userId, t('errors.generic')); updateUserProcError(getMapCopy(procUserError)); } } @@ -161,7 +158,7 @@ function InviteUser({ } catch (e) { deleteUserFromProc(userId); if (typeof e.message === 'string') procUserError.set(userId, e.message); - else procUserError.set(userId, t("errors.generic")); + else procUserError.set(userId, t('errors.generic')); updateUserProcError(getMapCopy(procUserError)); } } @@ -179,7 +176,7 @@ function InviteUser({ return ; } if (invitedUserIds.has(userId)) { - return messageJSX(t("Organisms.InviteUser.invite_result.invited"), true); + return messageJSX(t('Organisms.InviteUser.invite_result.invited'), true); } if (typeof roomId === 'string') { const member = mx.getRoom(roomId).getMember(userId); @@ -187,18 +184,18 @@ function InviteUser({ const userMembership = member.membership; switch (userMembership) { case 'join': - return messageJSX(t("Organisms.InviteUser.invite_result.already_joined"), true); + return messageJSX(t('Organisms.InviteUser.invite_result.already_joined'), true); case 'invite': - return messageJSX(t("Organisms.InviteUser.invite_result.already_invited"), true); + return messageJSX(t('Organisms.InviteUser.invite_result.already_invited'), true); case 'ban': - return messageJSX(t("Organisms.InviteUser.invite_result.banned"), false); + return messageJSX(t('Organisms.InviteUser.invite_result.banned'), false); default: } } } return (typeof roomId === 'string') - ? - : ; + ? + : ; }; const renderError = (userId) => { if (!procUserError.has(userId)) return null; @@ -245,27 +242,27 @@ function InviteUser({ return ( } + title={(typeof roomId === 'string' ? t('Organisms.InviteUser.invite_to_room', { room: mx.getRoom(roomId).name }) : t('Organisms.InviteUser.invite_to_dm'))} + contentOptions={} onRequestClose={onRequestClose} >
{ e.preventDefault(); searchUser(usernameRef.current.value); }}> - - + +
{ typeof searchQuery.username !== 'undefined' && isSearching && (
- {t("Organisms.InviteUser.searching_for_user", {user_name: searchQuery.username})} + {t('Organisms.InviteUser.searching_for_user', { user_name: searchQuery.username })}
) } { typeof searchQuery.username !== 'undefined' && !isSearching && ( - {t("Organisms.InviteUser.search_result_title", {user_name: searchQuery.username})} + {t('Organisms.InviteUser.search_result_title', { user_name: searchQuery.username })} ) } { diff --git a/src/app/organisms/join-alias/JoinAlias.jsx b/src/app/organisms/join-alias/JoinAlias.jsx index 7089d8bd..609cec1f 100644 --- a/src/app/organisms/join-alias/JoinAlias.jsx +++ b/src/app/organisms/join-alias/JoinAlias.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import './JoinAlias.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import navigation from '../../../client/state/navigation'; @@ -19,10 +20,7 @@ import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; import { useStore } from '../../hooks/useStore'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; -import { t } from 'i18next'; - +import '../../i18n'; const ALIAS_OR_ID_REG = /^[#|!].+:.+\..+$/; @@ -61,10 +59,10 @@ function JoinAliasContent({ term, requestClose }) { const alias = e.target.alias.value; if (alias?.trim() === '') return; if (alias.match(ALIAS_OR_ID_REG) === null) { - setError(t("Organisms.JoinAlias.invalid_address")); + setError(t('Organisms.JoinAlias.invalid_address')); return; } - setProcess(t("Organisms.JoinAlias.looking_for_address")); + setProcess(t('Organisms.JoinAlias.looking_for_address')); setError(undefined); let via; if (alias.startsWith('#')) { @@ -72,12 +70,12 @@ function JoinAliasContent({ term, requestClose }) { const aliasData = await mx.resolveRoomAlias(alias); via = aliasData?.servers.slice(0, 3) || []; if (mountStore.getItem()) { - setProcess(t("Organisms.JoinAlias.joining_alias", {alias_name: alias})); + setProcess(t('Organisms.JoinAlias.joining_alias', { alias_name: alias })); } } catch (err) { if (!mountStore.getItem()) return; setProcess(false); - setError(t("Organisms.JoinAlias.couldnt_find_room_or_space_alias", {alias_name: alias})); + setError(t('Organisms.JoinAlias.couldnt_find_room_or_space_alias', { alias_name: alias })); } } try { @@ -88,14 +86,14 @@ function JoinAliasContent({ term, requestClose }) { } catch { if (!mountStore.getItem()) return; setProcess(false); - setError(t("Organisms.JoinAlias.couldnt_find_room_or_space", {alias_name: alias})); + setError(t('Organisms.JoinAlias.couldnt_find_room_or_space', { alias_name: alias })); } }; return (
{process} ) - : + : }
@@ -145,13 +143,15 @@ function useWindowToggle() { function JoinAlias() { const [data, requestClose] = useWindowToggle(); + const { t } = useTranslation(); + return ( {t("Organisms.JoinAlias.title")} + {t('Organisms.JoinAlias.title')} )} - contentOptions={} + contentOptions={} onRequestClose={requestClose} > { data ? :
} diff --git a/src/app/organisms/navigation/DrawerBreadcrumb.jsx b/src/app/organisms/navigation/DrawerBreadcrumb.jsx index 69375bec..8d45ddb8 100644 --- a/src/app/organisms/navigation/DrawerBreadcrumb.jsx +++ b/src/app/organisms/navigation/DrawerBreadcrumb.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect, useRef } from 'react'; import PropTypes from 'prop-types'; import './DrawerBreadcrumb.scss'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; @@ -18,10 +19,7 @@ import NotificationBadge from '../../atoms/badge/NotificationBadge'; import ChevronRightIC from '../../../../public/res/ic/outlined/chevron-right.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; -import { t } from 'i18next'; - +import '../../i18n'; function DrawerBreadcrumb({ spaceId }) { const [, forceUpdate] = useState({}); @@ -116,7 +114,7 @@ function DrawerBreadcrumb({ spaceId }) { className={index === spacePath.length - 1 ? 'drawer-breadcrumb__btn--selected' : ''} onClick={() => selectSpace(id)} > - {id === cons.tabs.HOME ? t("Organisms.DrawerBreadcrumb.home") : twemojify(mx.getRoom(id).name)} + {id === cons.tabs.HOME ? t('Organisms.DrawerBreadcrumb.home') : twemojify(mx.getRoom(id).name)} { noti !== null && ( - {t("Organisms.DrawerHeader.add_rooms_or_spaces")} + {t('Organisms.DrawerHeader.add_rooms_or_spaces')} { afterOptionSelect(); openCreateRoom(true, spaceId); }} disabled={!canManage} > - {t("Organisms.DrawerHeader.create_new_space")} + {t('Organisms.DrawerHeader.create_new_space')} { afterOptionSelect(); openCreateRoom(false, spaceId); }} disabled={!canManage} > - {t("Organisms.DrawerHeader.create_new_room")} + {t('Organisms.DrawerHeader.create_new_room')} { !spaceId && ( { afterOptionSelect(); openPublicRooms(); }} > - {t("Organisms.DrawerHeader.join_public_room")} + {t('Organisms.DrawerHeader.join_public_room')} )} { !spaceId && ( @@ -72,7 +70,7 @@ export function HomeSpaceOptions({ spaceId, afterOptionSelect }) { iconSrc={PlusIC} onClick={() => { afterOptionSelect(); openJoinAlias(); }} > - {t("Organisms.DrawerHeader.join_with_address")} + {t('Organisms.DrawerHeader.join_with_address')} )} { spaceId && ( @@ -81,7 +79,7 @@ export function HomeSpaceOptions({ spaceId, afterOptionSelect }) { onClick={() => { afterOptionSelect(); openSpaceAddExisting(spaceId); }} disabled={!canManage} > - {t("Organisms.DrawerHeader.add_existing")} + {t('Organisms.DrawerHeader.add_existing')} )} { spaceId && ( @@ -89,7 +87,7 @@ export function HomeSpaceOptions({ spaceId, afterOptionSelect }) { onClick={() => { afterOptionSelect(); openSpaceManage(spaceId); }} iconSrc={HashSearchIC} > - {t("Organisms.DrawerHeader.manage_rooms")} + {t('Organisms.DrawerHeader.manage_rooms')} )} @@ -105,7 +103,8 @@ HomeSpaceOptions.propTypes = { function DrawerHeader({ selectedTab, spaceId }) { const mx = initMatrix.matrixClient; - const tabName = selectedTab !== cons.tabs.DIRECTS ? t("Organisms.DrawerHeader.home") : t("Organisms.DrawerHeader.direct_messages"); + const { t } = useTranslation(); + const tabName = selectedTab !== cons.tabs.DIRECTS ? t('Organisms.DrawerHeader.home') : t('Organisms.DrawerHeader.direct_messages'); const isDMTab = selectedTab === cons.tabs.DIRECTS; const room = mx.getRoom(spaceId); @@ -149,8 +148,8 @@ function DrawerHeader({ selectedTab, spaceId }) { )} - { isDMTab && openInviteUser()} tooltip={t("Organisms.DrawerHeader.start_dm_tooltip")} src={PlusIC} size="small" /> } - { !isDMTab && } + { isDMTab && openInviteUser()} tooltip={t('Organisms.DrawerHeader.start_dm_tooltip')} src={PlusIC} size="small" /> } + { !isDMTab && } ); } diff --git a/src/app/organisms/navigation/Selector.jsx b/src/app/organisms/navigation/Selector.jsx index 37ebc077..54f03f47 100644 --- a/src/app/organisms/navigation/Selector.jsx +++ b/src/app/organisms/navigation/Selector.jsx @@ -2,6 +2,7 @@ import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import navigation from '../../../client/state/navigation'; @@ -18,8 +19,7 @@ import VerticalMenuIC from '../../../../public/res/ic/outlined/vertical-menu.svg import { useForceUpdate } from '../../hooks/useForceUpdate'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function Selector({ roomId, isDM, drawerPostie, onClick, @@ -74,7 +74,7 @@ function Selector({ options={( isCrossVerified(device.device_id) === false); @@ -107,7 +105,7 @@ function CrossSigninAlert() { return ( openSettings(settingTabText.SECURITY)} avatar={} /> @@ -117,6 +115,7 @@ function CrossSigninAlert() { function FeaturedTab() { const { roomList, accountData, notifications } = initMatrix; const [selectedTab] = useSelectedTab(); + const { t } = useTranslation(); useNotificationUpdate(); function getHomeNoti() { @@ -155,7 +154,7 @@ function FeaturedTab() { return ( <> selectTab(cons.tabs.HOME)} avatar={} @@ -167,7 +166,7 @@ function FeaturedTab() { ) : null} /> selectTab(cons.tabs.DIRECTS)} avatar={} @@ -350,6 +349,7 @@ function useTotalInvites() { function SideBar() { const [totalInvites] = useTotalInvites(); + const { t } = useTranslation(); return (
@@ -363,7 +363,7 @@ function SideBar() {
openShortcutSpaces()} avatar={} /> @@ -375,13 +375,13 @@ function SideBar() {
openSearch()} avatar={} /> { totalInvites !== 0 && ( openInviteList()} avatar={} notificationBadge={} diff --git a/src/app/organisms/profile-editor/ProfileEditor.jsx b/src/app/organisms/profile-editor/ProfileEditor.jsx index c45f0699..0a1ce051 100644 --- a/src/app/organisms/profile-editor/ProfileEditor.jsx +++ b/src/app/organisms/profile-editor/ProfileEditor.jsx @@ -1,5 +1,6 @@ import React, { useState, useEffect, useRef } from 'react'; import PropTypes from 'prop-types'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; @@ -16,10 +17,7 @@ import { confirmDialog } from '../../molecules/confirm-dialog/ConfirmDialog'; import './ProfileEditor.scss'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; -import { t } from 'i18next'; - +import '../../i18n'; // TODO Fix bug that prevents 'Save' button from enabling up until second changed. function ProfileEditor({ userId }) { @@ -49,9 +47,9 @@ function ProfileEditor({ userId }) { const handleAvatarUpload = async (url) => { if (url === null) { const isConfirmed = await confirmDialog( - t("Organisms.ProfileEditor.remove_avatar"), - t("Organisms.ProfileViewer.remove_avatar_confirmation"), - t("common.remove"), + t('Organisms.ProfileEditor.remove_avatar'), + t('Organisms.ProfileViewer.remove_avatar_confirmation'), + t('common.remove'), 'caution', ); if (isConfirmed) { @@ -90,13 +88,13 @@ function ProfileEditor({ userId }) { onSubmit={(e) => { e.preventDefault(); saveDisplayName(); }} > - - + + ); @@ -107,7 +105,7 @@ function ProfileEditor({ userId }) { setIsEditing(true)} />
diff --git a/src/app/organisms/profile-viewer/ProfileViewer.jsx b/src/app/organisms/profile-viewer/ProfileViewer.jsx index 11502d45..7e3debac 100644 --- a/src/app/organisms/profile-viewer/ProfileViewer.jsx +++ b/src/app/organisms/profile-viewer/ProfileViewer.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect, useRef } from 'react'; import PropTypes from 'prop-types'; import './ProfileViewer.scss'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; @@ -11,7 +12,7 @@ import { selectRoom, openReusableContextMenu } from '../../../client/action/navi import * as roomActions from '../../../client/action/room'; import { - getUsername, getUsernameOfRoomMember, getPowerLabel, hasDMWith + getUsername, getUsernameOfRoomMember, getPowerLabel, hasDMWith, } from '../../../util/matrixUtil'; import { getEventCords } from '../../../util/common'; import colorMXID from '../../../util/colorMXID'; @@ -34,14 +35,11 @@ import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; import { useForceUpdate } from '../../hooks/useForceUpdate'; import { confirmDialog } from '../../molecules/confirm-dialog/ConfirmDialog'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; -import { t } from 'i18next'; +import '../../i18n'; function ModerationTools({ roomId, userId, }) { - const { t } = useTranslation(); const mx = initMatrix.matrixClient; @@ -77,14 +75,14 @@ function ModerationTools({
{canIKick && (
- - + +
)} {canIBan && (
- - + +
)}
@@ -127,8 +125,8 @@ function SessionInfo({ userId }) { if (!isVisible) return null; return (
- {devices === null && {t("Organisms.ProfileViewer.loading_sessions")}} - {devices?.length === 0 && {t("Organisms.ProfileViewer.no_sessions_found")}} + {devices === null && {t('Organisms.ProfileViewer.loading_sessions')}} + {devices?.length === 0 && {t('Organisms.ProfileViewer.no_sessions_found')}} {devices !== null && (devices.map((device) => ( setIsVisible(!isVisible)} iconSrc={isVisible ? ChevronBottomIC : ChevronRightIC} > - {t("Organisms.ProfileViewer.view_sessions", {count: devices?.length})} + {t('Organisms.ProfileViewer.view_sessions', { count: devices?.length })} {renderSessionChips()}
@@ -161,6 +159,7 @@ function ProfileFooter({ roomId, userId, onRequestClose }) { const [isCreatingDM, setIsCreatingDM] = useState(false); const [isIgnoring, setIsIgnoring] = useState(false); const [isUserIgnored, setIsUserIgnored] = useState(initMatrix.matrixClient.isUserIgnored(userId)); + const { t } = useTranslation(); const isMountedRef = useRef(true); const mx = initMatrix.matrixClient; @@ -261,7 +260,7 @@ function ProfileFooter({ roomId, userId, onRequestClose }) { onClick={openDM} disabled={isCreatingDM} > - {isCreatingDM ? t("Organisms.ProfileViewer.creating_dm_room") : t("Organisms.ProfileViewer.send_direct_message_button")} + {isCreatingDM ? t('Organisms.ProfileViewer.creating_dm_room') : t('Organisms.ProfileViewer.send_direct_message_button')} { isBanned && canIKick && ( )} @@ -290,8 +289,8 @@ function ProfileFooter({ roomId, userId, onRequestClose }) { > { isUserIgnored - ? `${isIgnoring ? t("Organisms.ProfileViewer.unignoring") : t("Organisms.ProfileViewer.unignore")}` - : `${isIgnoring ? t("Organisms.ProfileViewer.ignoring") : t("Organisms.ProfileViewer.ignore")}` + ? `${isIgnoring ? t('Organisms.ProfileViewer.unignoring') : t('Organisms.ProfileViewer.unignore')}` + : `${isIgnoring ? t('Organisms.ProfileViewer.ignoring') : t('Organisms.ProfileViewer.ignore')}` }
@@ -355,6 +354,7 @@ function ProfileViewer() { const [isOpen, roomId, userId, closeDialog, handleAfterClose] = useToggleDialog(); useRerenderOnProfileChange(roomId, userId); + const { t } = useTranslation(); const mx = initMatrix.matrixClient; const room = mx.getRoom(roomId); @@ -374,16 +374,16 @@ function ProfileViewer() { const handleChangePowerLevel = async (newPowerLevel) => { if (newPowerLevel === powerLevel) return; - const SHARED_POWER_MSG = t("Organisms.ProfileViewer.shared_power_message"); - const DEMOTING_MYSELF_MSG = t("Organisms.ProfileViewer.demoting_self_message"); + const SHARED_POWER_MSG = t('Organisms.ProfileViewer.shared_power_message'); + const DEMOTING_MYSELF_MSG = t('Organisms.ProfileViewer.demoting_self_message'); const isSharedPower = newPowerLevel === myPowerLevel; const isDemotingMyself = userId === mx.getUserId(); if (isSharedPower || isDemotingMyself) { const isConfirmed = await confirmDialog( - t("Organisms.ProfileViewer.change_power_level"), + t('Organisms.ProfileViewer.change_power_level'), isSharedPower ? SHARED_POWER_MSG : DEMOTING_MYSELF_MSG, - t("common.change"), + t('common.change'), 'caution', ); if (!isConfirmed) return; @@ -444,7 +444,7 @@ function ProfileViewer() { title={room?.name ?? ''} onAfterClose={handleAfterClose} onRequestClose={closeDialog} - contentOptions={} + contentOptions={} > {roomId ? renderProfile() :
}
diff --git a/src/app/organisms/public-rooms/PublicRooms.jsx b/src/app/organisms/public-rooms/PublicRooms.jsx index 19df1cea..362c24a0 100644 --- a/src/app/organisms/public-rooms/PublicRooms.jsx +++ b/src/app/organisms/public-rooms/PublicRooms.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect, useRef } from 'react'; import PropTypes from 'prop-types'; import './PublicRooms.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import { selectRoom, selectTab } from '../../../client/action/navigation'; @@ -18,9 +19,7 @@ import RoomTile from '../../molecules/room-tile/RoomTile'; import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; import HashSearchIC from '../../../../public/res/ic/outlined/hash-search.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; - +import '../../i18n'; const SEARCH_LIMIT = 20; @@ -59,7 +58,7 @@ function TryJoinWithAlias({ alias, onRequestClose }) { } catch (e) { setStatus({ isJoining: false, - error: t("Organisms.PublicRooms.could_not_join_alias", {alias: alias}), + error: t('Organisms.PublicRooms.could_not_join_alias', { alias }), roomId: null, tempRoomId: null, }); @@ -69,16 +68,16 @@ function TryJoinWithAlias({ alias, onRequestClose }) { return (
{status.roomId === null && !status.isJoining && status.error === null && ( - + )} {status.isJoining && ( <> - {t("Organisms.PublicRooms.joining_alias", {alias: alias})} + {t('Organisms.PublicRooms.joining_alias', { alias })} )} {status.roomId !== null && ( - + )} {status.error !== null && {status.error}}
@@ -147,14 +146,14 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { if (totalRooms.length === 0) { updateSearchQuery({ error: inputRoomName === '' - ? t("Organisms.PublicRooms.no_public_rooms", {homeserver: inputHs}) - : t("Organisms.PublicRooms.no_result_found", {homeserver: inputHs, input: inputRoomName}), + ? t('Organisms.PublicRooms.no_public_rooms', { homeserver: inputHs }) + : t('Organisms.PublicRooms.no_result_found', { homeserver: inputHs, input: inputRoomName }), alias: isInputAlias ? inputRoomName : null, }); } } catch (e) { updatePublicRooms([]); - let err = t("errors.generic"); + let err = t('errors.generic'); if (e?.httpStatus >= 400 && e?.httpStatus < 500) { err = e.message; } @@ -213,8 +212,8 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { desc={typeof room.topic === 'string' ? room.topic : null} options={( <> - {isJoined && } - {!isJoined && (joiningRooms.has(room.room_id) ? : )} + {isJoined && } + {!isJoined && (joiningRooms.has(room.room_id) ? : )} )} /> @@ -225,17 +224,17 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { return ( } + title={t('Organisms.PublicRooms.title')} + contentOptions={} onRequestClose={onRequestClose} >
{ e.preventDefault(); searchRooms(); }}>
- - + +
- +
{ @@ -244,13 +243,13 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { ? (
- {t("Organisms.PublicRooms.loading", {homeserver: searchQuery.homeserver})} + {t('Organisms.PublicRooms.loading', { homeserver: searchQuery.homeserver })}
) : (
- {t("Organisms.PublicRooms.searching", {homeserver: searchQuery.homeserver, query: searchQuery.name})} + {t('Organisms.PublicRooms.searching', { homeserver: searchQuery.homeserver, query: searchQuery.name })}
) ) @@ -258,8 +257,8 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { { typeof searchQuery.name !== 'undefined' && !isSearching && ( searchQuery.name === '' - ? {t("Organisms.PublicRooms.result_title", {homeserver: searchQuery.homeserver})} - : {t("Organisms.PublicRooms.search_result_title", {homeserver: searchQuery.homeserver, query: searchQuery.name})} + ? {t('Organisms.PublicRooms.result_title', { homeserver: searchQuery.homeserver })} + : {t('Organisms.PublicRooms.search_result_title', { homeserver: searchQuery.homeserver, query: searchQuery.name })} ) } { searchQuery.error && ( @@ -279,7 +278,7 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { { publicRooms.length !== 0 && publicRooms.length % SEARCH_LIMIT === 0 && (
{ isViewMore !== true && ( - + )} { isViewMore && }
diff --git a/src/app/organisms/room/PeopleDrawer.jsx b/src/app/organisms/room/PeopleDrawer.jsx index 10e0d5e8..a8476a3f 100644 --- a/src/app/organisms/room/PeopleDrawer.jsx +++ b/src/app/organisms/room/PeopleDrawer.jsx @@ -4,6 +4,7 @@ import React, { import PropTypes from 'prop-types'; import './PeopleDrawer.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import { getPowerLabel, getUsernameOfRoomMember } from '../../../util/matrixUtil'; import colorMXID from '../../../util/colorMXID'; @@ -25,8 +26,7 @@ import AddUserIC from '../../../../public/res/ic/outlined/add-user.svg'; import SearchIC from '../../../../public/res/ic/outlined/search.svg'; import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function simplyfiMembers(members) { const mx = initMatrix.matrixClient; @@ -134,11 +134,11 @@ function PeopleDrawer({ roomId }) {
- {t("Organisms.PeopleDrawer.title")} - {t("Organisms.PeopleDrawer.members", {count: room.getJoinedMemberCount()})} + {t('Organisms.PeopleDrawer.title')} + {t('Organisms.PeopleDrawer.members', { count: room.getJoinedMemberCount() })} - openInviteUser(roomId)} tooltip={t("Organisms.PeopleDrawer.invite_tooltip")} src={AddUserIC} disabled={!canInvite} /> + openInviteUser(roomId)} tooltip={t('Organisms.PeopleDrawer.invite_tooltip')} src={AddUserIC} disabled={!canInvite} />
@@ -155,7 +155,7 @@ function PeopleDrawer({ roomId }) { return getSegmentIndex[membership]; })() } - segments={[{ text: t("Organisms.PeopleDrawer.joined")}, { text: t("Organisms.PeopleDrawer.invited") }, { text: t("Organisms.PeopleDrawer.banned") }]} + segments={[{ text: t('Organisms.PeopleDrawer.joined') }, { text: t('Organisms.PeopleDrawer.invited') }, { text: t('Organisms.PeopleDrawer.banned') }]} onSelect={(index) => { const selectSegment = [ () => setMembership('join'), @@ -181,7 +181,7 @@ function PeopleDrawer({ roomId }) { (searchedMembers?.data.length === 0 || memberList.length === 0) && (
- {t("Organisms.PeopleDrawer.search_no_results")} + {t('Organisms.PeopleDrawer.search_no_results')}
) } @@ -191,7 +191,7 @@ function PeopleDrawer({ roomId }) { && memberList.length > itemCount && searchedMembers === null && ( - + ) }
@@ -201,7 +201,7 @@ function PeopleDrawer({ roomId }) {
e.preventDefault()} className="people-search"> - + { searchedMembers !== null && diff --git a/src/app/organisms/room/RoomSettings.jsx b/src/app/organisms/room/RoomSettings.jsx index 3504aa8e..4fb02d03 100644 --- a/src/app/organisms/room/RoomSettings.jsx +++ b/src/app/organisms/room/RoomSettings.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import './RoomSettings.scss'; +import { useTranslation } from 'react-i18next'; import { blurOnBubbling } from '../../atoms/button/script'; import initMatrix from '../../../client/initMatrix'; @@ -38,9 +39,7 @@ import ChevronTopIC from '../../../../public/res/ic/outlined/chevron-top.svg'; import { useForceUpdate } from '../../hooks/useForceUpdate'; import { confirmDialog } from '../../molecules/confirm-dialog/ConfirmDialog'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; -import { t } from 'i18next'; +import '../../i18n'; const tabText = { GENERAL: 'General', @@ -94,9 +93,9 @@ function GeneralSettings({ roomId }) { variant="danger" onClick={async () => { const isConfirmed = await confirmDialog( - t("Organisms.RoomSettings.leave_room"), - t("Organisms.RoomSettings.leave_room_confirm_message", {room_name: room.name}), - t("Organisms.RoomSettings.leave_room_confirm_button"), + t('Organisms.RoomSettings.leave_room'), + t('Organisms.RoomSettings.leave_room_confirm_message', { room_name: room.name }), + t('Organisms.RoomSettings.leave_room_confirm_button'), 'danger', ); if (!isConfirmed) return; @@ -108,15 +107,15 @@ function GeneralSettings({ roomId }) {
- {t("Organisms.RoomSettings.notification_header")} + {t('Organisms.RoomSettings.notification_header')}
- {t("Organisms.RoomSettings.visibility_header")} + {t('Organisms.RoomSettings.visibility_header')}
- {t("Organisms.RoomSettings.address_header")} + {t('Organisms.RoomSettings.address_header')}
@@ -128,14 +127,15 @@ GeneralSettings.propTypes = { }; function SecuritySettings({ roomId }) { + const { t } = useTranslation(); return ( <>
- {t("Organisms.RoomSettings.encryption_header")} + {t('Organisms.RoomSettings.encryption_header')}
- {t("Organisms.RoomSettings.message_history_header")} + {t('Organisms.RoomSettings.message_history_header')}
@@ -149,6 +149,7 @@ function RoomSettings({ roomId }) { const [, forceUpdate] = useForceUpdate(); const [selectedTab, setSelectedTab] = useState(tabItems[0]); const room = initMatrix.matrixClient.getRoom(roomId); + const { t } = useTranslation(); const handleTabChange = (tabItem) => { setSelectedTab(tabItem); @@ -187,7 +188,12 @@ function RoomSettings({ roomId }) { {`${room.name}`} - — {t("Organisms.RoomSettings.room_settings_subtitle")} + + {' '} + — + {' '} + {t('Organisms.RoomSettings.room_settings_subtitle')} + diff --git a/src/app/organisms/room/RoomViewContent.jsx b/src/app/organisms/room/RoomViewContent.jsx index c856e56e..507c0448 100644 --- a/src/app/organisms/room/RoomViewContent.jsx +++ b/src/app/organisms/room/RoomViewContent.jsx @@ -8,6 +8,7 @@ import PropTypes from 'prop-types'; import './RoomViewContent.scss'; import dateFormat from 'dateformat'; +import { useTranslation, Trans } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; @@ -29,9 +30,7 @@ import { parseTimelineChange } from './common'; import TimelineScroll from './TimelineScroll'; import EventLimit from './EventLimit'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; -import { Trans } from 'react-i18next'; +import '../../i18n'; const PAG_LIMIT = 30; const MAX_MSG_DIFF_MINUTES = 5; @@ -68,30 +67,30 @@ function RoomIntroContainer({ event, timeline }) { let avatarSrc = room.getAvatarUrl(mx.baseUrl, 80, 80, 'crop'); avatarSrc = isDM ? room.getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 80, 80, 'crop') : avatarSrc; - const heading = isDM ? room.name : t("Organisms.RoomViewContent.welcome_to_room", {room_name: room.name}); + const heading = isDM ? room.name : t('Organisms.RoomViewContent.welcome_to_room', { room_name: room.name }); const topic = twemojify(roomTopic || '', undefined, true); const nameJsx = twemojify(room.name); const desc = isDM ? ( <> - }} + }} /> - {topic == "" ? "" : " - "} + {topic == '' ? '' : ' - '} {topic } ) : ( <> - }} - /> + }} + /> - {topic == "" ? "" : " - "} + {topic == '' ? '' : ' - '} {topic} ); @@ -112,7 +111,14 @@ function RoomIntroContainer({ event, timeline }) { name={room.name} heading={twemojify(heading)} desc={desc} - time={event ? t("Organisms.RoomViewContent.created_on", {date: event.getDate(), formatParams: { date: { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'}}}) : null} + time={event ? t('Organisms.RoomViewContent.created_on', { + date: event.getDate(), + formatParams: { + date: { + weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', + }, + }, + }) : null} /> ); } @@ -539,7 +545,7 @@ function RoomViewContent({ eventId, roomTimeline }) { && readUptoEvent.getTs() < mEvent.getTs()); if (unreadDivider) { isNewEvent = true; - tl.push(); + tl.push(); itemCountIndex += 1; if (jumpToItemIndex === -1) jumpToItemIndex = itemCountIndex; } diff --git a/src/app/organisms/room/RoomViewFloating.jsx b/src/app/organisms/room/RoomViewFloating.jsx index b6d6ebaa..4adec02d 100644 --- a/src/app/organisms/room/RoomViewFloating.jsx +++ b/src/app/organisms/room/RoomViewFloating.jsx @@ -3,6 +3,7 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import './RoomViewFloating.scss'; +import { useTranslation, Trans } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; @@ -18,11 +19,7 @@ import TickMarkIC from '../../../../public/res/ic/outlined/tick-mark.svg'; import { getUsername, getUsernameOfRoomMember } from '../../../util/matrixUtil'; -import { getUsersActionJsx } from './common'; - -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; -import { Trans } from 'react-i18next'; +import '../../i18n'; function useJumpToEvent(roomTimeline) { const [eventId, setEventId] = useState(null); @@ -94,14 +91,13 @@ function useScrollToBottom(roomTimeline) { function RoomViewFloating({ roomId, roomTimeline, }) { - const { t } = useTranslation(); const [isJumpToEvent, jumpToEvent, cancelJumpToEvent] = useJumpToEvent(roomTimeline); const [typingMembers] = useTypingMembers(roomTimeline); const [isAtBottom, setIsAtBottom] = useScrollToBottom(roomTimeline); - const room = initMatrix.matrixClient.getRoom(roomId) + const room = initMatrix.matrixClient.getRoom(roomId); const getUserDisplayName = (userId) => { if (room?.getMember(userId)) return getUsernameOfRoomMember(room.getMember(userId)); @@ -113,41 +109,41 @@ function RoomViewFloating({ setIsAtBottom(true); }; - console.log(typingMembers) + console.log(typingMembers); - let typingMemberValues = [...typingMembers]; + const typingMemberValues = [...typingMembers]; - console.log(typingMemberValues) + console.log(typingMemberValues); return ( <>
0 ? ' room-view__typing--open' : ''}`}>
- - + }} - /> + components={{ bold: }} + />
diff --git a/src/app/organisms/room/RoomViewHeader.jsx b/src/app/organisms/room/RoomViewHeader.jsx index 951f1bb2..7dd68429 100644 --- a/src/app/organisms/room/RoomViewHeader.jsx +++ b/src/app/organisms/room/RoomViewHeader.jsx @@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react'; import PropTypes from 'prop-types'; import './RoomViewHeader.scss'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import { blurOnBubbling } from '../../atoms/button/script'; @@ -29,8 +30,7 @@ import BackArrowIC from '../../../../public/res/ic/outlined/chevron-left.svg'; import { useForceUpdate } from '../../hooks/useForceUpdate'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function RoomViewHeader({ roomId }) { const [, forceUpdate] = useForceUpdate(); @@ -98,12 +98,12 @@ function RoomViewHeader({ roomId }) { - toggleRoomSettings(tabText.SEARCH)} tooltip={t("Organisms.RoomViewHeader.search_tooltip")} src={SearchIC} /> - - toggleRoomSettings(tabText.MEMBERS)} tooltip={t("Organisms.RoomViewHeader.members_tooltip")} src={UserIC} /> + toggleRoomSettings(tabText.SEARCH)} tooltip={t('Organisms.RoomViewHeader.search_tooltip')} src={SearchIC} /> + + toggleRoomSettings(tabText.MEMBERS)} tooltip={t('Organisms.RoomViewHeader.members_tooltip')} src={UserIC} /> diff --git a/src/app/organisms/room/RoomViewInput.jsx b/src/app/organisms/room/RoomViewInput.jsx index 8d6a6896..f19bdef7 100644 --- a/src/app/organisms/room/RoomViewInput.jsx +++ b/src/app/organisms/room/RoomViewInput.jsx @@ -5,6 +5,7 @@ import './RoomViewInput.scss'; import TextareaAutosize from 'react-autosize-textarea'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import settings from '../../../client/state/settings'; @@ -30,8 +31,7 @@ import MarkdownIC from '../../../../public/res/ic/outlined/markdown.svg'; import FileIC from '../../../../public/res/ic/outlined/file.svg'; import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; const CMD_REGEX = /(^\/|:|@)(\S*)$/; let isTyping = false; @@ -86,7 +86,7 @@ function RoomViewInput({ function uploadingProgress(myRoomId, { loaded, total }) { if (myRoomId !== roomId) return; const progressPer = Math.round((loaded * 100) / total); - uploadProgressRef.current.textContent = t("Organisms.RoomViewInput.upload_progress", {progress: bytesToSize(loaded), total:bytesToSize(total), percent: progressPer}); + uploadProgressRef.current.textContent = t('Organisms.RoomViewInput.upload_progress', { progress: bytesToSize(loaded), total: bytesToSize(total), percent: progressPer }); inputBaseRef.current.style.backgroundImage = `linear-gradient(90deg, var(--bg-surface-hover) ${progressPer}%, var(--bg-surface-low) ${progressPer}%)`; } function clearAttachment(myRoomId) { @@ -133,9 +133,7 @@ function RoomViewInput({ } function firedCmd(cmdData) { const msg = textAreaRef.current.value; - textAreaRef.current.value = replaceCmdWith( - msg, cmdCursorPos, typeof cmdData?.replace !== 'undefined' ? cmdData.replace : '', - ); + textAreaRef.current.value = replaceCmdWith(msg, cmdCursorPos, typeof cmdData?.replace !== 'undefined' ? cmdData.replace : ''); deactivateCmd(); } @@ -316,8 +314,8 @@ function RoomViewInput({ { tombstoneEvent - ? tombstoneEvent.getContent()?.body ?? t("Organisms.RoomViewInput.tombstone_replaced") - : t("Organisms.RoomViewInput.tombstone_permission_denied") + ? tombstoneEvent.getContent()?.body ?? t('Organisms.RoomViewInput.tombstone_replaced') + : t('Organisms.RoomViewInput.tombstone_permission_denied') } ); @@ -338,7 +336,7 @@ function RoomViewInput({ onChange={handleMsgTyping} onPaste={handlePaste} onKeyDown={handleKeyDown} - placeholder={t("Organisms.RoomViewInput.send_message_placeholder")} + placeholder={t('Organisms.RoomViewInput.send_message_placeholder')} /> @@ -352,10 +350,10 @@ function RoomViewInput({ cords.y -= 250; openEmojiBoard(cords, addEmoji); }} - tooltip={t("Organisms.RoomViewInput.emoji_tooltip")} + tooltip={t('Organisms.RoomViewInput.emoji_tooltip')} src={EmojiIC} /> - +
); @@ -373,7 +371,7 @@ function RoomViewInput({
{attachment.name} - {t("Organisms.RoomViewInput.file_size", {size: bytesToSize(attachment.size)})} + {t('Organisms.RoomViewInput.file_size', { size: bytesToSize(attachment.size) })}
); @@ -388,7 +386,7 @@ function RoomViewInput({ setReplyTo(null); }} src={CrossIC} - tooltip={t("Organisms.RoomViewInput.cancel_reply_tooltip")} + tooltip={t('Organisms.RoomViewInput.cancel_reply_tooltip')} size="extra-small" /> }} + i18nKey="Organisms.RoomCommon.user_joined" + values={{ user_name: twemojify(user) }} + components={{ bold: }} /> - ); }, leave(user, reason) { const reasonMsg = (typeof reason === 'string') ? `: ${reason}` : ''; return ( - <> }} + i18nKey="Organisms.RoomCommon.user_left" + values={{ user_name: twemojify(user) }} + components={{ bold: }} /> - ); }, invite(inviter, user) { return ( - <> }} + i18nKey="Organisms.RoomCommon.user_invited" + values={{ user_name: twemojify(user), inviter_name: twemojify(inviter) }} + components={{ bold: }} /> - ); }, cancelInvite(inviter, user) { return ( - <> }} + i18nKey="Organisms.RoomCommon.invite_cancelled" + values={{ user_name: twemojify(user), inviter_name: twemojify(inviter) }} + components={{ bold: }} /> - ); }, rejectInvite(user) { return ( - <> }} + i18nKey="Organisms.RoomCommon.invite_rejected" + values={{ user_name: twemojify(user) }} + components={{ bold: }} /> - ); }, kick(actor, user, reason) { const reasonMsg = (typeof reason === 'string') ? `${reason}` : ''; return ( - <> }} + i18nKey="Organisms.RoomCommon.user_kicked" + values={{ + user_name: twemojify(user), + actor: twemojify(actor), + reason: twemojify(reasonMsg), + }} + components={{ bold: }} /> - ); }, ban(actor, user, reason) { const reasonMsg = (typeof reason === 'string') ? `${reason}` : ''; return ( - <> - }} - /> - + }} + /> ); }, unban(actor, user) { return ( - <> - }} - /> - + }} + /> ); }, avatarSets(user) { return ( - <> - }} - /> - + }} + /> ); }, avatarChanged(user) { return ( - <> - }} - /> - + }} + /> ); }, avatarRemoved(user) { return ( - <> - }} - /> - + }} + /> ); }, nameSets(user, newName) { return ( - <> - }} - /> - + }} + /> ); }, nameChanged(user, newName) { return ( - <> - }} - /> - + }} + /> ); }, nameRemoved(user, lastName) { return ( - <> - }} - /> - + }} + /> ); }, }; diff --git a/src/app/organisms/search/Search.jsx b/src/app/organisms/search/Search.jsx index 02a11e12..1f166262 100644 --- a/src/app/organisms/search/Search.jsx +++ b/src/app/organisms/search/Search.jsx @@ -1,6 +1,7 @@ import React, { useState, useEffect, useRef } from 'react'; import './Search.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import navigation from '../../../client/state/navigation'; @@ -20,8 +21,7 @@ import RoomSelector from '../../molecules/room-selector/RoomSelector'; import SearchIC from '../../../../public/res/ic/outlined/search.svg'; import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function useVisiblityToggle(setResult) { const [isOpen, setIsOpen] = useState(false); @@ -212,12 +212,12 @@ function Search() { size="small" >
- { e.preventDefault(); openFirstResult()}}> + { e.preventDefault(); openFirstResult(); }}> @@ -229,7 +229,7 @@ function Search() {
- {t("Organisms.Search.description")} + {t('Organisms.Search.description')}
diff --git a/src/app/organisms/settings/AuthRequest.jsx b/src/app/organisms/settings/AuthRequest.jsx index 2ddf22cd..83c7122d 100644 --- a/src/app/organisms/settings/AuthRequest.jsx +++ b/src/app/organisms/settings/AuthRequest.jsx @@ -12,7 +12,7 @@ import Spinner from '../../atoms/spinner/Spinner'; import { useStore } from '../../hooks/useStore'; -import '../../i18n.jsx' +import '../../i18n'; import { useTranslation } from 'react-i18next'; let lastUsedPassword; diff --git a/src/app/organisms/settings/CrossSigning.jsx b/src/app/organisms/settings/CrossSigning.jsx index c77c14be..6d2a96ec 100644 --- a/src/app/organisms/settings/CrossSigning.jsx +++ b/src/app/organisms/settings/CrossSigning.jsx @@ -20,7 +20,7 @@ import { authRequest } from './AuthRequest'; import { useCrossSigningStatus } from '../../hooks/useCrossSigningStatus'; -import '../../i18n.jsx' +import '../../i18n'; import { useTranslation } from 'react-i18next'; diff --git a/src/app/organisms/settings/DeviceManage.jsx b/src/app/organisms/settings/DeviceManage.jsx index db6591a1..1da3d71d 100644 --- a/src/app/organisms/settings/DeviceManage.jsx +++ b/src/app/organisms/settings/DeviceManage.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react'; import './DeviceManage.scss'; import dateFormat from 'dateformat'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import { isCrossVerified } from '../../../util/matrixUtil'; import { openReusableDialog, openEmojiVerification } from '../../../client/action/navigation'; @@ -27,9 +28,7 @@ import { useDeviceList } from '../../hooks/useDeviceList'; import { useCrossSigningStatus } from '../../hooks/useCrossSigningStatus'; import { accessSecretStorage } from './SecretStorageAccess'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; - +import '../../i18n'; const promptDeviceName = async (deviceName) => new Promise((resolve) => { let isCompleted = false; @@ -45,17 +44,17 @@ const promptDeviceName = async (deviceName) => new Promise((resolve) => { }; return (
- +
- - + +
); }; openReusableDialog( - {t("Organisms.DeviceManage.edit_session_name_title")}, + {t('Organisms.DeviceManage.edit_session_name_title')}, (requestClose) => renderContent((name) => { isCompleted = true; resolve(name); @@ -95,17 +94,17 @@ function DeviceManage() { }; return (
- +
- - + +
); }; openReusableDialog( - {t("Organisms.DeviceManage.edit_session_name_title")}, + {t('Organisms.DeviceManage.edit_session_name_title')}, (requestClose) => renderContent((name) => { isCompleted = true; resolve(name); @@ -132,7 +131,7 @@ function DeviceManage() {
- {t("Organisms.DeviceManage.loading_devices")} + {t('Organisms.DeviceManage.loading_devices')}
); @@ -155,14 +154,14 @@ function DeviceManage() { const handleRemove = async (device) => { const isConfirmed = await confirmDialog( - t("Organisms.DeviceManage.logout_device_title", {device: device.display_name}), - t("Organisms.DeviceManage.logout_device_message", {device: device.display_name}), - t("Organisms.DeviceManage.logout_device_confirm"), + t('Organisms.DeviceManage.logout_device_title', { device: device.display_name }), + t('Organisms.DeviceManage.logout_device_message', { device: device.display_name }), + t('Organisms.DeviceManage.logout_device_confirm'), 'danger', ); if (!isConfirmed) return; addToProcessing(device); - await authRequest(t("Organisms.DeviceManage.logout_device_title", {device: device.display_name}), async (auth) => { + await authRequest(t('Organisms.DeviceManage.logout_device_title', { device: device.display_name }), async (auth) => { await mx.deleteDevice(device.device_id, auth); }); @@ -171,7 +170,7 @@ function DeviceManage() { }; const verifyWithKey = async (device) => { - const keyData = await accessSecretStorage(t("Organisms.DeviceManage.session_verification_title")); + const keyData = await accessSecretStorage(t('Organisms.DeviceManage.session_verification_title')); if (!keyData) return; addToProcessing(device); await mx.checkOwnCrossSigningTrust(); @@ -205,7 +204,7 @@ function DeviceManage() { {displayName} {`${displayName ? ' — ' : ''}${deviceId}`} - {isCurrentDevice && {t("Organisms.DeviceManage.current_device_label")}} + {isCurrentDevice && {t('Organisms.DeviceManage.current_device_label')}} )} options={ @@ -213,9 +212,9 @@ function DeviceManage() { ? : ( <> - {(isCSEnabled && canVerify) && } - handleRename(device)} src={PencilIC} tooltip={t("Organisms.DeviceManage.edit_session_name_tooltip")} /> - handleRemove(device)} src={BinIC} tooltip={t("Organisms.DeviceManage.logout_device_tooltip")}/> + {(isCSEnabled && canVerify) && } + handleRename(device)} src={PencilIC} tooltip={t('Organisms.DeviceManage.edit_session_name_tooltip')} /> + handleRemove(device)} src={BinIC} tooltip={t('Organisms.DeviceManage.logout_device_tooltip')} /> ) } @@ -256,46 +255,46 @@ function DeviceManage() { return (
- {t("Organisms.DeviceManage.unverified_sessions_title")} + {t('Organisms.DeviceManage.unverified_sessions_title')} {!isCSEnabled && (
)} { unverified.length > 0 ? unverified.map((device) => renderDevice(device, false)) - : {t("Organisms.DeviceManage.unverified_sessions_none")} + : {t('Organisms.DeviceManage.unverified_sessions_none')} }
{noEncryption.length > 0 && (
- {t("Organisms.DeviceManage.unencrypted_sessions_title")} + {t('Organisms.DeviceManage.unencrypted_sessions_title')} {noEncryption.map((device) => renderDevice(device, null))}
)}
- {t("Organisms.DeviceManage.verified_sessions_title")} + {t('Organisms.DeviceManage.verified_sessions_title')} { verified.length > 0 ? verified.map((device, index) => { if (truncated && index >= TRUNCATED_COUNT) return null; return renderDevice(device, true); }) - : {t("Organisms.DeviceManage.verified_sessions_none")} + : {t('Organisms.DeviceManage.verified_sessions_none')} } { verified.length > TRUNCATED_COUNT && ( )} { deviceList.length > 0 && ( - {t("Organisms.DeviceManage.session_name_privacy_message")} + {t('Organisms.DeviceManage.session_name_privacy_message')} )}
diff --git a/src/app/organisms/settings/KeyBackup.jsx b/src/app/organisms/settings/KeyBackup.jsx index 5437968b..dd688967 100644 --- a/src/app/organisms/settings/KeyBackup.jsx +++ b/src/app/organisms/settings/KeyBackup.jsx @@ -24,7 +24,7 @@ import DownloadIC from '../../../../public/res/ic/outlined/download.svg'; import { useStore } from '../../hooks/useStore'; import { useCrossSigningStatus } from '../../hooks/useCrossSigningStatus'; -import '../../i18n.jsx' +import '../../i18n'; import { useTranslation } from 'react-i18next'; diff --git a/src/app/organisms/settings/SecretStorageAccess.jsx b/src/app/organisms/settings/SecretStorageAccess.jsx index 51f47cb9..bb7942d0 100644 --- a/src/app/organisms/settings/SecretStorageAccess.jsx +++ b/src/app/organisms/settings/SecretStorageAccess.jsx @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import './SecretStorageAccess.scss'; import { deriveKey } from 'matrix-js-sdk/lib/crypto/key_passphrase'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import { openReusableDialog } from '../../../client/action/navigation'; import { getDefaultSSKey, getSSKeyInfo } from '../../../util/matrixUtil'; @@ -13,10 +14,7 @@ import Button from '../../atoms/button/Button'; import Input from '../../atoms/input/Input'; import Spinner from '../../atoms/spinner/Spinner'; - -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; - +import '../../i18n'; import { useStore } from '../../hooks/useStore'; @@ -45,7 +43,7 @@ function SecretStorageAccess({ onComplete }) { if (!mountStore.getItem()) return; if (!isCorrect) { - setError(t(key ? "SecretStorageAccess.incorrect_security_key" : "SecretStorageAccess.incorrect_security_phrase")); + setError(t(key ? 'SecretStorageAccess.incorrect_security_key' : 'SecretStorageAccess.incorrect_security_phrase')); setProcess(false); return; } @@ -57,7 +55,7 @@ function SecretStorageAccess({ onComplete }) { }); } catch (e) { if (!mountStore.getItem()) return; - setError(t(key ? "SecretStorageAccess.incorrect_security_key" : "SecretStorageAccess.incorrect_security_phrase")); + setError(t(key ? 'SecretStorageAccess.incorrect_security_key' : 'SecretStorageAccess.incorrect_security_phrase')); setProcess(false); } }; @@ -82,7 +80,7 @@ function SecretStorageAccess({ onComplete }) {
{error}} {!process && (
- - {isPassphrase && } + + {isPassphrase && }
)}
diff --git a/src/app/organisms/settings/Settings.jsx b/src/app/organisms/settings/Settings.jsx index 4d6ef207..3c82d58b 100644 --- a/src/app/organisms/settings/Settings.jsx +++ b/src/app/organisms/settings/Settings.jsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; import './Settings.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import settings from '../../../client/state/settings'; @@ -40,8 +41,7 @@ import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; import CinnySVG from '../../../../public/res/svg/cinny.svg'; import { confirmDialog } from '../../molecules/confirm-dialog/ConfirmDialog'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function AppearanceSection() { const [, updateState] = useState({}); @@ -53,26 +53,26 @@ function AppearanceSection() {
Theme { toggleSystemTheme(); updateState({}); }} /> )} - content={{t("Organisms.Settings.theme.follow_system.description")}} + content={{t('Organisms.Settings.theme.follow_system.description')}} /> {!settings.useSystemTheme && ( settings.setTheme(index)} /> @@ -83,34 +83,34 @@ function AppearanceSection() {
Room messages { toggleMarkdown(); updateState({}); }} /> )} - content={{t("Organisms.Settings.markdown.description")}} + content={{t('Organisms.Settings.markdown.description')}} /> { toggleMembershipEvents(); updateState({}); }} /> )} - content={{t("Organisms.Settings.hide_membership_events.description")}} + content={{t('Organisms.Settings.hide_membership_events.description')}} /> { toggleNickAvatarEvents(); updateState({}); }} /> )} - content={{t("Organisms.Settings.hide_nickname_avatar_events.description")}} + content={{t('Organisms.Settings.hide_nickname_avatar_events.description')}} />
@@ -126,7 +126,7 @@ function NotificationsSection() { const renderOptions = () => { if (window.Notification === undefined) { - return {t("errors.browser_not_supported")}; + return {t('errors.browser_not_supported')}; } if (permission === 'granted') { @@ -154,54 +154,53 @@ function NotificationsSection() { return (
- {t("Organisms.Settings.notifications_and_sound.title")} + {t('Organisms.Settings.notifications_and_sound.title')} {t("Organisms.Settings.notifications_and_sound.desktop.description")}} + content={{t('Organisms.Settings.notifications_and_sound.desktop.description')}} /> { toggleNotificationSounds(); updateState({}); }} /> )} - content={{t("Organisms.Settings.notifications_and_sound.desktop.description")}} + content={{t('Organisms.Settings.notifications_and_sound.desktop.description')}} />
); } function SecuritySection() { - const { t } = useTranslation(); return (
- {t("Organisms.Settings.security.cross_signing.title")} + {t('Organisms.Settings.security.cross_signing.title')}
- {t("Organisms.Settings.security.export_import_encryption_keys.title")} + {t('Organisms.Settings.security.export_import_encryption_keys.title')} - {t("Organisms.Settings.security.export_encryption_keys.description")} + {t('Organisms.Settings.security.export_encryption_keys.description')} )} /> - {t("Organisms.Settings.security.import_encryption_keys.description")} + {t('Organisms.Settings.security.import_encryption_keys.description')} )} @@ -212,31 +211,30 @@ function SecuritySection() { } function AboutSection() { - const { t } = useTranslation(); return (
- {t("Organisms.Settings.about.application")} + {t('Organisms.Settings.about.application')}
Cinny logo
- {t("common.cinny")} + {t('common.cinny')} {`v${cons.version}`} - {t("common.slogan")} + {t('common.slogan')}
- - + +
- {t("Organisms.Settings.about.credits")} + {t('Organisms.Settings.about.credits')}
  • @@ -314,7 +312,7 @@ function Settings() { const handleTabChange = (tabItem) => setSelectedTab(tabItem); const handleLogout = async () => { - if (await confirmDialog(t("Organisms.Settings.logout.dialog.title"), t("Organisms.Settings.logout.dialog.description"), t("Organisms.Settings.logout.dialog.confirm"), 'danger')) { + if (await confirmDialog(t('Organisms.Settings.logout.dialog.title'), t('Organisms.Settings.logout.dialog.description'), t('Organisms.Settings.logout.dialog.confirm'), 'danger')) { logout(); } }; @@ -323,13 +321,13 @@ function Settings() { {t("Organisms.Settings.title")}} + title={{t('Organisms.Settings.title')}} contentOptions={( <> - + )} onRequestClose={requestClose} diff --git a/src/app/organisms/shortcut-spaces/ShortcutSpaces.jsx b/src/app/organisms/shortcut-spaces/ShortcutSpaces.jsx index e39abcd7..2882eaaa 100644 --- a/src/app/organisms/shortcut-spaces/ShortcutSpaces.jsx +++ b/src/app/organisms/shortcut-spaces/ShortcutSpaces.jsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; import './ShortcutSpaces.scss'; +import { useTranslation } from 'react-i18next'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import navigation from '../../../client/state/navigation'; @@ -22,9 +23,7 @@ import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; import { useSpaceShortcut } from '../../hooks/useSpaceShortcut'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; - +import '../../i18n'; function ShortcutSpacesContent() { const mx = initMatrix.matrixClient; @@ -77,8 +76,6 @@ function ShortcutSpacesContent() { const toggleSelected = () => toggleSelection(spaceId); const deleteShortcut = () => deleteSpaceShortcut(spaceId); - const { t } = useTranslation(); - return ( - {t("Organisms.ShortcutSpaces.pinned_spaces")} - {spaceShortcut.length === 0 && {t("Organisms.ShortcutSpaces.no_pinned_spaces")}} + {t('Organisms.ShortcutSpaces.pinned_spaces')} + {spaceShortcut.length === 0 && {t('Organisms.ShortcutSpaces.no_pinned_spaces')}} {spaceShortcut.map((spaceId) => renderSpace(spaceId, true))} - {t("Organisms.ShortcutSpaces.unpinned_spaces")} - {spaceWithoutShortcut.length === 0 && {t("Organisms.ShortcutSpaces.no_unpinned_spaces")}} + {t('Organisms.ShortcutSpaces.unpinned_spaces')} + {spaceWithoutShortcut.length === 0 && {t('Organisms.ShortcutSpaces.no_unpinned_spaces')}} {spaceWithoutShortcut.map((spaceId) => renderSpace(spaceId, false))} {selected.length !== 0 && (
    {process && } - {process || t("Organisms.ShortcutSpaces.spaces_selected", {count: selected.length})} + {process || t('Organisms.ShortcutSpaces.spaces_selected', { count: selected.length })} { !process && ( - + )}
    )} @@ -160,10 +157,10 @@ function ShortcutSpaces() { className="shortcut-spaces" title={( - {t("Organisms.ShortcutSpaces.header")} + {t('Organisms.ShortcutSpaces.header')} )} - contentOptions={} + contentOptions={} onRequestClose={requestClose} > { diff --git a/src/app/organisms/space-manage/SpaceManage.jsx b/src/app/organisms/space-manage/SpaceManage.jsx index f81c5a16..5ec96260 100644 --- a/src/app/organisms/space-manage/SpaceManage.jsx +++ b/src/app/organisms/space-manage/SpaceManage.jsx @@ -3,6 +3,7 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import './SpaceManage.scss'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; @@ -32,9 +33,7 @@ import InfoIC from '../../../../public/res/ic/outlined/info.svg'; import { useForceUpdate } from '../../hooks/useForceUpdate'; import { useStore } from '../../hooks/useStore'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; - +import '../../i18n'; function SpaceManageBreadcrumb({ path, onSelect }) { return ( @@ -120,7 +119,12 @@ function SpaceManageItem({ const roomNameJSX = ( {twemojify(name)} - • {t("Organisms.SpaceManage.room_members", {count: roomInfo.num_joined_members})} + + {' '} + • + {' '} + {t('Organisms.SpaceManage.room_members', { count: roomInfo.num_joined_members })} + ); @@ -148,13 +152,13 @@ function SpaceManageItem({ > {roomAvatarJSX} {roomNameJSX} - {isSuggested && {t("Organisms.SpaceManage.suggested")}} + {isSuggested && {t('Organisms.SpaceManage.suggested')}} {roomInfo.topic && expandBtnJsx} { isJoined - ? - : + ? + : }
{isExpand && roomInfo.topic && {twemojify(roomInfo.topic, undefined, true)}} @@ -162,7 +166,6 @@ function SpaceManageItem({ ); } - SpaceManageItem.propTypes = { parentId: PropTypes.string.isRequired, roomHierarchy: PropTypes.shape({}).isRequired, @@ -187,15 +190,15 @@ function SpaceManageFooter({ parentId, selected }) { }); const handleRemove = () => { - setProcess(t("Organisms.SpaceManage.remove", {count: selected.length})); + setProcess(t('Organisms.SpaceManage.remove', { count: selected.length })); selected.forEach((roomId) => { mx.sendStateEvent(parentId, 'm.space.child', {}, roomId); }); }; const handleToggleSuggested = (isMark) => { - if (isMark) setProcess(t("Organisms.SpaceManage.mark_suggested", {count: selected.length})); - else setProcess(t("Organisms.SpaceManage.mark_not_suggested", {count: selected.length})); + if (isMark) setProcess(t('Organisms.SpaceManage.mark_suggested', { count: selected.length })); + else setProcess(t('Organisms.SpaceManage.mark_not_suggested', { count: selected.length })); selected.forEach((roomId) => { const sEvent = room.currentState.getStateEvents('m.space.child', roomId); if (!sEvent) return; @@ -210,10 +213,10 @@ function SpaceManageFooter({ parentId, selected }) { return (
{process && } - {process || t("Organisms.SpaceManage.items_selected", {count: selected.length})} + {process || t('Organisms.SpaceManage.items_selected', { count: selected.length })} { !process && ( <> - + + )} {isLoading && (
- {t("common.loading")} + {t('common.loading')}
)} {selected.length > 0 && ( @@ -428,7 +430,12 @@ function SpaceManage() { title={( {roomId && twemojify(room.name)} - — {t("Organisms.SpaceManage.subtitle")} + + {' '} + — + {' '} + {t('Organisms.SpaceManage.subtitle')} + )} contentOptions={} diff --git a/src/app/organisms/space-settings/SpaceSettings.jsx b/src/app/organisms/space-settings/SpaceSettings.jsx index 2bb12b0b..29768282 100644 --- a/src/app/organisms/space-settings/SpaceSettings.jsx +++ b/src/app/organisms/space-settings/SpaceSettings.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import './SpaceSettings.scss'; +import { useTranslation } from 'react-i18next'; import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; @@ -39,9 +40,7 @@ import CategoryFilledIC from '../../../../public/res/ic/filled/category.svg'; import { confirmDialog } from '../../molecules/confirm-dialog/ConfirmDialog'; import { useForceUpdate } from '../../hooks/useForceUpdate'; - -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; const tabText = { GENERAL: 'General', @@ -74,7 +73,7 @@ function GeneralSettings({ roomId }) { return ( <>
- {t("common.options")} + {t('common.options')} { if (isCategorized) unCategorizeSpace(roomId); @@ -83,7 +82,7 @@ function GeneralSettings({ roomId }) { }} iconSrc={isCategorized ? CategoryFilledIC : CategoryIC} > - {isCategorized ? t("Organisms.SpaceSettings.uncategorize_subspaces") : t("Organisms.SpaceSettings.categorize_subspaces")} + {isCategorized ? t('Organisms.SpaceSettings.uncategorize_subspaces') : t('Organisms.SpaceSettings.categorize_subspaces')} { @@ -93,30 +92,30 @@ function GeneralSettings({ roomId }) { }} iconSrc={isPinned ? PinFilledIC : PinIC} > - {isPinned ? t("Organisms.SpaceSettings.unpin_sidebar") : t("Organisms.SpaceSettings.pin_sidebar")} + {isPinned ? t('Organisms.SpaceSettings.unpin_sidebar') : t('Organisms.SpaceSettings.pin_sidebar')} { const isConfirmed = await confirmDialog( - t("Organisms.SpaceSettings.leave.leave_dialog_title"), - t("Organisms.SpaceSettings.leave.leave_dialog_message", {space: roomName}), - t("Organisms.SpaceSettings.leave.leave_space"), + t('Organisms.SpaceSettings.leave.leave_dialog_title'), + t('Organisms.SpaceSettings.leave.leave_dialog_message', { space: roomName }), + t('Organisms.SpaceSettings.leave.leave_space'), 'danger', ); if (isConfirmed) leave(roomId); }} iconSrc={LeaveArrowIC} > - {t("Organisms.SpaceSettings.leave.leave_space")} + {t('Organisms.SpaceSettings.leave.leave_space')}
- {t("Organisms.SpaceSettings.visibility.header")} + {t('Organisms.SpaceSettings.visibility.header')}
- {t("Organisms.SpaceSettings.addresses.header")} + {t('Organisms.SpaceSettings.addresses.header')}
@@ -169,10 +168,15 @@ function SpaceSettings() { title={( {isOpen && twemojify(room.name)} - — {t("Organisms.SpaceSettings.subtitle")} + + {' '} + — + {' '} + {t('Organisms.SpaceSettings.subtitle')} + )} - contentOptions={} + contentOptions={} onRequestClose={requestClose} > {isOpen && ( diff --git a/src/app/organisms/view-source/ViewSource.jsx b/src/app/organisms/view-source/ViewSource.jsx index 38d4e4c7..b234421b 100644 --- a/src/app/organisms/view-source/ViewSource.jsx +++ b/src/app/organisms/view-source/ViewSource.jsx @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; import './ViewSource.scss'; +import { useTranslation } from 'react-i18next'; import cons from '../../../client/state/cons'; import navigation from '../../../client/state/navigation'; @@ -12,8 +13,7 @@ import PopupWindow from '../../molecules/popup-window/PopupWindow'; import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function ViewSourceBlock({ title, json }) { return ( @@ -56,18 +56,18 @@ function ViewSource() { const renderViewSource = () => (
- {event.isEncrypted() && } - + {event.isEncrypted() && } +
); return ( setIsOpen(false)} - contentOptions={ setIsOpen(false)} tooltip={t("common.close")} />} + contentOptions={ setIsOpen(false)} tooltip={t('common.close')} />} > {event ? renderViewSource() :
} diff --git a/src/app/organisms/welcome/Welcome.jsx b/src/app/organisms/welcome/Welcome.jsx index 51f9a64b..8091dcbc 100644 --- a/src/app/organisms/welcome/Welcome.jsx +++ b/src/app/organisms/welcome/Welcome.jsx @@ -1,16 +1,15 @@ import React from 'react'; import './Welcome.scss'; +import { useTranslation } from 'react-i18next'; import Text from '../../atoms/text/Text'; import CinnySvg from '../../../../public/res/svg/cinny.svg'; -import '../../i18n.jsx' -import { useTranslation } from 'react-i18next'; +import '../../i18n'; function Welcome() { - - const { t, i18n } = useTranslation(); + const { t } = useTranslation(); return (
diff --git a/src/client/action/auth.js b/src/client/action/auth.js index f9be13bc..2fac5b6a 100644 --- a/src/client/action/auth.js +++ b/src/client/action/auth.js @@ -68,9 +68,7 @@ async function verifyEmail(baseUrl, email, client_secret, send_attempt, next_lin return data; } -async function completeRegisterStage( - baseUrl, username, password, auth, -) { +async function completeRegisterStage(baseUrl, username, password, auth) { const tempClient = createTemporaryClient(baseUrl); try { diff --git a/src/util/cryptE2ERoomKeys.js b/src/util/cryptE2ERoomKeys.js index 50254a3c..579c0c6e 100644 --- a/src/util/cryptE2ERoomKeys.js +++ b/src/util/cryptE2ERoomKeys.js @@ -177,7 +177,6 @@ function unpackMegolmKeyFile(data) { return decodeBase64(fileStr.slice(dataStart, dataEnd)); } - /** * ascii-armour a megolm key file * @@ -196,7 +195,7 @@ function packMegolmKeyFile(data) { let o = 0; let i; for (i = 1; i <= nLines; i += 1) { - lines[i] = encodeBase64(data.subarray(o, o+LINE_LENGTH)); + lines[i] = encodeBase64(data.subarray(o, o + LINE_LENGTH)); o += LINE_LENGTH; } lines[i] = TRAILER_LINE; @@ -305,11 +304,11 @@ export async function encryptMegolmKeyFile(data, password, options) { encodedData, ); } catch (e) { - throw friendlyError('subtleCrypto.encrypt failed: ' + e, cryptoFailMsg()); + throw friendlyError(`subtleCrypto.encrypt failed: ${e}`, cryptoFailMsg()); } const cipherArray = new Uint8Array(ciphertext); - const bodyLength = (1+salt.length+iv.length+4+cipherArray.length+32); + const bodyLength = (1 + salt.length + iv.length + 4 + cipherArray.length + 32); const resultBuffer = new Uint8Array(bodyLength); let idx = 0; resultBuffer[idx++] = 1; // version @@ -331,7 +330,7 @@ export async function encryptMegolmKeyFile(data, password, options) { toSign, ); } catch (e) { - throw friendlyError('subtleCrypto.sign failed: ' + e, cryptoFailMsg()); + throw friendlyError(`subtleCrypto.sign failed: ${e}`, cryptoFailMsg()); } const hmacArray = new Uint8Array(hmac); diff --git a/src/util/matrixUtil.js b/src/util/matrixUtil.js index 43c82bda..dc8a7943 100644 --- a/src/util/matrixUtil.js +++ b/src/util/matrixUtil.js @@ -39,9 +39,9 @@ export function getUsernameOfRoomMember(roomMember) { return roomMember.name || roomMember.userId; } -export function getUserDisplayName(room, userId){ +export function getUserDisplayName(room, userId) { if (room?.getMember(userId)) return getUsernameOfRoomMember(room.getMember(userId)); - return getUsername(userId); + return getUsername(userId); } export async function isRoomAliasAvailable(alias) {