Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(subtitles): rework feature (#12484)

Calinteodorba4784f149fc
diff --git a/react/features/conference/components/native/Conference.js b/react/features/conference/components/native/Conference.js
index f922b24c35..802b3e2a02 100644
--- a/react/features/conference/components/native/Conference.js
+++ b/react/features/conference/components/native/Conference.js
@@ -38,7 +38,7 @@ import { navigate }
import { shouldEnableAutoKnock } from '../../../mobile/navigation/functions';
import { screen } from '../../../mobile/navigation/routes';
import { setPictureInPictureEnabled } from '../../../mobile/picture-in-picture/functions';
-import Captions from '../../../subtitles/components/Captions.native';
+import Captions from '../../../subtitles/components/native/Captions';
import { setToolboxVisible } from '../../../toolbox/actions';
import Toolbox from '../../../toolbox/components/native/Toolbox';
import { isToolboxVisible } from '../../../toolbox/functions';
diff --git a/react/features/large-video/components/LargeVideo.web.tsx b/react/features/large-video/components/LargeVideo.web.tsx
index ebb2adf870..9ba269a6f1 100644
--- a/react/features/large-video/components/LargeVideo.web.tsx
+++ b/react/features/large-video/components/LargeVideo.web.tsx
@@ -14,7 +14,7 @@ import StageParticipantNameLabel from '../../display-name/components/web/StagePa
import { FILMSTRIP_BREAKPOINT } from '../../filmstrip/constants';
import { getVerticalViewMaxWidth, isFilmstripResizable } from '../../filmstrip/functions.web';
import SharedVideo from '../../shared-video/components/web/SharedVideo';
-import Captions from '../../subtitles/components/Captions.web';
+import Captions from '../../subtitles/components/web/Captions';
import { setTileView } from '../../video-layout/actions.web';
import Whiteboard from '../../whiteboard/components/web/Whiteboard';
import { isWhiteboardEnabled } from '../../whiteboard/functions';
diff --git a/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx b/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx
index e72cc4d76e..3711f49b7b 100644
--- a/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx
+++ b/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx
@@ -37,6 +37,9 @@ import SecurityDialog
import SpeakerStats
// @ts-ignore
from '../../../../../speaker-stats/components/native/SpeakerStats';
+import LanguageSelectorDialog
+// @ts-ignore
+ from '../../../../../subtitles/components/native/LanguageSelectorDialog';
// @ts-ignore
import { screen } from '../../../routes';
import {
@@ -54,7 +57,8 @@ import {
securityScreenOptions,
settingsNavigationContainerScreenOptions,
sharedDocumentScreenOptions,
- speakerStatsScreenOptions
+ speakerStatsScreenOptions,
+ subtitlesScreenOptions
// @ts-ignore
} from '../../../screenOptions';
// @ts-ignore
@@ -191,6 +195,13 @@ const ConferenceNavigationContainer = () => {
...carmodeScreenOptions,
title: t('carmode.labels.title')
}} />
+ <ConferenceStack.Screen
+ component = { LanguageSelectorDialog }
+ name = { screen.conference.subtitles }
+ options = {{
+ ...subtitlesScreenOptions,
+ title: t('transcribing.subtitles')
+ }} />
</ConferenceStack.Navigator>
</NavigationContainer>
);
diff --git a/react/features/mobile/navigation/routes.ts b/react/features/mobile/navigation/routes.ts
index 9bff38864c..f6b3d71df4 100644
--- a/react/features/mobile/navigation/routes.ts
+++ b/react/features/mobile/navigation/routes.ts
@@ -30,7 +30,8 @@ export const screen = {
participants: 'Participants',
gifsMenu: 'GIPHY',
invite: 'Invite',
- sharedDocument: 'Shared document'
+ sharedDocument: 'Shared document',
+ subtitles: 'Subtitles'
},
lobby: {
root: 'Lobby root',
diff --git a/react/features/mobile/navigation/screenOptions.ts b/react/features/mobile/navigation/screenOptions.ts
index 9ec626360c..c197e10043 100644
--- a/react/features/mobile/navigation/screenOptions.ts
+++ b/react/features/mobile/navigation/screenOptions.ts
@@ -134,6 +134,11 @@ export const recordingScreenOptions = presentationScreenOptions;
*/
export const liveStreamScreenOptions = presentationScreenOptions;
+/**
+ * Screen options for subtitles modal.
+ */
+export const subtitlesScreenOptions = presentationScreenOptions;
+
/**
* Screen options for lobby modal.
*/
diff --git a/react/features/subtitles/actions.web.ts b/react/features/subtitles/actions.web.ts
index 0e6f101854..52a57c6341 100644
--- a/react/features/subtitles/actions.web.ts
+++ b/react/features/subtitles/actions.web.ts
@@ -1,7 +1,7 @@
import { IStore } from '../app/types';
import { toggleDialog } from '../base/dialog/actions';
-import LanguageSelectorDialogWeb from './components/LanguageSelectorDialog.web';
+import LanguageSelectorDialog from './components/web/LanguageSelectorDialog';
export * from './actions.any';
@@ -14,6 +14,6 @@ export * from './actions.any';
*/
export function toggleLanguageSelectorDialog() {
return function(dispatch: IStore['dispatch']) {
- dispatch(toggleDialog(LanguageSelectorDialogWeb));
+ dispatch(toggleDialog(LanguageSelectorDialog));
};
}
diff --git a/react/features/subtitles/components/AbstractCaptions.tsx b/react/features/subtitles/components/AbstractCaptions.tsx
index 8da07872fc..a4f5794059 100644
--- a/react/features/subtitles/components/AbstractCaptions.tsx
+++ b/react/features/subtitles/components/AbstractCaptions.tsx
@@ -1,11 +1,12 @@
-import React, { Component } from 'react';
+import React, { Component, ReactElement } from 'react';
import { IReduxState } from '../../app/types';
+
/**
* {@code AbstractCaptions} Properties.
*/
-export type AbstractCaptionsProps = {
+export interface IAbstractCaptionsProps {
/**
* Whether local participant is requesting to see subtitles.
@@ -17,23 +18,22 @@ export type AbstractCaptionsProps = {
* Mapped by id just to have the keys for convenience during the rendering
* process.
*/
- _transcripts?: Map<string, string>;
-};
+ _transcripts: Map<string, string>;
+}
/**
* Abstract React {@code Component} which can display speech-to-text results
* from Jigasi as subtitles.
*/
-export class AbstractCaptions<P extends AbstractCaptionsProps>
- extends Component<P> {
+export class AbstractCaptions<P extends IAbstractCaptionsProps> extends Component<P> {
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
- * @returns {React$Element}
+ * @returns {ReactElement}
*/
- render() {
+ render(): any {
const { _requestingSubtitles, _transcripts } = this.props;
if (!_requestingSubtitles || !_transcripts || !_transcripts.size) {
@@ -42,10 +42,12 @@ export class AbstractCaptions<P extends AbstractCaptionsProps>
const paragraphs = [];
+ // @ts-ignore
for (const [ id, text ] of _transcripts ?? []) {
paragraphs.push(this._renderParagraph(id, text));
}
+ // @ts-ignore
return this._renderSubtitlesContainer(paragraphs);
}
@@ -58,7 +60,7 @@ export class AbstractCaptions<P extends AbstractCaptionsProps>
* @param {string} _text - Subtitles text formatted with the participant's
* name.
* @protected
- * @returns {React$Element} - The React element which displays the text.
+ * @returns {ReactElement} - The React element which displays the text.
*/
_renderParagraph(_id: string, _text: string) {
return <></>;
@@ -68,12 +70,12 @@ export class AbstractCaptions<P extends AbstractCaptionsProps>
* Renders the subtitles container.
*
* @abstract
- * @param {Array<React$Element>} _el - An array of elements created
+ * @param {Array<ReactElement>} _el - An array of elements created
* for each subtitle using the {@link _renderParagraph} method.
* @protected
- * @returns {React$Element} - The subtitles container.
+ * @returns {ReactElement} - The subtitles container.
*/
- _renderSubtitlesContainer(_el: Array<React.ReactElement>) {
+ _renderSubtitlesContainer(_el: Array<ReactElement>) {
return <></>;
}
}
@@ -129,7 +131,7 @@ export function _abstractMapStateToProps(state: IReduxState) {
return {
_requestingSubtitles,
- // avoid rerenders by setting to props new empty Map instances.
+ // avoid re-renders by setting to prop new empty Map instances.
_transcripts: transcripts.size === 0 ? undefined : transcripts
};
}
diff --git a/react/features/subtitles/components/AbstractClosedCaptionButton.ts b/react/features/subtitles/components/AbstractClosedCaptionButton.tsx
similarity index 98%
rename from react/features/subtitles/components/AbstractClosedCaptionButton.ts
rename to react/features/subtitles/components/AbstractClosedCaptionButton.tsx
index 26d541d461..a079857084 100644
--- a/react/features/subtitles/components/AbstractClosedCaptionButton.ts
+++ b/react/features/subtitles/components/AbstractClosedCaptionButton.tsx
@@ -1,9 +1,12 @@
+/* eslint-disable lines-around-comment */
+
import { createToolbarEvent } from '../../analytics/AnalyticsEvents';
import { sendAnalytics } from '../../analytics/functions';
import { IReduxState } from '../../app/types';
import { MEET_FEATURES } from '../../base/jwt/constants';
import { isLocalParticipantModerator } from '../../base/participants/functions';
import AbstractButton, { IProps as AbstractButtonProps } from '../../base/toolbox/components/AbstractButton';
+// @ts-ignore
import { maybeShowPremiumFeatureDialog } from '../../jaas/actions';
export interface IAbstractProps extends AbstractButtonProps {
diff --git a/react/features/subtitles/components/AbstractLanguageSelectorDialog.tsx b/react/features/subtitles/components/AbstractLanguageSelectorDialog.tsx
new file mode 100644
index 0000000000..b376f7629e
--- /dev/null
+++ b/react/features/subtitles/components/AbstractLanguageSelectorDialog.tsx
@@ -0,0 +1,82 @@
+import React, { ComponentType, useCallback, useEffect, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { useDispatch, useSelector } from 'react-redux';
+
+import { IReduxState } from '../../app/types';
+import {
+ TRANSLATION_LANGUAGES,
+ TRANSLATION_LANGUAGES_HEAD
+} from '../../base/i18n/i18next';
+import { setRequestingSubtitles, updateTranslationLanguage } from '../actions.any';
+
+
+export interface IAbstractLanguageSelectorDialogProps {
+ dispatch: Function;
+ language: string;
+ listItems: Array<any>;
+ onLanguageSelected: (e: string) => void;
+ subtitles: string;
+ t: Function;
+}
+
+
+/**
+ * Higher Order Component taking in a concrete LanguageSelector component and
+ * augmenting it with state/behavior common to both web and native implementations.
+ *
+ * @param {React.Component} Component - The concrete component.
+ * @returns {React.Component}
+ */
+const AbstractLanguageSelectorDialog = (Component: ComponentType<IAbstractLanguageSelectorDialogProps>) => () => {
+ const dispatch = useDispatch();
+ const { t } = useTranslation();
+ const off = 'transcribing.subtitlesOff';
+
+ const [ subtitles, setSubtiles ] = useState(off);
+ const language = useSelector((state: IReduxState) => state['features/subtitles']._language);
+
+ const transcription = useSelector((state: IReduxState) => state['features/base/config'].transcription);
+ const translationLanguagesHead = transcription?.translationLanguagesHead ?? TRANSLATION_LANGUAGES_HEAD;
+ const languagesHead = translationLanguagesHead?.map((lang: string) => `translation-languages:${lang}`);
+
+ // The off and the head languages are always on the top of the list. But once you are selecting
+ // a language from the translationLanguages, that language is moved under the fixedItems list,
+ // until a new languages is selected. FixedItems keep their positions.
+ const fixedItems = [ off, ...languagesHead ];
+ const translationLanguages = transcription?.translationLanguages ?? TRANSLATION_LANGUAGES;
+ const languages = translationLanguages
+ .map((lang: string) => `translation-languages:${lang}`)
+ .filter((lang: string) => !(lang === subtitles || languagesHead?.includes(lang)));
+ const listItems = (fixedItems?.includes(subtitles)
+ ? [ ...fixedItems, ...languages ]
+ : [ ...fixedItems, subtitles, ...languages ])
+ .map((lang, index) => {
+ return {
+ id: lang + index,
+ lang,
+ selected: lang === subtitles
+ };
+ });
+
+ useEffect(() => {
+ language ? setSubtiles(language) : setSubtiles(off);
+ }, []);
+
+ const onLanguageSelected = useCallback((e: string) => {
+ setSubtiles(e);
+ dispatch(updateTranslationLanguage(e));
+ dispatch(setRequestingSubtitles(e !== off));
+ }, [ language ]);
+
+ return (
+ <Component
+ dispatch = { dispatch }
+ language = { language }
+ listItems = { listItems }
+ onLanguageSelected = { onLanguageSelected }
+ subtitles = { subtitles }
+ t = { t } />
+ );
+};
+
+export default AbstractLanguageSelectorDialog;
diff --git a/react/features/subtitles/components/ClosedCaptionButton.native.js b/react/features/subtitles/components/ClosedCaptionButton.native.js
deleted file mode 100644
index 3b093d0b6d..0000000000
--- a/react/features/subtitles/components/ClosedCaptionButton.native.js
+++ /dev/null
@@ -1,45 +0,0 @@
-// @flow
-
-import { connect } from 'react-redux';
-
-import { CLOSE_CAPTIONS_ENABLED } from '../../base/flags/constants';
-import { getFeatureFlag } from '../../base/flags/functions';
-import { translate } from '../../base/i18n/functions';
-import { IconSubtitles } from '../../base/icons/svg';
-
-import {
- AbstractClosedCaptionButton,
- _abstractMapStateToProps
-} from './AbstractClosedCaptionButton';
-
-/**
- * A button which starts/stops the transcriptions.
- */
-class ClosedCaptionButton
- extends AbstractClosedCaptionButton {
- accessibilityLabel = 'toolbar.accessibilityLabel.cc';
- icon = IconSubtitles;
- label = 'transcribing.start';
- toggledLabel = 'transcribing.stop';
-}
-
-/**
- * Maps (parts of) the redux state to the associated props for this component.
- *
- * @param {Object} state - The redux state.
- * @param {Object} ownProps - The properties explicitly passed to the component
- * instance.
- * @private
- * @returns {Props}
- */
-export function mapStateToProps(state: Object, ownProps: Object) {
- const enabled = getFeatureFlag(state, CLOSE_CAPTIONS_ENABLED, true);
- const abstractProps = _abstractMapStateToProps(state, ownProps);
-
- return {
- ...abstractProps,
- visible: abstractProps.visible && enabled
- };
-}
-
-export default translate(connect(mapStateToProps)(ClosedCaptionButton));
diff --git a/react/features/subtitles/components/LanguageSelectorDialog.web.tsx b/react/features/subtitles/components/LanguageSelectorDialog.web.tsx
deleted file mode 100644
index 6db36d8850..0000000000
--- a/react/features/subtitles/components/LanguageSelectorDialog.web.tsx
+++ /dev/null
@@ -1,141 +0,0 @@
-import i18next from 'i18next';
-import React, { useCallback, useEffect, useState } from 'react';
-import { WithTranslation } from 'react-i18next';
-import { connect, useDispatch } from 'react-redux';
-import { makeStyles } from 'tss-react/mui';
-
-import { IReduxState } from '../../app/types';
-import { translate, translateToHTML } from '../../base/i18n/functions';
-import { TRANSLATION_LANGUAGES, TRANSLATION_LANGUAGES_HEAD } from '../../base/i18n/i18next';
-import Dialog from '../../base/ui/components/web/Dialog';
-import { openSettingsDialog } from '../../settings/actions';
-import { SETTINGS_TABS } from '../../settings/constants';
-import { setRequestingSubtitles, toggleLanguageSelectorDialog, updateTranslationLanguage } from '../actions';
-
-import LanguageList from './LanguageList.web';
-
-
-interface ILanguageSelectorDialogProps extends WithTranslation {
- _language: string;
- _translationLanguages: Array<string>;
- _translationLanguagesHead: Array<string>;
-}
-
-const useStyles = makeStyles()(theme => {
- return {
- paragraphWrapper: {
- fontSize: 14,
- margin: '10px 0px',
- color: theme.palette.text01
- },
- spanWrapper: {
- fontWeight: 700,
- cursor: 'pointer',
- color: theme.palette.link01,
- '&:hover': {
- backgroundColor: theme.palette.ui04,
- color: theme.palette.link01Hover
- }
- }
- };
-});
-
-/**
- * Component that renders the subtitle language selector dialog.
- *
- * @returns {React$Element<any>}
- */
-const LanguageSelectorDialog = ({
- t,
- _language,
- _translationLanguages,
- _translationLanguagesHead
-}: ILanguageSelectorDialogProps) => {
- const { classes: styles } = useStyles();
- const dispatch = useDispatch();
- const off = 'transcribing.subtitlesOff';
- const [ language, setLanguage ] = useState(off);
-
- const languagesHead = _translationLanguagesHead.map((lang: string) => `translation-languages:${lang}`);
-
- // The off and the head languages are always on the top of the list. But once you are selecting
- // a language from the translationLanguages, that language is moved under the fixedItems list,
- // until a new languages is selected. FixedItems keep their positions.
- const fixedItems = [ off, ...languagesHead ];
- const languages = _translationLanguages
- .map((lang: string) => `translation-languages:${lang}`)
- .filter((lang: string) => !(lang === language || languagesHead.includes(lang)));
-
- const listItems = (fixedItems.includes(language)
- ? [ ...fixedItems, ...languages ]
- : [ ...fixedItems, language, ...languages ])
- .map((lang, index) => {
- return {
- id: lang + index,
- lang,
- selected: lang === language
- };
- });
-
- useEffect(() => {
- _language ? setLanguage(_language) : setLanguage(off);
- }, []);
-
- const onLanguageSelected = useCallback((e: string) => {
- setLanguage(e);
- dispatch(updateTranslationLanguage(e));
- dispatch(setRequestingSubtitles(e !== off));
- dispatch(toggleLanguageSelectorDialog());
- }, [ _language ]);
-
- const onSourceLanguageClick = useCallback(() => {
- dispatch(openSettingsDialog(SETTINGS_TABS.PROFILE, false));
- }, []);
-
- return (
- <Dialog
- cancel = {{ hidden: true }}
- ok = {{ hidden: true }}
- titleKey = 'transcribing.subtitles'>
- <p className = { styles.paragraphWrapper } >
- {
- translateToHTML(t, 'transcribing.sourceLanguageDesc', {
- 'sourceLanguage': t(`languages:${i18next.language}`).toLowerCase()
- })
- }<span
- className = { styles.spanWrapper }
- onClick = { onSourceLanguageClick }>{t('transcribing.sourceLanguageHere')}.</span>
- </p>
- <LanguageList
- items = { listItems }
- onLanguageSelected = { onLanguageSelected }
- selectedLanguage = { language } />
- </Dialog>
- );
-};
-
-/**
- * Maps (parts of) the Redux state to the associated props for the
- * {@code LanguageSelectorDialog} component.
- *
- * @param {Object} state - The Redux state.
- * @private
- * @returns {Props}
- */
-function mapStateToProps(state: IReduxState) {
- const { conference } = state['features/base/conference'];
- const { _language } = state['features/subtitles'];
- const { transcription } = state['features/base/config'];
-
- const languages = transcription?.translationLanguages ?? TRANSLATION_LANGUAGES;
- const languagesHead = transcription?.translationLanguagesHead ?? TRANSLATION_LANGUAGES_HEAD;
-
- return {
- _conference: conference,
- _language,
- _translationLanguages: languages,
- _translationLanguagesHead: languagesHead
- };
-}
-
-export default translate(connect(mapStateToProps)(LanguageSelectorDialog));
diff --git a/react/features/subtitles/components/Captions.native.js b/react/features/subtitles/components/native/Captions.tsx
similarity index 50%
rename from react/features/subtitles/components/Captions.native.js
rename to react/features/subtitles/components/native/Captions.tsx
index caefc5d854..81d5de374c 100644
--- a/react/features/subtitles/components/Captions.native.js
+++ b/react/features/subtitles/components/native/Captions.tsx
@@ -1,32 +1,35 @@
-// @flow
+/* eslint-disable lines-around-comment */
-import React from 'react';
+import React, { ReactElement } from 'react';
+import { GestureResponderEvent, StyleProp } from 'react-native';
import { connect } from 'react-redux';
-import Container from '../../base/react/components/native/Container';
-import Text from '../../base/react/components/native/Text';
-
+// @ts-ignore
+import Container from '../../../base/react/components/native/Container';
+// @ts-ignore
+import Text from '../../../base/react/components/native/Text';
import {
AbstractCaptions,
- type AbstractCaptionsProps,
+ type IAbstractCaptionsProps,
_abstractMapStateToProps
-} from './AbstractCaptions';
+} from '../AbstractCaptions';
+
+// @ts-ignore
import styles from './styles';
+
/**
* The type of the React {@code Component} props of {@link Captions}.
*/
-type Props = AbstractCaptionsProps & {
- onPress: Function
-};
+interface IProps extends IAbstractCaptionsProps {
+ onPress: (event: GestureResponderEvent) => void;
+}
/**
* React {@code Component} which can display speech-to-text results from
* Jigasi as subtitles.
*/
-class Captions
- extends AbstractCaptions<Props> {
-
+class Captions extends AbstractCaptions<IProps> {
/**
* Renders the transcription text.
*
@@ -35,14 +38,14 @@ class Captions
* @param {string} text - Subtitles text formatted with the participant's
* name.
* @protected
- * @returns {React$Element} - The React element which displays the text.
+ * @returns {ReactElement} - The React element which displays the text.
*/
- _renderParagraph(id: string, text: string): React$Element<*> {
+ _renderParagraph(id: string, text: string): ReactElement {
return (
<Text
key = { id }
onPress = { this.props.onPress }
- style = { styles.subtitle } >
+ style = { styles.captionsSubtitles as StyleProp<Object> } >
{ text }
</Text>
);
@@ -51,19 +54,19 @@ class Captions
/**
* Renders the subtitles container.
*
- * @param {Array<React$Element>} paragraphs - An array of elements created
+ * @param {Array<ReactElement>} paragraphs - An array of elements created
* for each subtitle using the {@link _renderParagraph} method.
* @protected
- * @returns {React$Element} - The subtitles container.
+ * @returns {ReactElement} - The subtitles container.
*/
- _renderSubtitlesContainer(
- paragraphs: Array<React$Element<*>>): React$Element<*> {
+ _renderSubtitlesContainer(paragraphs: Array<ReactElement>): ReactElement {
return (
- <Container style = { styles.subtitlesContainer } >
+ <Container style = { styles.captionsSubtitlesContainer } >
{ paragraphs }
</Container>
);
}
}
+// @ts-ignore
export default connect(_abstractMapStateToProps)(Captions);
diff --git a/react/features/subtitles/components/native/ClosedCaptionButton.tsx b/react/features/subtitles/components/native/ClosedCaptionButton.tsx
new file mode 100644
index 0000000000..470b998a9b
--- /dev/null
+++ b/react/features/subtitles/components/native/ClosedCaptionButton.tsx
@@ -0,0 +1,65 @@
+/* eslint-disable lines-around-comment */
+
+import { connect } from 'react-redux';
+
+import { IReduxState } from '../../../app/types';
+import { CLOSE_CAPTIONS_ENABLED } from '../../../base/flags/constants';
+import { getFeatureFlag } from '../../../base/flags/functions';
+import { translate } from '../../../base/i18n/functions';
+import { IconSubtitles } from '../../../base/icons/svg';
+import { navigate }
+// @ts-ignore
+ from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
+// @ts-ignore
+import { screen } from '../../../mobile/navigation/routes';
+import {
+ AbstractClosedCaptionButton,
+ IAbstractProps,
+ _abstractMapStateToProps
+} from '../AbstractClosedCaptionButton';
+
+
+/**
+ * A button which starts/stops the transcriptions.
+ */
+class ClosedCaptionButton
+ extends AbstractClosedCaptionButton {
+ accessibilityLabel = 'toolbar.accessibilityLabel.cc';
+ icon = IconSubtitles;
+ label = 'toolbar.startSubtitles';
+ labelProps = {
+ language: this.props.t(this.props._language),
+ languages: this.props.t(this.props.languages ?? ''),
+ languagesHead: this.props.t(this.props.languagesHead ?? '')
+ };
+
+ /**
+ * Toggle language selection dialog.
+ *
+ * @returns {void}
+ */
+ _handleClickOpenLanguageSelector() {
+ navigate(screen.conference.subtitles);
+ }
+}
+
+/**
+ * Maps (parts of) the redux state to the associated props for this component.
+ *
+ * @param {Object} state - The redux state.
+ * @param {Object} ownProps - The properties explicitly passed to the component
+ * instance.
+ * @private
+ * @returns {Props}
+ */
+export function mapStateToProps(state: IReduxState, ownProps: IAbstractProps) {
+ const enabled = getFeatureFlag(state, CLOSE_CAPTIONS_ENABLED, true);
+ const abstractProps = _abstractMapStateToProps(state, ownProps);
+
+ return {
+ ...abstractProps,
+ visible: abstractProps.visible && enabled
+ };
+}
+
+export default translate(connect(mapStateToProps)(ClosedCaptionButton));
diff --git a/react/features/subtitles/components/native/LanguageList.tsx b/react/features/subtitles/components/native/LanguageList.tsx
new file mode 100644
index 0000000000..b9d0d8eb9d
--- /dev/null
+++ b/react/features/subtitles/components/native/LanguageList.tsx
@@ -0,0 +1,48 @@
+/* eslint-disable lines-around-comment */
+
+import React from 'react';
+import { ScrollView } from 'react-native';
+
+import LanguageListItem from './LanguageListItem';
+// @ts-ignore
+import styles from './styles';
+
+interface ILanguageListProps {
+ items: Array<ILanguageItem>;
+ onLanguageSelected: (lang: string) => void;
+ selectedLanguage: string;
+}
+
+
+interface ILanguageItem {
+ id: string;
+ lang: string;
+ selected: boolean;
+}
+
+/**
+ * Component that renders the security options dialog.
+ *
+ * @returns {React$Element<any>}
+ */
+const LanguageList = ({ items, onLanguageSelected }: ILanguageListProps) => {
+
+ const listItems = items?.map(item => (
+ <LanguageListItem
+ key = { item.id }
+ // @ts-ignore
+ lang = { item.lang }
+ onLanguageSelected = { onLanguageSelected }
+ selected = { item.selected } />
+ ));
+
+ return (
+ <ScrollView
+ bounces = { false }
+ style = { styles.itemsContainer }>
+ { listItems }
+ </ScrollView>
+ );
+};
+
+export default LanguageList;
diff --git a/react/features/subtitles/components/native/LanguageListItem.tsx b/react/features/subtitles/components/native/LanguageListItem.tsx
new file mode 100644
index 0000000000..2dd6f6d529
--- /dev/null
+++ b/react/features/subtitles/components/native/LanguageListItem.tsx
@@ -0,0 +1,70 @@
+/* eslint-disable lines-around-comment */
+
+import React, { useCallback } from 'react';
+import { WithTranslation } from 'react-i18next';
+import { StyleProp, TouchableHighlight, View, ViewStyle } from 'react-native';
+import { Text } from 'react-native-paper';
+
+import { translate } from '../../../base/i18n/functions';
+import Icon from '../../../base/icons/components/Icon';
+import { IconCheck } from '../../../base/icons/svg';
+
+// @ts-ignore
+import styles from './styles';
+
+
+interface ILanguageListItemProps extends WithTranslation {
+
+ /**
+ * Language string.
+ */
+ lang: string;
+
+ /**
+ * Callback for language selection.
+ */
+ onLanguageSelected: (lang: string) => void;
+
+ /**
+ * If language item is selected or not.
+ */
+ selected?: boolean;
+}
+
+/**
+ * Component that renders the language list item.
+ *
+ * @returns {React$Element<any>}
+ */
+
+const LanguageListItem = ({ t, lang, selected, onLanguageSelected
+}: ILanguageListItemProps) => {
+
+ const onLanguageSelectedWrapper
+ = useCallback(() => onLanguageSelected(lang), [ lang ]);
+
+ return (
+ <View style = { styles.languageItemWrapper as StyleProp<ViewStyle> }>
+ <View style = { styles.iconWrapper }>
+ {
+ selected
+ && <Icon
+ size = { 20 }
+ src = { IconCheck } />
+ }
+ </View>
+ <TouchableHighlight
+ onPress = { onLanguageSelectedWrapper }
+ underlayColor = { 'transparent' } >
+ <Text
+ style = { [
+ styles.languageItemText,
+ selected && styles.activeLanguageItemText ] }>
+ { t(lang) }
+ </Text>
+ </TouchableHighlight>
+ </View>
+ );
+};
+
+export default translate(LanguageListItem);
diff --git a/react/features/subtitles/components/native/LanguageSelectorDialog.tsx b/react/features/subtitles/components/native/LanguageSelectorDialog.tsx
new file mode 100644
index 0000000000..a942d30a1e
--- /dev/null
+++ b/react/features/subtitles/components/native/LanguageSelectorDialog.tsx
@@ -0,0 +1,45 @@
+/* eslint-disable lines-around-comment */
+
+import React, { useCallback } from 'react';
+
+// @ts-ignore
+import JitsiScreen from '../../../base/modal/components/JitsiScreen';
+import { goBack }
+// @ts-ignore
+ from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
+import AbstractLanguageSelectorDialog, {
+ IAbstractLanguageSelectorDialogProps
+} from '../AbstractLanguageSelectorDialog';
+
+import LanguageList from './LanguageList';
+// @ts-ignore
+import styles from './styles';
+
+
+const LanguageSelectorDialog = (props: IAbstractLanguageSelectorDialogProps) => {
+ const { language, listItems, onLanguageSelected, subtitles } = props;
+
+ const onSelected = useCallback((e: string) => {
+ onLanguageSelected(e);
+ goBack();
+ }, [ language ]);
+
+ return (
+ // @ts-ignore
+ <JitsiScreen
+ disableForcedKeyboardDismiss = { true }
+ style = { styles.subtitlesContainer }>
+ <LanguageList
+ items = { listItems }
+ onLanguageSelected = { onSelected }
+ selectedLanguage = { subtitles } />
+ </JitsiScreen>
+ );
+};
+
+/*
+ * We apply AbstractLanguageSelector to fill in the AbstractProps common
+ * to both the web and native implementations.
+ */
+// eslint-disable-next-line new-cap
+export default AbstractLanguageSelectorDialog(LanguageSelectorDialog);
diff --git a/react/features/subtitles/components/native/styles.js b/react/features/subtitles/components/native/styles.js
new file mode 100644
index 0000000000..e3b6725ba3
--- /dev/null
+++ b/react/features/subtitles/components/native/styles.js
@@ -0,0 +1,63 @@
+import { BoxModel } from '../../../base/styles/components/styles/BoxModel';
+import {
+ ColorPalette
+} from '../../../base/styles/components/styles/ColorPalette';
+import BaseTheme from '../../../base/ui/components/BaseTheme.native';
+
+/**
+ * The styles of the React {@code Component}s of the feature subtitles.
+ */
+export default {
+ languageItemWrapper: {
+ alignItems: 'center',
+ display: 'flex',
+ flexDirection: 'row'
+ },
+
+ iconWrapper: {
+ width: 32
+ },
+
+ activeLanguageItemText: {
+ ...BaseTheme.typography.bodyShortBoldLarge
+ },
+
+ languageItemText: {
+ ...BaseTheme.typography.bodyShortRegularLarge,
+ color: BaseTheme.palette.text01,
+ marginLeft: BaseTheme.spacing[2],
+ marginVertical: BaseTheme.spacing[2]
+ },
+
+ subtitlesContainer: {
+ backgroundColor: BaseTheme.palette.ui01,
+ flex: 1
+ },
+
+ /**
+ * Style for subtitle paragraph.
+ */
+ captionsSubtitles: {
+ backgroundColor: ColorPalette.black,
+ borderRadius: BoxModel.margin / 4,
+ color: ColorPalette.white,
+ marginBottom: BoxModel.margin,
+ padding: BoxModel.padding / 2
+ },
+
+ /**
+ * Style for the subtitles container.
+ */
+ captionsSubtitlesContainer: {
+ alignItems: 'center',
+ flexDirection: 'column',
+ flexGrow: 0,
+ justifyContent: 'flex-end',
+ margin: BoxModel.margin
+ },
+
+ itemsContainer: {
+ marginHorizontal: BaseTheme.spacing[4],
+ marginVertical: BaseTheme.spacing[4]
+ }
+};
diff --git a/react/features/subtitles/components/styles.js b/react/features/subtitles/components/styles.js
deleted file mode 100644
index b889f3561e..0000000000
--- a/react/features/subtitles/components/styles.js
+++ /dev/null
@@ -1,33 +0,0 @@
-// @flow
-
-import { BoxModel } from '../../base/styles/components/styles/BoxModel';
-import { ColorPalette } from '../../base/styles/components/styles/ColorPalette';
-import { createStyleSheet } from '../../base/styles/functions.any';
-
-/**
- * The styles of the React {@code Component}s of the feature subtitles.
- */
-export default createStyleSheet({
-
- /**
- * Style for subtitle paragraph.
- */
- subtitle: {
- backgroundColor: ColorPalette.black,
- borderRadius: BoxModel.margin / 4,
- color: ColorPalette.white,
- marginBottom: BoxModel.margin,
- padding: BoxModel.padding / 2
- },
-
- /**
- * Style for the subtitles container.
- */
- subtitlesContainer: {
- alignItems: 'center',
- flexDirection: 'column',
- flexGrow: 0,
- justifyContent: 'flex-end',
- margin: BoxModel.margin
- }
-});
diff --git a/react/features/subtitles/components/Captions.web.tsx b/react/features/subtitles/components/web/Captions.tsx
similarity index 63%
rename from react/features/subtitles/components/Captions.web.tsx
rename to react/features/subtitles/components/web/Captions.tsx
index 737504d066..a69fdabfe6 100644
--- a/react/features/subtitles/components/Captions.web.tsx
+++ b/react/features/subtitles/components/web/Captions.tsx
@@ -1,23 +1,23 @@
-import React from 'react';
+import React, { ReactElement } from 'react';
import { connect } from 'react-redux';
-import { IReduxState } from '../../app/types';
-import { getLocalParticipant } from '../../base/participants/functions';
-import { getLargeVideoParticipant } from '../../large-video/functions';
-import { isLayoutTileView } from '../../video-layout/functions.web';
-
+import { IReduxState } from '../../../app/types';
+import { getLocalParticipant } from '../../../base/participants/functions';
+import { getLargeVideoParticipant } from '../../../large-video/functions';
+import { isLayoutTileView } from '../../../video-layout/functions.web';
import {
AbstractCaptions,
- type AbstractCaptionsProps,
+ type IAbstractCaptionsProps,
_abstractMapStateToProps
-} from './AbstractCaptions';
+} from '../AbstractCaptions';
+
-interface IProps extends AbstractCaptionsProps {
+interface IProps extends IAbstractCaptionsProps {
/**
* Whether the subtitles container is lifted above the invite box.
*/
- _isLifted: boolean;
+ _isLifted: boolean | undefined;
}
/**
@@ -34,9 +34,9 @@ class Captions extends AbstractCaptions<IProps> {
* @param {string} text - Subtitles text formatted with the participant's
* name.
* @protected
- * @returns {React$Element} - The React element which displays the text.
+ * @returns {ReactElement} - The React element which displays the text.
*/
- _renderParagraph(id: string, text: string) {
+ _renderParagraph(id: string, text: string): ReactElement {
return (
<p key = { id }>
<span>{ text }</span>
@@ -47,14 +47,15 @@ class Captions extends AbstractCaptions<IProps> {
/**
* Renders the subtitles container.
*
- * @param {Array<React$Element>} paragraphs - An array of elements created
+ * @param {Array<ReactElement>} paragraphs - An array of elements created
* for each subtitle using the {@link _renderParagraph} method.
* @protected
- * @returns {React$Element} - The subtitles container.
+ * @returns {ReactElement} - The subtitles container.
*/
- _renderSubtitlesContainer(paragraphs: Array<React.ReactElement>) {
-
- const className = this.props._isLifted ? 'transcription-subtitles lifted' : 'transcription-subtitles';
+ _renderSubtitlesContainer(paragraphs: Array<ReactElement>): ReactElement {
+ const className = this.props._isLifted
+ ? 'transcription-subtitles lifted'
+ : 'transcription-subtitles';
return (
<div className = { className } >
@@ -83,4 +84,5 @@ function mapStateToProps(state: IReduxState) {
};
}
+// @ts-ignore
export default connect(mapStateToProps)(Captions);
diff --git a/react/features/subtitles/components/ClosedCaptionButton.web.ts b/react/features/subtitles/components/web/ClosedCaptionButton.tsx
similarity index 80%
rename from react/features/subtitles/components/ClosedCaptionButton.web.ts
rename to react/features/subtitles/components/web/ClosedCaptionButton.tsx
index 7e27ec9cc4..99f5ee4abe 100644
--- a/react/features/subtitles/components/ClosedCaptionButton.web.ts
+++ b/react/features/subtitles/components/web/ClosedCaptionButton.tsx
@@ -1,13 +1,12 @@
import { connect } from 'react-redux';
-import { translate } from '../../base/i18n/functions';
-import { IconSubtitles } from '../../base/icons/svg';
-import { toggleLanguageSelectorDialog } from '../actions.web';
-
+import { translate } from '../../../base/i18n/functions';
+import { IconSubtitles } from '../../../base/icons/svg';
+import { toggleLanguageSelectorDialog } from '../../actions.web';
import {
AbstractClosedCaptionButton,
_abstractMapStateToProps
-} from './AbstractClosedCaptionButton';
+} from '../AbstractClosedCaptionButton';
/**
* A button which starts/stops the transcriptions.
diff --git a/react/features/subtitles/components/LanguageList.web.tsx b/react/features/subtitles/components/web/LanguageList.tsx
similarity index 73%
rename from react/features/subtitles/components/LanguageList.web.tsx
rename to react/features/subtitles/components/web/LanguageList.tsx
index 4167375344..8dbe525936 100644
--- a/react/features/subtitles/components/LanguageList.web.tsx
+++ b/react/features/subtitles/components/web/LanguageList.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import { makeStyles } from 'tss-react/mui';
-import LanguageListItem from './LanguageListItem.web';
+import LanguageListItem from './LanguageListItem';
interface ILanguageListProps {
items: Array<ILanguageItem>;
@@ -36,11 +36,13 @@ const LanguageList = ({
onLanguageSelected
}: ILanguageListProps) => {
const { classes: styles } = useStyles();
- const listItems = items.map(item => (<LanguageListItem
- key = { item.id }
- lang = { item.lang }
- onLanguageSelected = { onLanguageSelected }
- selected = { item.selected } />));
+ const listItems = items.map(item => (
+ <LanguageListItem
+ key = { item.id }
+ lang = { item.lang }
+ onLanguageSelected = { onLanguageSelected }
+ selected = { item.selected } />
+ ));
return (
<div className = { styles.itemsContainer }>{listItems}</div>
diff --git a/react/features/subtitles/components/LanguageListItem.web.tsx b/react/features/subtitles/components/web/LanguageListItem.tsx
similarity index 85%
rename from react/features/subtitles/components/LanguageListItem.web.tsx
rename to react/features/subtitles/components/web/LanguageListItem.tsx
index 185df380ee..4b9a7511ab 100644
--- a/react/features/subtitles/components/LanguageListItem.web.tsx
+++ b/react/features/subtitles/components/web/LanguageListItem.tsx
@@ -2,24 +2,24 @@ import React, { useCallback } from 'react';
import { WithTranslation } from 'react-i18next';
import { makeStyles } from 'tss-react/mui';
-import { translate } from '../../base/i18n/functions';
-import Icon from '../../base/icons/components/Icon';
-import { IconCheck } from '../../base/icons/svg';
+import { translate } from '../../../base/i18n/functions';
+import Icon from '../../../base/icons/components/Icon';
+import { IconCheck } from '../../../base/icons/svg';
interface ILanguageListItemProps extends WithTranslation {
/**
- * Whether or not the button should be full width.
+ * Language string.
*/
lang: string;
/**
- * Click callback.
+ * Callback for language selection.
*/
onLanguageSelected: (lang: string) => void;
/**
- * The id of the button.
+ * If language item is selected or not.
*/
selected?: boolean;
}
diff --git a/react/features/subtitles/components/web/LanguageSelectorDialog.tsx b/react/features/subtitles/components/web/LanguageSelectorDialog.tsx
new file mode 100644
index 0000000000..6a56a2e556
--- /dev/null
+++ b/react/features/subtitles/components/web/LanguageSelectorDialog.tsx
@@ -0,0 +1,78 @@
+import i18next from 'i18next';
+import React, { useCallback } from 'react';
+import { makeStyles } from 'tss-react/mui';
+
+import { translate, translateToHTML } from '../../../base/i18n/functions';
+import Dialog from '../../../base/ui/components/web/Dialog';
+import { openSettingsDialog } from '../../../settings/actions.web';
+import { SETTINGS_TABS } from '../../../settings/constants';
+import { toggleLanguageSelectorDialog } from '../../actions.web';
+import AbstractLanguageSelectorDialog, {
+ IAbstractLanguageSelectorDialogProps
+} from '../AbstractLanguageSelectorDialog';
+
+import LanguageList from './LanguageList';
+
+
+const useStyles = makeStyles()(theme => {
+ return {
+ paragraphWrapper: {
+ fontSize: 14,
+ margin: '10px 0px',
+ color: theme.palette.text01
+ },
+ spanWrapper: {
+ fontWeight: 700,
+ cursor: 'pointer',
+ color: theme.palette.link01,
+ '&:hover': {
+ backgroundColor: theme.palette.ui04,
+ color: theme.palette.link01Hover
+ }
+ }
+ };
+});
+
+
+const LanguageSelectorDialog = (props: IAbstractLanguageSelectorDialogProps) => {
+ const { dispatch, language, listItems, onLanguageSelected, subtitles, t } = props;
+
+ const { classes: styles } = useStyles();
+
+ const onSelected = useCallback((e: string) => {
+ onLanguageSelected(e);
+ dispatch(toggleLanguageSelectorDialog());
+ }, [ language ]);
+
+ const onSourceLanguageClick = useCallback(() => {
+ dispatch(openSettingsDialog(SETTINGS_TABS.PROFILE, false));
+ }, []);
+
+ return (
+ <Dialog
+ cancel = {{ hidden: true }}
+ ok = {{ hidden: true }}
+ titleKey = 'transcribing.subtitles'>
+ <p className = { styles.paragraphWrapper } >
+ {
+ translateToHTML(t, 'transcribing.sourceLanguageDesc', {
+ 'sourceLanguage': t(`languages:${i18next.language}`).toLowerCase()
+ })
+ }<span
+ className = { styles.spanWrapper }
+ onClick = { onSourceLanguageClick }>{t('transcribing.sourceLanguageHere')}.</span>
+ </p>
+ <LanguageList
+ items = { listItems }
+ onLanguageSelected = { onSelected }
+ selectedLanguage = { subtitles } />
+ </Dialog>
+ );
+};
+
+/*
+ * We apply AbstractLanguageSelector to fill in the AbstractProps common
+ * to both the web and native implementations.
+ */
+// eslint-disable-next-line new-cap
+export default translate(AbstractLanguageSelectorDialog(LanguageSelectorDialog));
diff --git a/react/features/subtitles/middleware.ts b/react/features/subtitles/middleware.ts
index 3365789864..7c58bb0ab6 100644
--- a/react/features/subtitles/middleware.ts
+++ b/react/features/subtitles/middleware.ts
@@ -11,7 +11,7 @@ import {
import {
removeTranscriptMessage,
updateTranscriptMessage
-} from './actions';
+} from './actions.any';
import logger from './logger';
/**
diff --git a/react/features/subtitles/reducer.ts b/react/features/subtitles/reducer.ts
index b7c93827e9..7a8934b820 100644
--- a/react/features/subtitles/reducer.ts
+++ b/react/features/subtitles/reducer.ts
@@ -24,7 +24,7 @@ interface ITranscriptMessage {
export interface ISubtitlesState {
_language: string;
_requestingSubtitles: boolean;
- _transcriptMessages: Map<string, ITranscriptMessage>;
+ _transcriptMessages: Map<string, ITranscriptMessage> | any;
}
/**
diff --git a/react/features/toolbox/components/native/OverflowMenu.js b/react/features/toolbox/components/native/OverflowMenu.js
index 73159fe3a1..7199821df2 100644
--- a/react/features/toolbox/components/native/OverflowMenu.js
+++ b/react/features/toolbox/components/native/OverflowMenu.js
@@ -18,7 +18,7 @@ import SecurityDialogButton
import SharedVideoButton from '../../../shared-video/components/native/SharedVideoButton';
import SpeakerStatsButton from '../../../speaker-stats/components/native/SpeakerStatsButton';
import { isSpeakerStatsDisabled } from '../../../speaker-stats/functions';
-import ClosedCaptionButton from '../../../subtitles/components/ClosedCaptionButton.native';
+import ClosedCaptionButton from '../../../subtitles/components/native/ClosedCaptionButton';
import TileViewButton from '../../../video-layout/components/TileViewButton';
import styles from '../../../video-menu/components/native/styles';
import { getMovableButtons } from '../../functions.native';
diff --git a/react/features/toolbox/components/web/Toolbox.tsx b/react/features/toolbox/components/web/Toolbox.tsx
index afaa471836..fe2a9989e3 100644
--- a/react/features/toolbox/components/web/Toolbox.tsx
+++ b/react/features/toolbox/components/web/Toolbox.tsx
@@ -73,7 +73,7 @@ import SettingsButton from '../../../settings/components/web/SettingsButton';
import SharedVideoButton from '../../../shared-video/components/web/SharedVideoButton';
import SpeakerStats from '../../../speaker-stats/components/web/SpeakerStats';
import SpeakerStatsButton from '../../../speaker-stats/components/web/SpeakerStatsButton';
-import ClosedCaptionButton from '../../../subtitles/components/ClosedCaptionButton.web';
+import ClosedCaptionButton from '../../../subtitles/components/web/ClosedCaptionButton';
import { toggleTileView } from '../../../video-layout/actions.web';
import TileViewButton from '../../../video-layout/components/TileViewButton';
import { shouldDisplayTileView } from '../../../video-layout/functions.web';