diff --git a/frontend/src/components/Stats/index.tsx b/frontend/src/components/Stats/index.tsx
index b347f41..2c7abd3 100644
--- a/frontend/src/components/Stats/index.tsx
+++ b/frontend/src/components/Stats/index.tsx
@@ -5,6 +5,7 @@ import {useObservable} from 'rxjs-hooks'
import {of, from, concat, combineLatest} from 'rxjs'
import {map, switchMap, distinctUntilChanged} from 'rxjs/operators'
import {Duration, DateTime} from 'luxon'
+import {useTranslation} from 'react-i18next'
import api from 'api'
@@ -17,6 +18,7 @@ function formatDuration(seconds) {
}
export default function Stats({user = null}: {user?: null | string}) {
+ const {t} = useTranslation()
const [timeframe, setTimeframe] = useState('all_time')
const onClick = useCallback((_e, {name}) => setTimeframe(name), [setTimeframe])
@@ -63,35 +65,37 @@ export default function Stats({user = null}: {user?: null | string}) {
[timeframe, user]
)
+ const placeholder = t('Stats.placeholder')
+
return (
<>
- {user && 'My '}Statistics
+ {user ? t('Stats.titleUser') : t('Stats.title')}
- {stats ? `${Number(stats?.trackLength / 1000).toFixed(1)} km` : '...'}
- Total track length
+ {stats ? `${Number(stats?.trackLength / 1000).toFixed(1)} km` : placeholder}
+ {t('Stats.totalTrackLength')}
- {stats ? formatDuration(stats?.trackDuration) : '...'}
- Time recorded
+ {stats ? formatDuration(stats?.trackDuration) : placeholder}
+ {t('Stats.timeRecorded')}
- {stats?.numEvents ?? '...'}
- Events confirmed
+ {stats?.numEvents ?? placeholder}
+ {t('Stats.eventsConfirmed')}
{user ? (
- {stats?.trackCount ?? '...'}
- Tracks recorded
+ {stats?.trackCount ?? placeholder}
+ {t('Stats.tracksRecorded')}
) : (
- {stats?.userCount ?? '...'}
- Members joined
+ {stats?.userCount ?? placeholder}
+ {t('Stats.membersJoined')}
)}
@@ -99,13 +103,13 @@ export default function Stats({user = null}: {user?: null | string}) {
diff --git a/frontend/src/pages/HomePage.tsx b/frontend/src/pages/HomePage.tsx
index 1f6f3b8..e0184f7 100644
--- a/frontend/src/pages/HomePage.tsx
+++ b/frontend/src/pages/HomePage.tsx
@@ -4,7 +4,7 @@ import {Message, 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} from 'react-i18next'
+import {useTranslation, Trans as Translate} from 'react-i18next'
import api from 'api'
import {Stats, Page, Map} from 'components'
@@ -13,6 +13,8 @@ import {TrackListItem} from './TracksPage'
import styles from './HomePage.module.less'
function MostRecentTrack() {
+ const {t} = useTranslation()
+
const track: Track | null = useObservable(
() =>
of(null).pipe(
@@ -23,14 +25,15 @@ function MostRecentTrack() {
[]
)
- const {t} = useTranslation()
return (
<>
{t('HomePage.mostRecentTrack')}
{track === undefined ? (
- No public tracks yet. Upload the first!
+
+ No public tracks yet. Upload the first!
+
) : track ? (
diff --git a/frontend/src/translations/de.yaml b/frontend/src/translations/de.yaml
index a4cebdf..6389af1 100644
--- a/frontend/src/translations/de.yaml
+++ b/frontend/src/translations/de.yaml
@@ -1,6 +1,3 @@
-HomePage:
- mostRecentTrack: Neueste Aufzeichnung
-
App:
footer:
aboutTheProject: Über das Projekt
@@ -29,3 +26,20 @@ App:
LoginButton:
login: Anmelden
+
+HomePage:
+ mostRecentTrack: Neueste Fahrt
+ noPublicTracks: Es gibt noch keine öffentlichen Fahrten. <1>Lade die erste hoch!1>
+
+Stats:
+ title: Statistik
+ titleUser: Meine Statistik
+ placeholder: "..."
+ totalTrackLength: Gesamtfahrstrecke
+ timeRecorded: Aufzeichnungszeit
+ eventsConfirmed: Bestätigte Vorgänge
+ tracksRecorded: Aufgezeichnete Fahrten
+ membersJoined: Neue Mitglieder
+ thisMonth: Dieser Monat
+ thisYear: Dieses Jahr
+ allTime: Immer
diff --git a/frontend/src/translations/en.yaml b/frontend/src/translations/en.yaml
index d9fb333..2b966a6 100644
--- a/frontend/src/translations/en.yaml
+++ b/frontend/src/translations/en.yaml
@@ -1,6 +1,3 @@
-HomePage:
- mostRecentTrack: Most recent track
-
locales:
en: English
de: Deutsch
@@ -33,3 +30,20 @@ App:
LoginButton:
login: Login
+
+HomePage:
+ mostRecentTrack: Most recent track
+ noPublicTracks: No public tracks yet. <1>Upload the first!1>
+
+Stats:
+ title: Statistics
+ titleUser: My Statistic
+ placeholder: "..."
+ totalTrackLength: Total track length
+ timeRecorded: Time recorded
+ eventsConfirmed: Events confirmed
+ tracksRecorded: Tracks recorded
+ membersJoined: Members joined
+ thisMonth: This month
+ thisYear: This year
+ allTime: All time