From 55e724e8d84bc676987fa1f85effdf0194f84ef9 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Thu, 1 Apr 2021 13:58:01 -0500 Subject: [PATCH] Allow splitting long notifications This adds the ability to split notification messages in to multiple paragraphs. --- src/notifications/Notification.tsx | 17 ++++++++++++++++- src/notifications/i18n.en.json | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/notifications/Notification.tsx b/src/notifications/Notification.tsx index 88ec7c6f..fc49da35 100644 --- a/src/notifications/Notification.tsx +++ b/src/notifications/Notification.tsx @@ -20,5 +20,20 @@ export default function Notification(props: OwnProps): JSX.Element { fallback: en, }); const { messageId, replacements } = props; - return <>{i18n.translate(messageId, replacements)}; + let message = i18n.translate(messageId, replacements) as + | React.ReactElement + | string; + + // Use newline characters to create paragraphs + if (typeof message === 'string') { + message = ( + <> + {message.split('\n').map((x, i) => ( +

{x}

+ ))} + + ); + } + + return message; } diff --git a/src/notifications/i18n.en.json b/src/notifications/i18n.en.json index c7264b45..d20fb9f5 100644 --- a/src/notifications/i18n.en.json +++ b/src/notifications/i18n.en.json @@ -6,14 +6,14 @@ }, "ble": { "gattPermission": "The web browser did not give permission to use Bluetooth Low Energy", - "gattServiceNotFound": "Connected to hub but failed to get {serviceName} service. Ensure that you are using the most recent firmware. If the problem persists, try removing the \"{hubName}\" device in your OS Bluetooth settings, then try connecting again.", + "gattServiceNotFound": "Connected to hub but failed to get {serviceName} service.\nEnsure that you are using the most recent firmware.\nIf the problem persists, try removing the \"{hubName}\" device in your OS Bluetooth settings, then try connecting again.", "noWebBluetooth": "This web browser does not support Web Bluetooth or it is not enabled.", "noBluetooth": "No Bluetooth adapter could be found. Bluetooth won't work.", "unexpectedError": "Unexpected error while trying to connect: {errorMessage}" }, "editor": { "programChanged": { - "message": "The program was changed in another window. Do you want to delete this program and replace it with the new program?", + "message": "The program was changed in another window.\nDo you want to delete this program and replace it with the new program?", "action": "Reload" } },