From 85d91c64b5b3ec31df8acecd68a1fa6a68d57ff9 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Wed, 30 Mar 2022 21:47:45 +0200 Subject: feat(renderer): Renderer translations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add react-i18n to make us able to use i18next translations in the renderer process just like we do in the main process. Translations are hot-reloaded automatically. Signed-off-by: Kristóf Marussy --- .../renderer/src/components/NewWindowBanner.tsx | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'packages/renderer/src/components/NewWindowBanner.tsx') diff --git a/packages/renderer/src/components/NewWindowBanner.tsx b/packages/renderer/src/components/NewWindowBanner.tsx index a49b4b1..9aa6121 100644 --- a/packages/renderer/src/components/NewWindowBanner.tsx +++ b/packages/renderer/src/components/NewWindowBanner.tsx @@ -23,6 +23,7 @@ import IconOpenInNew from '@mui/icons-material/OpenInNew'; import Button from '@mui/material/Button'; import { observer } from 'mobx-react-lite'; import React from 'react'; +import { Trans, useTranslation } from 'react-i18next'; import type Service from '../stores/Service'; @@ -33,6 +34,10 @@ function NewWindowBanner({ }: { service: Service | undefined; }): JSX.Element | null { + const { t } = useTranslation(undefined, { + keyPrefix: 'banner.newWindow', + }); + if (service === undefined) { // eslint-disable-next-line unicorn/no-null -- React requires `null` to skip rendering. return null; @@ -63,7 +68,7 @@ function NewWindowBanner({ color="inherit" size="small" > - Follow link in this window + {t('followLink')} {count > 1 && ( <> @@ -81,27 +86,29 @@ function NewWindowBanner({ size="small" startIcon={} > - Open all + {t('openAllInExternalBrowser')} )} } > - {name} wants to open {url}{' '} {count === 1 ? ( - <>in a new window + + {{ name }} wants to open {{ url }} in a new window + ) : ( - <> - and {count} other links in new windows - + + {{ name }} wants to open {{ url }} and{' '} + {{ count: count - 1 }} other links in new windows + )} ); -- cgit v1.2.3-54-g00ecf