Fix translation interpolation

This commit is contained in:
Paul Bienkowski 2022-07-24 18:53:26 +02:00
parent 248f8b4a6f
commit 76943fb1f0
5 changed files with 21 additions and 16 deletions

View file

@ -213,7 +213,6 @@ const App = connect((state) => ({login: state.login}))(function App({login}) {
<List.Item> <List.Item>
<a href={config?.privacyPolicyUrl} target="_blank" rel="noreferrer"> <a href={config?.privacyPolicyUrl} target="_blank" rel="noreferrer">
{t('App.footer.privacyPolicy')} {t('App.footer.privacyPolicy')}
Privacy policy
</a> </a>
</List.Item> </List.Item>
<List.Item> <List.Item>

View file

@ -1,4 +1,5 @@
import {DateTime} from 'luxon' import {DateTime} from 'luxon'
import {useTranslation} from 'react-i18next'
export default function FormattedDate({date, relative = false}) { export default function FormattedDate({date, relative = false}) {
if (date == null) { if (date == null) {
@ -10,11 +11,15 @@ export default function FormattedDate({date, relative = false}) {
let str let str
const {i18n} = useTranslation()
const locale = i18n.language
if (relative) { if (relative) {
str = dateTime.toRelative() str = dateTime.setLocale(locale).toRelative()
} else { } else {
str = dateTime.toLocaleString(DateTime.DATETIME_MED) str = dateTime.setLocale(locale).toLocaleString(DateTime.DATETIME_MED)
} }
return <span title={dateTime.toISO()}>{str}</span> const iso = dateTime.toISO()
return <time dateTime={iso} title={iso}>{str}</time>
} }

View file

@ -9,7 +9,7 @@ import _ from 'lodash'
import {useTranslation, Trans as Translate} from 'react-i18next' import {useTranslation, Trans as Translate} from 'react-i18next'
import type {Track} from 'types' import type {Track} from 'types'
import {Avatar, Page, StripMarkdown} from 'components' import {Avatar, Page, StripMarkdown, FormattedDate} from 'components'
import api from 'api' import api from 'api'
import {useQueryParam} from 'query' import {useQueryParam} from 'query'
@ -104,9 +104,10 @@ export function TrackListItem({track, privateTracks = false}) {
{track.title || t('general.unnamedTrack')} {track.title || t('general.unnamedTrack')}
</Item.Header> </Item.Header>
<Item.Meta> <Item.Meta>
<Translate i18nKey="TracksPage.createdBy"> {privateTracks ? null : <span>{t('TracksPage.createdBy', {author: track.author.username})}</span>}
Created by <span style={{margin: 0}}>{{author: track.author.username}}</span> on <span style={{margin: 0}}>{{date: track.createdAt}}</span> <span>
</Translate> <FormattedDate date={track.createdAt} />
</span>
</Item.Meta> </Item.Meta>
<Item.Description> <Item.Description>
<StripMarkdown>{maxLength(track.description, 200)}</StripMarkdown> <StripMarkdown>{maxLength(track.description, 200)}</StripMarkdown>

View file

@ -20,7 +20,7 @@ App:
thisInstallation: Diese Installation thisInstallation: Diese Installation
privacyPolicy: Datenschutz privacyPolicy: Datenschutz
imprint: Impressum imprint: Impressum
version: Version v{apiVersion} version: Version v{{apiVersion}}
versionLoading: Version lädt... versionLoading: Version lädt...
changeLanguage: Sprache wechseln changeLanguage: Sprache wechseln
@ -57,7 +57,7 @@ TracksPage:
titlePublic: Öffentliche Fahrten titlePublic: Öffentliche Fahrten
titleUser: Meine Fahrten titleUser: Meine Fahrten
noPublicTracks: Es gibt noch keine öffentlichen Fahrten. <1>Lade die erste hoch!</1> noPublicTracks: Es gibt noch keine öffentlichen Fahrten. <1>Lade die erste hoch!</1>
createdBy: Erstellt von <1>{{author}}</1> am <1>{{date}}</1> createdBy: Erstellt von {{author}}
upload: Hochladen upload: Hochladen
processing: processing:
@ -93,7 +93,7 @@ ExportPage:
label: Geografischer Bereich label: Geografischer Bereich
UploadPage: UploadPage:
uploadProgress: Lade hoch {progress}% uploadProgress: Lade hoch {{progress}}%
processing: Verarbeiten... processing: Verarbeiten...
table: table:
@ -109,7 +109,7 @@ FileUploadField:
LoginRedirectPage: LoginRedirectPage:
loginError: Login error loginError: Login error
loginErrorText: "The login server reported: {error}" loginErrorText: "The login server reported: {{error}}"
loggingIn: Logging you in loggingIn: Logging you in
hangTight: Hang tight... hangTight: Hang tight...

View file

@ -24,7 +24,7 @@ App:
thisInstallation: This installation thisInstallation: This installation
privacyPolicy: Privacy policy privacyPolicy: Privacy policy
imprint: Imprint imprint: Imprint
version: Version v{apiVersion} version: Version v{{apiVersion}}
versionLoading: Fetching version... versionLoading: Fetching version...
changeLanguage: Change language changeLanguage: Change language
@ -61,7 +61,7 @@ TracksPage:
titlePublic: Public tracks titlePublic: Public tracks
titleUser: My tracks titleUser: My tracks
noPublicTracks: No public tracks yet. <1>Upload the first!</1> noPublicTracks: No public tracks yet. <1>Upload the first!</1>
createdBy: Created by <1>{author}</1> on <1>{date}</1> createdBy: Created by {{author}}
upload: Upload upload: Upload
processing: processing:
@ -98,7 +98,7 @@ ExportPage:
label: Bounding Box label: Bounding Box
UploadPage: UploadPage:
uploadProgress: Uploading {progress}% uploadProgress: Uploading {{progress}}%
processing: Processing... processing: Processing...
table: table:
@ -114,7 +114,7 @@ FileUploadField:
LoginRedirectPage: LoginRedirectPage:
loginError: Loginfehler loginError: Loginfehler
loginErrorText: "Der Login-Server meldet: {error}" loginErrorText: "Der Login-Server meldet: {{error}}"
loggingIn: Du wirst eingeloggt loggingIn: Du wirst eingeloggt
hangTight: Bitte warten... hangTight: Bitte warten...