Add react-i18next integration

This commit is contained in:
Paul Bienkowski 2022-07-24 17:06:44 +02:00 committed by gluap
parent cec3db5feb
commit 7ce6b66b75
No known key found for this signature in database
2 changed files with 16 additions and 13 deletions

View file

@ -227,7 +227,7 @@ const App = connect((state) => ({login: state.login}))(function App({login}) {
target="_blank"
rel="noreferrer"
>
{apiVersion ? t('App.footer.version', {apiVersion}) : t('App.footer.versionLoading')}
Version {apiVersion ? t('App.footer.version', {apiVersion}) : t('App.footer.versionLoading')}
</a>
</List.Item>
</List>

View file

@ -14,23 +14,26 @@ import styles from './HomePage.module.less'
function MostRecentTrack() {
const {t} = useTranslation()
const tracks: Track[] | null = useObservable(
const track: Track | null = useObservable(
() =>
of(null).pipe(
switchMap(() => from(api.fetch("/tracks?limit=3"))),
map((response) => response?.tracks)
switchMap(() => from(api.fetch('/tracks?limit=1'))),
map((response) => response?.tracks?.[0])
),
null,
[]
);
)
const {t} = useTranslation()
return (
<>
<Header as="h2">{t('HomePage.mostRecentTrack')}</Header>
<Loader active={track === null} />
{track === undefined ? (
<NoPublicTracksMessage />
) : track ? (
<Header as="h2">Most recent tracks</Header>
<Loader active={tracks === null} />
{tracks?.length === 0 ? (
<Message>
No public tracks yet. <Link to="/upload">Upload the first!</Link>
</Message>
) : tracks ? (
<Item.Group>
{tracks.map((track) => (
<TrackListItem key={track.id} track={track} />
@ -38,7 +41,7 @@ function MostRecentTrack() {
</Item.Group>
) : null}
</>
);
)
}
export default function HomePage() {
@ -48,13 +51,13 @@ export default function HomePage() {
<Grid.Row>
<Grid.Column width={8}>
<Stats />
<MostRecentTrack />
</Grid.Column>
<Grid.Column width={8}>
<MostRecentTrack />
<RegionStats />
</Grid.Column>
</Grid.Row>
</Grid>
</Page>
);
)
}