From 307adf053e6fee914519c2416cef58c88060c530 Mon Sep 17 00:00:00 2001 From: Stevie Robinson Date: Sun, 13 Aug 2023 23:03:52 +0200 Subject: [PATCH] Translate Updated and Connection Lost Modals in frontend (cherry picked from commit 074aa6f4457bf83173e6ba7209c452a6e0659a35) --- frontend/src/App/AppUpdatedModalContent.css | 1 + frontend/src/App/AppUpdatedModalContent.js | 15 ++++--- frontend/src/App/ConnectionLostModal.js | 4 +- .../src/Components/Markdown/InlineMarkdown.js | 41 ++++++++++++++++--- src/NzbDrone.Core/Localization/Core/en.json | 8 +++- 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/frontend/src/App/AppUpdatedModalContent.css b/frontend/src/App/AppUpdatedModalContent.css index 37b89c9be..0df4183a6 100644 --- a/frontend/src/App/AppUpdatedModalContent.css +++ b/frontend/src/App/AppUpdatedModalContent.css @@ -1,6 +1,7 @@ .version { margin: 0 3px; font-weight: bold; + font-family: var(--defaultFontFamily); } .maintenance { diff --git a/frontend/src/App/AppUpdatedModalContent.js b/frontend/src/App/AppUpdatedModalContent.js index d03609a69..71dc7702c 100644 --- a/frontend/src/App/AppUpdatedModalContent.js +++ b/frontend/src/App/AppUpdatedModalContent.js @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import Button from 'Components/Link/Button'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import InlineMarkdown from 'Components/Markdown/InlineMarkdown'; import ModalBody from 'Components/Modal/ModalBody'; import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; @@ -64,12 +65,12 @@ function AppUpdatedModalContent(props) { return ( - Prowlarr Updated + {translate('AppUpdated', { appName: 'Prowlarr' })}
- Version {version} of Prowlarr has been installed, in order to get the latest changes you'll need to reload Prowlarr. +
{ @@ -77,16 +78,14 @@ function AppUpdatedModalContent(props) {
{ !update.changes && -
- {translate('MaintenanceRelease')} -
+
{translate('MaintenanceRelease')}
} { !!update.changes &&
- What's new? + {translate('WhatsNew')}
- Recent Changes + {translate('RecentChanges')} diff --git a/frontend/src/App/ConnectionLostModal.js b/frontend/src/App/ConnectionLostModal.js index 16adf78f5..71cfa907e 100644 --- a/frontend/src/App/ConnectionLostModal.js +++ b/frontend/src/App/ConnectionLostModal.js @@ -28,11 +28,11 @@ function ConnectionLostModal(props) {
- {translate('ConnectionLostMessage')} + {translate('ConnectionLostToBackend', { appName: 'Prowlarr' })}
- {translate('ConnectionLostAutomaticMessage')} + {translate('ConnectionLostReconnect', { appName: 'Prowlarr' })}
diff --git a/frontend/src/Components/Markdown/InlineMarkdown.js b/frontend/src/Components/Markdown/InlineMarkdown.js index dc9ea9bf3..993bb241e 100644 --- a/frontend/src/Components/Markdown/InlineMarkdown.js +++ b/frontend/src/Components/Markdown/InlineMarkdown.js @@ -10,27 +10,55 @@ class InlineMarkdown extends Component { render() { const { className, - data + data, + blockClassName } = this.props; - // For now only replace links + // For now only replace links or code blocks (not both) const markdownBlocks = []; if (data) { - const regex = RegExp(/\[(.+?)\]\((.+?)\)/g); + const linkRegex = RegExp(/\[(.+?)\]\((.+?)\)/g); let endIndex = 0; let match = null; - while ((match = regex.exec(data)) !== null) { + + while ((match = linkRegex.exec(data)) !== null) { if (match.index > endIndex) { markdownBlocks.push(data.substr(endIndex, match.index - endIndex)); } + markdownBlocks.push({match[1]}); endIndex = match.index + match[0].length; } - if (endIndex !== data.length) { + if (endIndex !== data.length && markdownBlocks.length > 0) { markdownBlocks.push(data.substr(endIndex, data.length - endIndex)); } + + const codeRegex = RegExp(/(?=`)`(?!`)[^`]*(?=`)`(?!`)/g); + + endIndex = 0; + match = null; + let matchedCode = false; + + while ((match = codeRegex.exec(data)) !== null) { + matchedCode = true; + + if (match.index > endIndex) { + markdownBlocks.push(data.substr(endIndex, match.index - endIndex)); + } + + markdownBlocks.push({match[0].substring(1, match[0].length - 1)}); + endIndex = match.index + match[0].length; + } + + if (endIndex !== data.length && markdownBlocks.length > 0 && matchedCode) { + markdownBlocks.push(data.substr(endIndex, data.length - endIndex)); + } + + if (markdownBlocks.length === 0) { + markdownBlocks.push(data); + } } return {markdownBlocks}; @@ -39,7 +67,8 @@ class InlineMarkdown extends Component { InlineMarkdown.propTypes = { className: PropTypes.string, - data: PropTypes.string + data: PropTypes.string, + blockClassName: PropTypes.string }; export default InlineMarkdown; diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 289b7103c..66ccfad7a 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -31,6 +31,8 @@ "AppProfileInUse": "App Profile in Use", "AppProfileSelectHelpText": "App profiles are used to control RSS, Automatic Search and Interactive Search settings on application sync", "AppSettingsSummary": "Applications and settings to configure how Prowlarr interacts with your PVR programs", + "AppUpdated": "{appName} Updated", + "AppUpdatedVersion": "{appName} has been updated to version `{version}`, in order to get the latest changes you'll need to reload {appName}", "Application": "Application", "ApplicationLongTermStatusCheckAllClientMessage": "All applications are unavailable due to failures for more than 6 hours", "ApplicationLongTermStatusCheckSingleClientMessage": "Applications unavailable due to failures for more than 6 hours: {0}", @@ -103,8 +105,8 @@ "ConnectSettings": "Connect Settings", "ConnectSettingsSummary": "Notifications and custom scripts", "ConnectionLost": "Connection Lost", - "ConnectionLostAutomaticMessage": "Prowlarr will try to connect automatically, or you can click reload below.", - "ConnectionLostMessage": "Prowlarr has lost its connection to the backend and will need to be reloaded to restore functionality.", + "ConnectionLostReconnect": "{appName} will try to connect automatically, or you can click reload below.", + "ConnectionLostToBackend": "{appName} has lost its connection to the backend and will need to be reloaded to restore functionality.", "Connections": "Connections", "CouldNotConnectSignalR": "Could not connect to SignalR, UI won't update", "CountApplicationsSelected": "{count} application(s) selected", @@ -375,6 +377,7 @@ "RSSIsNotSupportedWithThisIndexer": "RSS is not supported with this indexer", "RawSearchSupported": "Raw Search Supported", "ReadTheWikiForMoreInformation": "Read the Wiki for more information", + "RecentChanges": "Recent Changes", "Reddit": "Reddit", "Redirect": "Redirect", "RedirectHelpText": "Redirect incoming download request for indexer and pass the grab directly instead of proxying the request via Prowlarr", @@ -552,6 +555,7 @@ "VipExpiration": "VIP Expiration", "Warn": "Warn", "Website": "Website", + "WhatsNew": "What's New?", "Wiki": "Wiki", "Year": "Year", "Yes": "Yes",