chore: translation

This commit is contained in:
Lei Nelissen
2024-07-25 17:12:23 +02:00
parent 0cd6d5d05c
commit 065515c25b
4 changed files with 35 additions and 14 deletions

View File

@@ -76,5 +76,9 @@
"delete": "Delete", "delete": "Delete",
"cancel": "Cancel", "cancel": "Cancel",
"disc": "Disc", "disc": "Disc",
"lyrics": "Lyrics" "lyrics": "Lyrics",
"direct-play": "Direct play",
"transcoded": "Transcoded",
"khz": "kHz",
"kbps": "kbps"
} }

View File

@@ -75,5 +75,9 @@
"sleep-timer": "Slaaptimer", "sleep-timer": "Slaaptimer",
"delete": "Verwijder", "delete": "Verwijder",
"cancel": "Annuleer", "cancel": "Annuleer",
"disc": "Schijf" "disc": "Schijf",
"direct-play": "Direct afgespeeld",
"transcoded": "Getranscodeerd",
"khz": "kHz",
"kbps": "kbps"
} }

View File

@@ -75,4 +75,8 @@ export type LocaleKeys = 'play-next'
| 'delete' | 'delete'
| 'cancel' | 'cancel'
| 'disc' | 'disc'
| 'lyrics'; | 'lyrics'
| 'direct-play'
| 'transcoded'
| 'khz'
| 'kbps'

View File

@@ -1,15 +1,16 @@
import { Text } from '@/components/Typography'; import { Text } from '@/components/Typography';
import { useTypedSelector } from '@/store';
import useCurrentTrack from '@/utility/useCurrentTrack'; import useCurrentTrack from '@/utility/useCurrentTrack';
import React from 'react-native'; import React from 'react-native';
import WaveformIcon from '@/assets/icons/waveform.svg'; import WaveformIcon from '@/assets/icons/waveform.svg';
import useDefaultStyles from '@/components/Colors'; import useDefaultStyles from '@/components/Colors';
import styled, { css } from 'styled-components/native'; import styled, { css } from 'styled-components/native';
import { useMemo } from 'react';
import { t } from '@/localisation';
const Container = styled.View` const Container = styled.View`
flex-direction: row; flex-direction: row;
gap: 8px; gap: 8px;
margin-top: 8px; margin-top: 12px;
margin-bottom: 16px; margin-bottom: 16px;
`; `;
@@ -30,24 +31,28 @@ const Label = styled(Text)<{ overflow?: boolean }>`
`} `}
`; `;
/**
* This component displays information about the media that is being played
* back, such as the bitrate, sample rate, codec and whether it's transcoded.
*/
export default function MediaInformation() { export default function MediaInformation() {
const styles = useDefaultStyles(); const styles = useDefaultStyles();
const { track } = useCurrentTrack(); const { track, albumTrack } = useCurrentTrack();
const { entities } = useTypedSelector((state) => state.music.tracks);
if (!track) { const mediaStream = useMemo(() => (
albumTrack?.MediaStreams?.find((d) => d.Type === 'Audio')
), [albumTrack]);
if (!albumTrack || !track) {
return null; return null;
} }
const albumTrack = entities[track.backendId];
const mediaStream = albumTrack.MediaStreams?.find((d) => d.Type === 'Audio');
return ( return (
<Container> <Container>
<WaveformIcon fill={styles.icon.color} height={16} width={16} /> <WaveformIcon fill={styles.icon.color} height={16} width={16} />
<Info> <Info>
<Label numberOfLines={1} overflow> <Label numberOfLines={1} overflow>
{track.isDirectPlay ? 'Direct play' : 'Transcoded'} {track.isDirectPlay ? t('direct-play') : t('transcoded')}
</Label> </Label>
<Label numberOfLines={1} overflow> <Label numberOfLines={1} overflow>
{track.isDirectPlay {track.isDirectPlay
@@ -58,9 +63,13 @@ export default function MediaInformation() {
{mediaStream && ( {mediaStream && (
<> <>
<Label numberOfLines={1} overflow> <Label numberOfLines={1} overflow>
{((track.isDirectPlay ? mediaStream.BitRate : track.bitRate) / 1000).toFixed(0)}{'kbps'}</Label> {((track.isDirectPlay ? mediaStream.BitRate : track.bitRate) / 1000)
.toFixed(0)}
{t('kbps')}
</Label>
<Label numberOfLines={1} overflow> <Label numberOfLines={1} overflow>
{(mediaStream.SampleRate / 1000).toFixed(1)}{'kHz'} {(mediaStream.SampleRate / 1000).toFixed(1)}
{t('khz')}
</Label> </Label>
</> </>
)} )}