diff --git a/frontend/src/pages/HomePage.tsx b/frontend/src/pages/HomePage.tsx index c9381ae..b8aede0 100644 --- a/frontend/src/pages/HomePage.tsx +++ b/frontend/src/pages/HomePage.tsx @@ -1,16 +1,15 @@ import React from 'react' -import {Link} from 'react-router-dom' -import {Message, Grid, Loader, Header, Item} from 'semantic-ui-react' +import {Grid, Loader, Header, Item} from 'semantic-ui-react' import {useObservable} from 'rxjs-hooks' import {of, from} from 'rxjs' import {map, switchMap} from 'rxjs/operators' -import {useTranslation, Trans as Translate} from 'react-i18next' +import {useTranslation} from 'react-i18next' import api from 'api' import {Stats, Page} from 'components' import type {Track} from 'types' -import {TrackListItem} from './TracksPage' +import {TrackListItem, NoPublicTracksMessage} from './TracksPage' function MostRecentTrack() { const {t} = useTranslation() @@ -30,11 +29,7 @@ function MostRecentTrack() {
{t('HomePage.mostRecentTrack')}
{track === undefined ? ( - - - No public tracks yet. Upload the first! - - + ) : track ? ( diff --git a/frontend/src/pages/TracksPage.tsx b/frontend/src/pages/TracksPage.tsx index 8bebc8d..fcdb62a 100644 --- a/frontend/src/pages/TracksPage.tsx +++ b/frontend/src/pages/TracksPage.tsx @@ -6,6 +6,7 @@ import {Link} from 'react-router-dom' import {of, from, concat} from 'rxjs' import {map, switchMap, distinctUntilChanged} from 'rxjs/operators' import _ from 'lodash' +import {useTranslation, Trans as Translate} from 'react-i18next' import type {Track} from 'types' import {Avatar, Page, StripMarkdown} from 'components' @@ -38,10 +39,11 @@ function TrackList({privateTracks}: {privateTracks: boolean}) { const {tracks, trackCount} = data || {tracks: [], trackCount: 0} const loading = !data const totalPages = Math.ceil(trackCount / pageSize) + const {t} = useTranslation() return (
- + {!loading && totalPages > 1 && ( ) : ( - - No public tracks yet. Upload the first! - + )}
) } -function maxLength(t, max) { +export function NoPublicTracksMessage() { + return ( + + + No public tracks yet. Upload the first! + + + ) +} + +function maxLength(t: string|null, max: number): string|null { if (t && t.length > max) { return t.substring(0, max) + ' ...' } else { @@ -82,6 +92,8 @@ const COLOR_BY_STATUS = { } export function TrackListItem({track, privateTracks = false}) { + const {t} = useTranslation() + return ( @@ -89,10 +101,12 @@ export function TrackListItem({track, privateTracks = false}) { - {track.title || 'Unnamed track'} + {track.title || t('general.unnamedTrack')} - Created by {track.author.username} on {track.createdAt} + + Created by {{author: track.author.username}} on {{date: track.createdAt}} + {maxLength(track.description, 200)} @@ -101,17 +115,18 @@ export function TrackListItem({track, privateTracks = false}) { {track.public ? ( <> - Public + {t('general.public')} ) : ( <> - Private + {t('general.private')} )} - Processing{' '} - {track.processingStatus} + + {' '} + {t(`TracksPage.processing.${track.processingStatus}`)} )} @@ -121,6 +136,7 @@ export function TrackListItem({track, privateTracks = false}) { } function UploadButton({navigate, ...props}) { + const {t} = useTranslation() const onClick = useCallback( (e) => { e.preventDefault() @@ -130,13 +146,15 @@ function UploadButton({navigate, ...props}) { ) return ( ) } const TracksPage = connect((state) => ({login: (state as any).login}))(function TracksPage({login, privateTracks}) { - const title = privateTracks ? 'My tracks' : 'Public tracks' + const {t} = useTranslation() + const title = privateTracks ? t('TracksPage.titleUser') : t('TracksPage.titlePublic') + return (
{title}
diff --git a/frontend/src/translations/de.yaml b/frontend/src/translations/de.yaml index 6389af1..134dbe6 100644 --- a/frontend/src/translations/de.yaml +++ b/frontend/src/translations/de.yaml @@ -1,3 +1,9 @@ +general: + loading: Lädt + unnamedTrack: Unbenannte Fahrt + public: Öffentlich + private: Privat + App: footer: aboutTheProject: Über das Projekt @@ -29,7 +35,6 @@ LoginButton: HomePage: mostRecentTrack: Neueste Fahrt - noPublicTracks: Es gibt noch keine öffentlichen Fahrten. <1>Lade die erste hoch! Stats: title: Statistik @@ -43,3 +48,17 @@ Stats: thisMonth: Dieser Monat thisYear: Dieses Jahr allTime: Immer + +TracksPage: + titlePublic: Öffentliche Fahrten + titleUser: Meine Fahrten + noPublicTracks: Es gibt noch keine öffentlichen Fahrten. <1>Lade die erste hoch! + createdBy: Erstellt von <1>{{author}} am <1>{{date}} + upload: Hochladen + + processing: + created: Nicht verarbeitet + queued: Verarbeitung in Warteschlage + processing: Verarbeite... + complete: Verarbeitet + error: Fehler bei Verarbeitung diff --git a/frontend/src/translations/en.yaml b/frontend/src/translations/en.yaml index 2b966a6..f67a96c 100644 --- a/frontend/src/translations/en.yaml +++ b/frontend/src/translations/en.yaml @@ -2,6 +2,12 @@ locales: en: English de: Deutsch +general: + loading: Loading + unnamedTrack: Unnamed track + public: Public + private: Private + App: footer: aboutTheProject: About the project @@ -33,7 +39,6 @@ LoginButton: HomePage: mostRecentTrack: Most recent track - noPublicTracks: No public tracks yet. <1>Upload the first! Stats: title: Statistics @@ -47,3 +52,17 @@ Stats: thisMonth: This month thisYear: This year allTime: All time + +TracksPage: + titlePublic: Public tracks + titleUser: My tracks + noPublicTracks: No public tracks yet. <1>Upload the first! + createdBy: Created by <1>{author} on <1>{date} + upload: Upload + + processing: + created: Not processed + queued: Processing queued + processing: Processing... + complete: Processed + error: Error while processing