@@ -7,13 +7,10 @@ import OT, {
77 ExceptionEvent ,
88 PublisherProperties ,
99} from '@vonage/client-sdk-video' ;
10+ import { useTranslation } from 'react-i18next' ;
1011import usePublisherQuality , { NetworkQuality } from '../usePublisherQuality/usePublisherQuality' ;
1112import usePublisherOptions from '../usePublisherOptions' ;
1213import useSessionContext from '../../../hooks/useSessionContext' ;
13- import { PUBLISHING_BLOCKED_CAPTION } from '../../../utils/constants' ;
14- import getAccessDeniedError , {
15- PublishingErrorType ,
16- } from '../../../utils/getAccessDeniedError/getAccessDeniedError' ;
1714import applyBackgroundFilter from '../../../utils/backgroundFilter/applyBackgroundFilter/applyBackgroundFilter' ;
1815
1916type PublisherStreamCreatedEvent = Event < 'streamCreated' , Publisher > & {
@@ -29,6 +26,11 @@ type DeviceAccessStatus = {
2926 camera : boolean | undefined ;
3027} ;
3128
29+ type PublishingErrorType = {
30+ header : string ;
31+ caption : string ;
32+ } | null ;
33+
3234export type AccessDeniedEvent = Event < 'accessDenied' , Publisher > & {
3335 message ?: string ;
3436} ;
@@ -72,6 +74,7 @@ export type PublisherContextType = {
7274 * @returns {PublisherContextType } the publisher context
7375 */
7476const usePublisher = ( ) : PublisherContextType => {
77+ const { t } = useTranslation ( ) ;
7578 const [ publisherVideoElement , setPublisherVideoElement ] = useState <
7679 HTMLVideoElement | HTMLObjectElement
7780 > ( ) ;
@@ -96,10 +99,13 @@ const usePublisher = (): PublisherContextType => {
9699 useEffect ( ( ) => {
97100 if ( deviceAccess ?. microphone === false || deviceAccess ?. camera === false ) {
98101 const device = deviceAccess . camera ? 'Microphone' : 'Camera' ;
99- const accessDeniedError = getAccessDeniedError ( device ) ;
102+ const accessDeniedError = {
103+ header : t ( 'publishingErrors.accessDenied.title' , { device } ) ,
104+ caption : t ( 'publishingErrors.accessDenied.message' , { device : device . toLowerCase ( ) } ) ,
105+ } ;
100106 setPublishingError ( accessDeniedError ) ;
101107 }
102- } , [ deviceAccess ] ) ;
108+ } , [ deviceAccess , t ] ) ;
103109
104110 useEffect ( ( ) => {
105111 if ( ! publisherOptions ) {
@@ -232,8 +238,8 @@ const usePublisher = (): PublisherContextType => {
232238
233239 if ( publishAttempt === 3 ) {
234240 const publishingBlocked : PublishingErrorType = {
235- header : 'Difficulties joining room' ,
236- caption : PUBLISHING_BLOCKED_CAPTION ,
241+ header : t ( 'publishingErrors.blocked.title' ) ,
242+ caption : t ( 'publishingErrors.blocked.message' ) ,
237243 } ;
238244 setPublishingError ( publishingBlocked ) ;
239245 setIsPublishingToSession ( false ) ;
0 commit comments