Calling device selection: Localize 'default'

This commit is contained in:
Josh Perez 2020-08-27 21:11:00 -04:00 committed by Josh Perez
parent 99f545b685
commit 036ce0a6d9
3 changed files with 46 additions and 2 deletions

View file

@ -2746,6 +2746,10 @@
"message": "No devices available", "message": "No devices available",
"description": "Message for when there are no available devices to select for input/output audio or video" "description": "Message for when there are no available devices to select for input/output audio or video"
}, },
"callingDeviceSelection__select--default": {
"message": "Default",
"description": "Shown when the device is the default device"
},
"muteNotificationsTitle": { "muteNotificationsTitle": {
"message": "Mute notifications", "message": "Mute notifications",
"description": "Label for the mute notifications drop-down selector" "description": "Label for the mute notifications drop-down selector"

View file

@ -72,6 +72,37 @@ stories.add('Some Devices', () => {
return <CallingDeviceSelection {...props} />; return <CallingDeviceSelection {...props} />;
}); });
stories.add('Default Devices', () => {
const availableSpeakers = [
{
name: 'default (Headphones)',
index: 0,
uniqueId: 'Default',
i18nKey: 'default_communication_device',
},
];
const selectedSpeaker = availableSpeakers[0];
const availableMicrophones = [
{
name: 'DefAuLt (Headphones)',
index: 0,
uniqueId: 'Default',
i18nKey: 'default_communication_device',
},
];
const selectedMicrophone = availableMicrophones[0];
const props = createProps({
availableMicrophones,
availableSpeakers,
selectedMicrophone,
selectedSpeaker,
});
return <CallingDeviceSelection {...props} />;
});
stories.add('All Devices', () => { stories.add('All Devices', () => {
const availableSpeakers = [ const availableSpeakers = [
{ {

View file

@ -15,6 +15,15 @@ export type Props = MediaDeviceSettings & {
toggleSettings: () => void; toggleSettings: () => void;
}; };
function localizeDefault(i18n: LocalizerType, deviceLabel: string): string {
return deviceLabel.toLowerCase().startsWith('default')
? deviceLabel.replace(
/default/i,
i18n('callingDeviceSelection__select--default')
)
: deviceLabel;
}
function renderAudioOptions( function renderAudioOptions(
devices: Array<AudioDevice>, devices: Array<AudioDevice>,
i18n: LocalizerType, i18n: LocalizerType,
@ -39,7 +48,7 @@ function renderAudioOptions(
key={device.index} key={device.index}
value={device.index} value={device.index}
> >
{device.name} {localizeDefault(i18n, device.name)}
</option> </option>
); );
})} })}
@ -71,7 +80,7 @@ function renderVideoOptions(
key={device.deviceId} key={device.deviceId}
value={device.deviceId} value={device.deviceId}
> >
{device.label} {localizeDefault(i18n, device.label)}
</option> </option>
); );
})} })}