From eab2d3a2cf78d874a597a14455d1b7f939b68475 Mon Sep 17 00:00:00 2001 From: Andrey Babushkin <55714097+reyand43@users.noreply.github.com> Date: Mon, 10 Mar 2025 15:51:21 +0100 Subject: [PATCH] Fix localisation (#3123) * fix localised errors * fix locales --- frontend/app/components/Alerts/AlertForm.tsx | 5 +- .../Alerts/Notifications/Notifications.tsx | 4 +- .../AssistActions/AssistActions.tsx | 2 +- .../CustomMetricTableErrors.tsx | 21 +++++---- .../components/Alerts/AlertForm/Condition.tsx | 14 ++++-- .../DashboardOptions/DashboardOptions.tsx | 2 +- .../DashboardWidgetGrid.tsx | 4 +- .../FilterSeries/SeriesName/SeriesName.tsx | 4 +- .../FunnelIssueGraph/FunnelIssueGraph.tsx | 8 ++-- .../components/WidgetName/WidgetName.tsx | 2 +- .../components/WidgetView/CardViewMenu.tsx | 14 +++--- .../components/WidgetView/WidgetView.tsx | 6 +-- .../WidgetView/WidgetViewHeader.tsx | 10 ++-- .../Funnels/FunnelMenuItem/FunnelMenuItem.js | 4 +- .../Funnels/IssueItem/IssueGraph.js | 6 +-- .../Highlights/HighlightsListHeader.tsx | 2 +- .../Player/ClipPlayer/AutoplayToggle.tsx | 4 +- .../Player/ClipPlayer/ClipPlayerHeader.tsx | 4 +- .../Player/LivePlayer/LivePlayerSubHeader.tsx | 4 +- .../MobilePlayer/MobilePlayerSubheader.tsx | 6 ++- .../Session/Player/TagWatch/TagWatch.tsx | 2 +- .../Session_/EventsBlock/EventsBlock.tsx | 2 + .../Session_/Highlight/HighlightButton.tsx | 4 +- .../app/components/Session_/Issues/Issues.js | 2 +- .../components/Session_/Storage/Storage.tsx | 11 +++-- .../app/components/Session_/Subheader.tsx | 2 +- .../SpotPlayer/components/SpotLocation.tsx | 4 +- .../Spots/SpotsList/SpotListItem.tsx | 22 +++++---- frontend/app/components/hocs/withCopy.tsx | 4 +- .../shared/AutoplayToggle/AutoplayToggle.tsx | 8 ++-- .../components/shared/CopyText/CopyText.tsx | 6 ++- .../StackEventPanel/StackEventPanel.tsx | 2 +- .../components/FetchTabs/FetchTabs.tsx | 5 +- .../FilterAutoComplete/AutocompleteModal.tsx | 2 +- .../shared/Filters/FilterList/EventsOrder.tsx | 2 +- .../shared/LiveSearchBar/LiveSearchBar.tsx | 2 +- .../SelectDateRange/SelectDateRange.tsx | 13 ++++-- .../SessionItem/ErrorBars/ErrorBars.tsx | 4 +- .../SessionSettingButton.tsx | 4 +- .../components/ui/CountryFlag/CountryFlag.tsx | 4 +- frontend/app/locales/en.json | 40 +++++++++++++++- frontend/app/locales/es.json | 40 +++++++++++++++- frontend/app/locales/fr.json | 40 +++++++++++++++- frontend/app/locales/ru.json | 46 +++++++++++++++++-- frontend/app/locales/zh.json | 40 +++++++++++++++- 45 files changed, 344 insertions(+), 93 deletions(-) diff --git a/frontend/app/components/Alerts/AlertForm.tsx b/frontend/app/components/Alerts/AlertForm.tsx index fefa89ff0..84133bc69 100644 --- a/frontend/app/components/Alerts/AlertForm.tsx +++ b/frontend/app/components/Alerts/AlertForm.tsx @@ -228,7 +228,10 @@ function AlertForm(props) {
c.value === instance.query.operator) || '' + localizedConditions.find((c) => c.value === instance.query.operator) || '' } onChange={({ value }) => writeQueryOption(null, { name: 'operator', value: value.value }) diff --git a/frontend/app/components/Dashboard/components/DashboardOptions/DashboardOptions.tsx b/frontend/app/components/Dashboard/components/DashboardOptions/DashboardOptions.tsx index ccb83e078..8dd13f7e1 100644 --- a/frontend/app/components/Dashboard/components/DashboardOptions/DashboardOptions.tsx +++ b/frontend/app/components/Dashboard/components/DashboardOptions/DashboardOptions.tsx @@ -35,7 +35,7 @@ function DashboardOptions(props: Props) { { icon: , key: 'delete', - label: 'Delete', + label: t('Delete'), onClick: deleteHandler, }, { diff --git a/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx b/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx index 12201b63e..15241457d 100644 --- a/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx +++ b/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx @@ -7,6 +7,7 @@ import { Button, Popover, Tooltip } from 'antd'; import { PlusOutlined } from '@ant-design/icons'; import { Loader } from 'UI'; import AddCardSection from '../AddCardSection/AddCardSection'; +import { useTranslation } from 'react-i18next'; interface Props { siteId: string; @@ -53,6 +54,7 @@ function DashboardWidgetGrid(props: Props) { } function GridItem({ item, index, dashboard, dashboardId, siteId }: any) { + const { t } = useTranslation(); const [popoverOpen, setPopoverOpen] = React.useState(false); const handleOpenChange = (open: boolean) => { setPopoverOpen(open); @@ -92,7 +94,7 @@ function GridItem({ item, index, dashboard, dashboardId, siteId }: any) { content={} trigger="click" > - + {/* */} diff --git a/frontend/app/components/Funnels/FunnelMenuItem/FunnelMenuItem.js b/frontend/app/components/Funnels/FunnelMenuItem/FunnelMenuItem.js index a652fd5d6..087a2c7fb 100644 --- a/frontend/app/components/Funnels/FunnelMenuItem/FunnelMenuItem.js +++ b/frontend/app/components/Funnels/FunnelMenuItem/FunnelMenuItem.js @@ -2,6 +2,7 @@ import React from 'react'; import cn from 'classnames'; import { Icon, Tooltip } from 'UI'; import stl from './funnelMenuItem.module.css'; +import { useTranslation } from 'react-i18next'; function FunnelMenuItem({ iconName = 'info', @@ -12,6 +13,7 @@ function FunnelMenuItem({ isPublic = false, onClick, }) { + const { t } = useTranslation(); return (
- +
- +
- +
{issue.affectedSessionsPer}
*/}
- +
- {tag.toLowerCase()} + {(t(tag.toLowerCase()))}
), })), diff --git a/frontend/app/components/Session/Player/ClipPlayer/AutoplayToggle.tsx b/frontend/app/components/Session/Player/ClipPlayer/AutoplayToggle.tsx index a727efdd2..7b72fe162 100644 --- a/frontend/app/components/Session/Player/ClipPlayer/AutoplayToggle.tsx +++ b/frontend/app/components/Session/Player/ClipPlayer/AutoplayToggle.tsx @@ -10,8 +10,10 @@ import { CaretRightOutlined, PauseOutlined, } from './.store/@ant-design-icons-virtual-de151eefe5/package'; +import { useTranslation } from 'react-i18next'; function AutoplayToggle() { + const { t } = useTranslation(); const { clipStore } = useStore(); const playerContext = React.useContext(PlayerContext); // const { player, store } = playerContext; @@ -22,7 +24,7 @@ function AutoplayToggle() { }; return ( - + - + diff --git a/frontend/app/components/Session_/Issues/Issues.js b/frontend/app/components/Session_/Issues/Issues.js index fe4715d06..ca87863a7 100644 --- a/frontend/app/components/Session_/Issues/Issues.js +++ b/frontend/app/components/Session_/Issues/Issues.js @@ -37,7 +37,7 @@ function Issues({ sessionId }) { )} >
- + diff --git a/frontend/app/components/Session_/Storage/Storage.tsx b/frontend/app/components/Session_/Storage/Storage.tsx index 61f3cbcc7..7b7c0e25a 100644 --- a/frontend/app/components/Session_/Storage/Storage.tsx +++ b/frontend/app/components/Session_/Storage/Storage.tsx @@ -277,20 +277,21 @@ function Storage() { style={{ paddingRight: 30, marginLeft: 'auto' }} className="font-semibold" > - {t('TTE')} + {t('TTE')}
- { - 'Inspect your application state while you’re replaying your users sessions. OpenReplay supports ' - } + {t( + 'Inspect your application state while you’re replaying your users sessions. OpenReplay supports', + )} +  
- +
- + (); @@ -52,17 +54,17 @@ function SpotListItem({ { key: 'rename', icon: , - label: 'Rename', + label: t('Rename'), }, { key: 'download', - label: 'Download Video', + label: t('Download Video'), icon: , }, { key: 'delete', icon: , - label: 'Delete', + label: t('Delete'), }, ]; @@ -70,7 +72,7 @@ function SpotListItem({ menuItems.splice(1, 0, { key: 'slack', icon: , - label: 'Share via Slack', + label: t('Share via Slack'), }); }, []); const onMenuClick = async ({ key }: any) => { @@ -88,7 +90,7 @@ function SpotListItem({ siteId, )}`, ); - return toast.success('Spot URL copied to clipboard'); + return toast.success(t('Spot URL copied to clipboard')); case 'delete': return onDelete(); case 'slack': @@ -114,12 +116,12 @@ function SpotListItem({ navigator.clipboard .writeText(fullLink) .then(() => { - setTooltipText('Link copied to clipboard!'); - setTimeout(() => setTooltipText('Copy link to clipboard'), 2000); // Reset tooltip text after 2 seconds + setTooltipText(t('Link copied to clipboard!')); + setTimeout(() => setTooltipText(t('Copy link to clipboard')), 2000); // Reset tooltip text after 2 seconds }) .catch(() => { - setTooltipText('Failed to copy URL'); - setTimeout(() => setTooltipText('Copy link to clipboard'), 2000); // Reset tooltip text after 2 seconds + setTooltipText(t('Failed to copy URL')); + setTimeout(() => setTooltipText(t('Copy link to clipboard')), 2000); // Reset tooltip text after 2 seconds }); }; diff --git a/frontend/app/components/hocs/withCopy.tsx b/frontend/app/components/hocs/withCopy.tsx index b1f3b5f02..81f38c581 100644 --- a/frontend/app/components/hocs/withCopy.tsx +++ b/frontend/app/components/hocs/withCopy.tsx @@ -1,9 +1,11 @@ import React from 'react'; import copy from 'copy-to-clipboard'; import { Tooltip } from 'UI'; +import { useTranslation } from 'react-i18next'; const withCopy = (WrappedComponent: React.ComponentType) => { function ComponentWithCopy(props: any) { + const { t } = useTranslation(); const [copied, setCopied] = React.useState(false); const { value, tooltip } = props; const copyToClipboard = (text: string) => { @@ -18,7 +20,7 @@ const withCopy = (WrappedComponent: React.ComponentType) => { onClick={() => copyToClipboard(value)} className="w-fit cursor-pointer" > - +
diff --git a/frontend/app/components/shared/AutoplayToggle/AutoplayToggle.tsx b/frontend/app/components/shared/AutoplayToggle/AutoplayToggle.tsx index aa1685a77..68d0aca1d 100644 --- a/frontend/app/components/shared/AutoplayToggle/AutoplayToggle.tsx +++ b/frontend/app/components/shared/AutoplayToggle/AutoplayToggle.tsx @@ -4,22 +4,24 @@ import { observer } from 'mobx-react-lite'; import { Switch, Tooltip, message } from 'antd'; import { CaretRightOutlined, PauseOutlined } from '@ant-design/icons'; import './AutoplayToggle.css'; +import { useTranslation } from 'react-i18next'; const AutoplayToggle: React.FC = () => { + const { t } = useTranslation(); const { player, store } = useContext(PlayerContext); const { autoplay } = store.get(); const handleToggle = () => { player.toggleAutoplay(); if (!autoplay) { - message.success('Autoplay is ON'); + message.success(t('Autoplay is ON')); } else { - message.info('Autoplay is OFF'); + message.info(t('Autoplay is OFF')); } }; return ( - + + {t('Current Tab')} ), diff --git a/frontend/app/components/shared/FetchDetailsModal/components/FetchTabs/FetchTabs.tsx b/frontend/app/components/shared/FetchDetailsModal/components/FetchTabs/FetchTabs.tsx index d29ea5eef..ebe8cf68a 100644 --- a/frontend/app/components/shared/FetchDetailsModal/components/FetchTabs/FetchTabs.tsx +++ b/frontend/app/components/shared/FetchDetailsModal/components/FetchTabs/FetchTabs.tsx @@ -4,6 +4,7 @@ import { JSONTree, Tabs, NoContent } from 'UI'; import AnimatedSVG, { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG'; import Headers from '../Headers'; import { useTranslation } from 'react-i18next'; +import { TFunction } from 'i18next'; const HEADERS = 'HEADERS'; const REQUEST = 'REQUEST'; @@ -23,8 +24,8 @@ function parseRequestResponse( setHeaders: (hs: Record | null) => void, setJSONBody: (body: Record | null) => void, setStringBody: (body: string) => void, + t: TFunction, ): void { - const { t } = useTranslation(); try { if (!r) { setHeaders(null); @@ -100,12 +101,14 @@ function FetchTabs({ resource, isSpot }: Props) { setRequestHeaders, setJsonRequest, setStringRequest, + t, ); parseRequestResponse( response, setResponseHeaders, setJsonResponse, setStringResponse, + t, ); }, [resource]); diff --git a/frontend/app/components/shared/Filters/FilterAutoComplete/AutocompleteModal.tsx b/frontend/app/components/shared/Filters/FilterAutoComplete/AutocompleteModal.tsx index e4eca9bef..ae77f91da 100644 --- a/frontend/app/components/shared/Filters/FilterAutoComplete/AutocompleteModal.tsx +++ b/frontend/app/components/shared/Filters/FilterAutoComplete/AutocompleteModal.tsx @@ -205,7 +205,7 @@ export function AutocompleteModal({
- +
-
{state}
+
{t(state)}
); } diff --git a/frontend/app/components/shared/SessionsTabOverview/components/SessionSettingButton/SessionSettingButton.tsx b/frontend/app/components/shared/SessionsTabOverview/components/SessionSettingButton/SessionSettingButton.tsx index 77cf6e3b4..21c748c63 100644 --- a/frontend/app/components/shared/SessionsTabOverview/components/SessionSettingButton/SessionSettingButton.tsx +++ b/frontend/app/components/shared/SessionsTabOverview/components/SessionSettingButton/SessionSettingButton.tsx @@ -3,8 +3,10 @@ import React from 'react'; import SessionSettings from 'Shared/SessionSettings'; import { Icon, Tooltip } from 'UI'; import { Button } from 'antd'; +import { useTranslation } from 'react-i18next'; function SessionSettingButton(props: any) { + const { t } = useTranslation(); const { showModal } = useModal(); const handleClick = () => { @@ -13,7 +15,7 @@ function SessionSettingButton(props: any) { return (
- +