From 6f7c8d54f29bf71a5d4099ede90780aed204c260 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Sun, 24 Jul 2022 21:51:27 +0200 Subject: [PATCH] Translate TrackPage --- frontend/src/components/Visibility.tsx | 18 +++ frontend/src/components/index.js | 1 + frontend/src/pages/TrackPage/TrackActions.tsx | 38 ++--- .../src/pages/TrackPage/TrackComments.tsx | 66 +++++--- frontend/src/pages/TrackPage/TrackDetails.tsx | 147 +++++++++--------- frontend/src/pages/TrackPage/index.tsx | 60 +++---- frontend/src/pages/TracksPage.tsx | 10 +- frontend/src/translations/de.yaml | 48 ++++++ frontend/src/translations/en.yaml | 49 ++++++ 9 files changed, 292 insertions(+), 145 deletions(-) create mode 100644 frontend/src/components/Visibility.tsx diff --git a/frontend/src/components/Visibility.tsx b/frontend/src/components/Visibility.tsx new file mode 100644 index 0000000..453627a --- /dev/null +++ b/frontend/src/components/Visibility.tsx @@ -0,0 +1,18 @@ +import React from "react"; +import { Icon } from "semantic-ui-react"; +import { useTranslation } from "react-i18next"; + +export default function Visibility({ public: public_ }: { public: boolean }) { + const { t } = useTranslation(); + const icon = public_ ? ( + + ) : ( + + ); + const text = public_ ? t("general.public") : t("general.private"); + return ( + <> + {icon} {text} + + ); +} diff --git a/frontend/src/components/index.js b/frontend/src/components/index.js index 6764bf9..e5e4c3f 100644 --- a/frontend/src/components/index.js +++ b/frontend/src/components/index.js @@ -9,3 +9,4 @@ export {default as Page} from './Page' export {default as Stats} from './Stats' export {default as StripMarkdown} from './StripMarkdown' export {default as Chart} from './Chart' +export {default as Visibility} from './Visibility' diff --git a/frontend/src/pages/TrackPage/TrackActions.tsx b/frontend/src/pages/TrackPage/TrackActions.tsx index 3c14e20..c0d44cf 100644 --- a/frontend/src/pages/TrackPage/TrackActions.tsx +++ b/frontend/src/pages/TrackPage/TrackActions.tsx @@ -1,40 +1,40 @@ import React from 'react' import {Link} from 'react-router-dom' import {Icon, Popup, Button, Dropdown} from 'semantic-ui-react' +import { useTranslation } from "react-i18next"; export default function TrackActions({slug, isAuthor, onDownload}) { + const { t } = useTranslation(); + return ( <> - {isAuthor && ( - - - - )} - - - - onDownload('original.csv')} disabled={!isAuthor} /> - onDownload('track.gpx')} /> - - - } offset={[12, 0]} content={ isAuthor ? ( <> -

Only you, the author of this track, can download the original file.

-

- This is the file as it was uploaded to the server, without modifications, and it can be used with other - tools. -

+

{t('TrackPage.actions.hintAuthorOnly')}

+

{t('TrackPage.actions.hintOriginal')}

) : ( -

Only the author of this track can download the original file.

+

{t('TrackPage.actions.hintAuthorOnlyOthers')}

) } /> + + + + onDownload('original.csv')} disabled={!isAuthor} /> + onDownload('track.gpx')} /> + + + + {isAuthor && ( + + + + )} ) } diff --git a/frontend/src/pages/TrackPage/TrackComments.tsx b/frontend/src/pages/TrackPage/TrackComments.tsx index abbb93f..4f221f5 100644 --- a/frontend/src/pages/TrackPage/TrackComments.tsx +++ b/frontend/src/pages/TrackPage/TrackComments.tsx @@ -1,31 +1,57 @@ -import React from 'react' -import {Message, Segment, Form, Button, Loader, Header, Comment} from 'semantic-ui-react' -import Markdown from 'react-markdown' +import React from "react"; +import { + Message, + Segment, + Form, + Button, + Loader, + Header, + Comment, +} from "semantic-ui-react"; +import Markdown from "react-markdown"; +import { useTranslation } from "react-i18next"; -import {Avatar, FormattedDate} from 'components' +import { Avatar, FormattedDate } from "components"; -function CommentForm({onSubmit}) { - const [body, setBody] = React.useState('') +function CommentForm({ onSubmit }) { + const { t } = useTranslation(); + const [body, setBody] = React.useState(""); const onSubmitComment = React.useCallback(() => { - onSubmit({body}) - setBody('') - }, [onSubmit, body]) + onSubmit({ body }); + setBody(""); + }, [onSubmit, body]); return (
- setBody(e.target.value)} /> -