🌐(frontend) refactor device i18n keys for reusability across contexts

Update localization keys for device toggling and selection to be more
generic, enabling translation sharing between join and room contexts.

Eliminates duplicate translations and creates consistent messaging for
device interactions regardless of application context.
This commit is contained in:
lebaudantoine
2025-08-22 00:58:24 +02:00
committed by aleb_the_flash
parent 6f3339fbdc
commit a49893696b
8 changed files with 46 additions and 48 deletions

View File

@@ -23,7 +23,7 @@ export const AudioDevicesControl = ({
hideMenu, hideMenu,
...props ...props
}: AudioDevicesControlProps) => { }: AudioDevicesControlProps) => {
const { t } = useTranslation('rooms', { keyPrefix: 'join' }) const { t } = useTranslation('rooms', { keyPrefix: 'selectDevice' })
const { const {
userChoices: { audioDeviceId, audioOutputDeviceId }, userChoices: { audioDeviceId, audioOutputDeviceId },
@@ -44,8 +44,9 @@ export const AudioDevicesControl = ({
...props, ...props,
}) })
const cannotUseDevice = useCannotUseDevice('audioinput') const kind = 'audioinput'
const selectLabel = t('audioinput.choose') const cannotUseDevice = useCannotUseDevice(kind)
const selectLabel = t(`${kind}.choose`)
return ( return (
<div <div
@@ -56,7 +57,7 @@ export const AudioDevicesControl = ({
> >
<ToggleDevice <ToggleDevice
{...trackProps} {...trackProps}
kind="audioinput" kind={kind}
toggle={trackProps.toggle as () => Promise<void>} toggle={trackProps.toggle as () => Promise<void>}
toggleButtonProps={{ toggleButtonProps={{
...(hideMenu ...(hideMenu
@@ -95,7 +96,7 @@ export const AudioDevicesControl = ({
> >
<SelectDevice <SelectDevice
context="room" context="room"
kind="audioinput" kind={kind}
id={audioDeviceId} id={audioDeviceId}
onSubmit={saveAudioInputDeviceId} onSubmit={saveAudioInputDeviceId}
/> />

View File

@@ -29,7 +29,7 @@ const SelectDevicePermissions = <T extends string | number>({
onSubmit, onSubmit,
...props ...props
}: SelectDevicePermissionsProps<T>) => { }: SelectDevicePermissionsProps<T>) => {
const { t } = useTranslation('rooms', { keyPrefix: 'join' }) const { t } = useTranslation('rooms', { keyPrefix: 'selectDevice' })
const deviceIcons = useDeviceIcons(kind) const deviceIcons = useDeviceIcons(kind)
@@ -66,11 +66,7 @@ const SelectDevicePermissions = <T extends string | number>({
isDisabled={items.length === 0} isDisabled={items.length === 0}
items={items} items={items}
iconComponent={deviceIcons.select} iconComponent={deviceIcons.select}
placeholder={ placeholder={items.length === 0 ? t('loading') : t('select')}
items.length === 0
? t('selectDevice.loading')
: t('selectDevice.select')
}
selectedKey={id || activeDeviceId} selectedKey={id || activeDeviceId}
onSelectionChange={(key) => { onSelectionChange={(key) => {
onSubmit?.(key as string) onSubmit?.(key as string)
@@ -87,7 +83,7 @@ export const SelectDevice = ({
kind, kind,
context = 'join', context = 'join',
}: SelectDeviceProps) => { }: SelectDeviceProps) => {
const { t } = useTranslation('rooms', { keyPrefix: 'join' }) const { t } = useTranslation('rooms', { keyPrefix: 'selectDevice' })
const contextProps = useMemo<SelectDeviceContext>(() => { const contextProps = useMemo<SelectDeviceContext>(() => {
if (context == 'room') { if (context == 'room') {
@@ -106,7 +102,7 @@ export const SelectDevice = ({
label="" label=""
isDisabled={true} isDisabled={true}
items={[]} items={[]}
placeholder={t('selectDevice.permissionsNeeded')} placeholder={t('permissionsNeeded')}
iconComponent={deviceIcons.select} iconComponent={deviceIcons.select}
{...contextProps} {...contextProps}
/> />

View File

@@ -43,7 +43,7 @@ export const ToggleDevice = <T extends ToggleSource>({
context = 'room', context = 'room',
...props ...props
}: ToggleDeviceProps<T>) => { }: ToggleDeviceProps<T>) => {
const { t } = useTranslation('rooms', { keyPrefix: 'join' }) const { t } = useTranslation('rooms', { keyPrefix: 'selectDevice' })
const { variant, errorVariant, toggleButtonProps } = const { variant, errorVariant, toggleButtonProps } =
useMemo<ToggleDeviceStyleProps>(() => { useMemo<ToggleDeviceStyleProps>(() => {
@@ -89,7 +89,7 @@ export const ToggleDevice = <T extends ToggleSource>({
const toggleLabel = useMemo(() => { const toggleLabel = useMemo(() => {
const label = t(enabled ? 'disable' : 'enable', { const label = t(enabled ? 'disable' : 'enable', {
keyPrefix: `join.${kind}`, keyPrefix: `selectDevice.${kind}`,
}) })
return deviceShortcut ? appendShortcutLabel(label, deviceShortcut) : label return deviceShortcut ? appendShortcutLabel(label, deviceShortcut) : label
}, [enabled, kind, deviceShortcut, t]) }, [enabled, kind, deviceShortcut, t])

View File

@@ -24,7 +24,7 @@ export const VideoDeviceControl = ({
hideMenu, hideMenu,
...props ...props
}: VideoDeviceControlProps) => { }: VideoDeviceControlProps) => {
const { t } = useTranslation('rooms', { keyPrefix: 'join' }) const { t } = useTranslation('rooms', { keyPrefix: 'selectDevice' })
const { userChoices, saveVideoInputDeviceId, saveVideoInputEnabled } = const { userChoices, saveVideoInputDeviceId, saveVideoInputEnabled } =
usePersistentUserChoices() usePersistentUserChoices()
@@ -41,7 +41,8 @@ export const VideoDeviceControl = ({
...props, ...props,
}) })
const cannotUseDevice = useCannotUseDevice('videoinput') const kind = 'videoinput'
const cannotUseDevice = useCannotUseDevice(kind)
const toggle = () => { const toggle = () => {
/** /**
@@ -70,7 +71,7 @@ export const VideoDeviceControl = ({
} as VideoCaptureOptions) } as VideoCaptureOptions)
} }
const selectLabel = t('videoinput.choose') const selectLabel = t(`${kind}.choose`)
return ( return (
<div <div
@@ -81,7 +82,7 @@ export const VideoDeviceControl = ({
> >
<ToggleDevice <ToggleDevice
{...trackProps} {...trackProps}
kind="videoinput" kind={kind}
toggle={toggle} toggle={toggle}
toggleButtonProps={{ toggleButtonProps={{
...(hideMenu ...(hideMenu
@@ -120,7 +121,7 @@ export const VideoDeviceControl = ({
> >
<SelectDevice <SelectDevice
context="room" context="room"
kind="videoinput" kind={kind}
id={userChoices.videoDeviceId} id={userChoices.videoDeviceId}
onSubmit={saveVideoInputDeviceId} onSubmit={saveVideoInputDeviceId}
/> />

View File

@@ -7,12 +7,10 @@
"home": "Zur Startseite zurückkehren", "home": "Zur Startseite zurückkehren",
"back": "Dem Meeting erneut beitreten" "back": "Dem Meeting erneut beitreten"
}, },
"join": { "selectDevice": {
"selectDevice": { "loading": "Laden…",
"loading": "Laden…", "select": "Wählen Sie einen Wert",
"select": "Wählen Sie einen Wert", "permissionsNeeded": "Genehmigung erforderlich",
"permissionsNeeded": "Genehmigung erforderlich"
},
"videoinput": { "videoinput": {
"choose": "Kamera auswählen", "choose": "Kamera auswählen",
"permissionsNeeded": "Kamera auswählen - genehmigung erforderlich", "permissionsNeeded": "Kamera auswählen - genehmigung erforderlich",
@@ -31,7 +29,9 @@
"audiooutput": { "audiooutput": {
"choose": "Lautsprecher auswählen", "choose": "Lautsprecher auswählen",
"permissionsNeeded": "Lautsprecher auswählen - genehmigung erforderlich" "permissionsNeeded": "Lautsprecher auswählen - genehmigung erforderlich"
}, }
},
"join": {
"effects": { "effects": {
"description": "Effekte anwenden", "description": "Effekte anwenden",
"title": "Effekte", "title": "Effekte",

View File

@@ -7,12 +7,10 @@
"home": "Return to home", "home": "Return to home",
"back": "Rejoin the meeting" "back": "Rejoin the meeting"
}, },
"join": { "selectDevice": {
"selectDevice": { "loading": "Loading…",
"loading": "Loading…", "select": "Select a value",
"select": "Select a value", "permissionsNeeded": "Permission needed",
"permissionsNeeded": "Permission needed"
},
"videoinput": { "videoinput": {
"choose": "Select camera", "choose": "Select camera",
"permissionsNeeded": "Select camera - permission needed", "permissionsNeeded": "Select camera - permission needed",
@@ -31,7 +29,9 @@
"audiooutput": { "audiooutput": {
"choose": "Select speaker", "choose": "Select speaker",
"permissionsNeeded": "Select speaker - permission needed" "permissionsNeeded": "Select speaker - permission needed"
}, }
},
"join": {
"effects": { "effects": {
"description": "Apply effects", "description": "Apply effects",
"title": "Effects", "title": "Effects",

View File

@@ -7,12 +7,10 @@
"home": "Retourner à l'accueil", "home": "Retourner à l'accueil",
"back": "Réintégrer la réunion" "back": "Réintégrer la réunion"
}, },
"join": { "selectDevice": {
"selectDevice": { "loading": "Chargement…",
"loading": "Chargement…", "select": "Sélectionnez une valeur",
"select": "Sélectionnez une valeur", "permissionsNeeded": "Autorisations nécessaires",
"permissionsNeeded": "Autorisations nécessaires"
},
"videoinput": { "videoinput": {
"choose": "Choisir la webcam", "choose": "Choisir la webcam",
"permissionsNeeded": "Choisir la webcam - autorisations nécessaires", "permissionsNeeded": "Choisir la webcam - autorisations nécessaires",
@@ -31,7 +29,9 @@
"audiooutput": { "audiooutput": {
"choose": "Choisir le haut-parleur", "choose": "Choisir le haut-parleur",
"permissionsNeeded": "Choisir le haut-parleur - autorisations nécessaires" "permissionsNeeded": "Choisir le haut-parleur - autorisations nécessaires"
}, }
},
"join": {
"heading": "Rejoindre la réunion ?", "heading": "Rejoindre la réunion ?",
"effects": { "effects": {
"description": "Effets d'arrière plan", "description": "Effets d'arrière plan",

View File

@@ -7,12 +7,10 @@
"home": "Keer terug naar het hoofdscherm", "home": "Keer terug naar het hoofdscherm",
"back": "Sluit weer bij de vergadering aan" "back": "Sluit weer bij de vergadering aan"
}, },
"join": { "selectDevice": {
"selectDevice": { "loading": "Bezig met laden…",
"loading": "Bezig met laden…", "select": "Selecteer een waarde",
"select": "Selecteer een waarde", "permissionsNeeded": "Toestemming vereist",
"permissionsNeeded": "Toestemming vereist"
},
"videoinput": { "videoinput": {
"choose": "Selecteer camera", "choose": "Selecteer camera",
"permissionsNeeded": "Selecteer camera - Toestemming vereist", "permissionsNeeded": "Selecteer camera - Toestemming vereist",
@@ -31,7 +29,9 @@
"audiooutput": { "audiooutput": {
"choose": "Selecteer luidspreker", "choose": "Selecteer luidspreker",
"permissionsNeeded": "Selecteer luidspreker - Toestemming vereist" "permissionsNeeded": "Selecteer luidspreker - Toestemming vereist"
}, }
},
"join": {
"effects": { "effects": {
"description": "Pas effecten toe", "description": "Pas effecten toe",
"title": "Effecten", "title": "Effecten",