Skip to content

Commit

Permalink
chore: translation
Browse files Browse the repository at this point in the history
  • Loading branch information
leinelissen committed Jul 25, 2024
1 parent 0cd6d5d commit 065515c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
6 changes: 5 additions & 1 deletion src/localisation/lang/en/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,9 @@
"delete": "Delete",
"cancel": "Cancel",
"disc": "Disc",
"lyrics": "Lyrics"
"lyrics": "Lyrics",
"direct-play": "Direct play",
"transcoded": "Transcoded",
"khz": "kHz",
"kbps": "kbps"
}
6 changes: 5 additions & 1 deletion src/localisation/lang/nl/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,9 @@
"sleep-timer": "Slaaptimer",
"delete": "Verwijder",
"cancel": "Annuleer",
"disc": "Schijf"
"disc": "Schijf",
"direct-play": "Direct afgespeeld",
"transcoded": "Getranscodeerd",
"khz": "kHz",
"kbps": "kbps"
}
6 changes: 5 additions & 1 deletion src/localisation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,8 @@ export type LocaleKeys = 'play-next'
| 'delete'
| 'cancel'
| 'disc'
| 'lyrics';
| 'lyrics'
| 'direct-play'
| 'transcoded'
| 'khz'
| 'kbps'
31 changes: 20 additions & 11 deletions src/screens/modals/Player/components/MediaInformation.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Text } from '@/components/Typography';
import { useTypedSelector } from '@/store';
import useCurrentTrack from '@/utility/useCurrentTrack';
import React from 'react-native';
import WaveformIcon from '@/assets/icons/waveform.svg';
import useDefaultStyles from '@/components/Colors';
import styled, { css } from 'styled-components/native';
import { useMemo } from 'react';
import { t } from '@/localisation';

const Container = styled.View`
flex-direction: row;
gap: 8px;
margin-top: 8px;
margin-top: 12px;
margin-bottom: 16px;
`;

Expand All @@ -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() {
const styles = useDefaultStyles();
const { track } = useCurrentTrack();
const { entities } = useTypedSelector((state) => state.music.tracks);
const { track, albumTrack } = useCurrentTrack();

if (!track) {
const mediaStream = useMemo(() => (
albumTrack?.MediaStreams?.find((d) => d.Type === 'Audio')
), [albumTrack]);

if (!albumTrack || !track) {
return null;
}

const albumTrack = entities[track.backendId];
const mediaStream = albumTrack.MediaStreams?.find((d) => d.Type === 'Audio');

return (
<Container>
<WaveformIcon fill={styles.icon.color} height={16} width={16} />
<Info>
<Label numberOfLines={1} overflow>
{track.isDirectPlay ? 'Direct play' : 'Transcoded'}
{track.isDirectPlay ? t('direct-play') : t('transcoded')}
</Label>
<Label numberOfLines={1} overflow>
{track.isDirectPlay
Expand All @@ -58,9 +63,13 @@ export default function MediaInformation() {
{mediaStream && (
<>
<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>
{(mediaStream.SampleRate / 1000).toFixed(1)}{'kHz'}
{(mediaStream.SampleRate / 1000).toFixed(1)}
{t('khz')}
</Label>
</>
)}
Expand Down

0 comments on commit 065515c

Please sign in to comment.