Fix i18n warning on empty string

This commit is contained in:
Alvaro 2023-02-21 10:44:31 -07:00 committed by GitHub
parent 5daa820e4e
commit b483d26488
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -60,7 +60,6 @@ export type DispatchProps = Readonly<{
export type Props = OwnProps & DispatchProps;
type ButtonProps = {
i18n: LocalizerType;
variant: 'play' | 'playback-rate';
mod?: string;
label: string;
@ -129,7 +128,6 @@ const timeToText = (time: number): string => {
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
function ButtonInner(props, ref) {
const {
i18n,
variant,
mod,
label,
@ -189,8 +187,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
onMouseUp={() => setIsDown(false)}
onMouseLeave={() => setIsDown(false)}
tabIndex={0}
// eslint-disable-next-line local-rules/valid-i18n-keys
aria-label={i18n(label)}
aria-label={label}
>
{children}
</button>
@ -517,7 +514,6 @@ export function MessageAudio(props: Props): JSX.Element {
button = (
<Button
ref={buttonRef}
i18n={i18n}
variant="play"
mod="download"
label="MessageAudio--download"
@ -530,10 +526,11 @@ export function MessageAudio(props: Props): JSX.Element {
button = (
<Button
ref={buttonRef}
i18n={i18n}
variant="play"
mod={isPlaying ? 'pause' : 'play'}
label={isPlaying ? 'MessageAudio--pause' : 'MessageAudio--play'}
label={
isPlaying ? i18n('MessageAudio--pause') : i18n('MessageAudio--play')
}
animateClick={false}
onClick={toggleIsPlaying}
/>
@ -575,8 +572,7 @@ export function MessageAudio(props: Props): JSX.Element {
/>
<Button
variant="playback-rate"
i18n={i18n}
label={(active && playbackRateLabels[active.playbackRate]) ?? ''}
label={playbackRateLabels[active?.playbackRate ?? 1]}
visible={isPlaying && (!played || !isPlayedDotVisible)}
onClick={() => {
if (active) {
@ -587,7 +583,7 @@ export function MessageAudio(props: Props): JSX.Element {
}
}}
>
{active && playbackRateLabels[active.playbackRate]}
{playbackRateLabels[active?.playbackRate ?? 1]}
</Button>
</div>