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): add transcription.translationEnabled config flag

Boris Grozevd8011c775f05
diff --git a/config.js b/config.js
index 8a6600695f..bc5ecc8600 100644
--- a/config.js
+++ b/config.js
@@ -493,6 +493,9 @@ var config = {
// // Translation languages.
// // Available languages can be found in
// // ./lang/translation-languages.json.
+ // // Whether to enable translation (language selection) UI. Defaults to true.
+ // translationEnabled: true,
+
// translationLanguages: ['en', 'es', 'fr', 'ro'],
// // Important languages to show on the top of the language list.
diff --git a/react/features/base/config/configType.ts b/react/features/base/config/configType.ts
index 16ae3ee79d..46c0d722dd 100644
--- a/react/features/base/config/configType.ts
+++ b/react/features/base/config/configType.ts
@@ -728,6 +728,7 @@ export interface IConfig {
enabled?: boolean;
preferredLanguage?: string;
renderTranscriptDetails?: boolean;
+ translationEnabled?: boolean;
translationLanguages?: Array<string>;
translationLanguagesHead?: Array<string>;
useAppLanguage?: boolean;
diff --git a/react/features/subtitles/components/AbstractLanguageSelectorDialog.tsx b/react/features/subtitles/components/AbstractLanguageSelectorDialog.tsx
index 895e09345e..5a3039fcb2 100644
--- a/react/features/subtitles/components/AbstractLanguageSelectorDialog.tsx
+++ b/react/features/subtitles/components/AbstractLanguageSelectorDialog.tsx
@@ -6,7 +6,7 @@ import { IReduxState, IStore } from '../../app/types';
import { openDialog } from '../../base/dialog/actions';
import { StartRecordingDialog } from '../../recording/components/Recording/index';
import { setRequestingSubtitles } from '../actions.any';
-import { getAvailableSubtitlesLanguages } from '../functions.any';
+import { getAvailableSubtitlesLanguages, isTranslationEnabled } from '../functions.any';
export interface IAbstractLanguageSelectorDialogProps {
dispatch: IStore['dispatch'];
@@ -46,6 +46,7 @@ const AbstractLanguageSelectorDialog = (Component: ComponentType<IAbstractLangua
};
});
const { conference } = useSelector((state: IReduxState) => state['features/base/conference']);
+ const translationEnabled = useSelector(isTranslationEnabled);
const onLanguageSelected = useCallback((value: string) => {
const _selectedLanguage = value === noLanguageLabel ? null : value;
@@ -61,6 +62,10 @@ const AbstractLanguageSelectorDialog = (Component: ComponentType<IAbstractLangua
}
}, [ conference, language ]);
+ if (!translationEnabled) {
+ return null;
+ }
+
return (
<Component
dispatch = { dispatch }
diff --git a/react/features/subtitles/components/web/LanguageSelector.tsx b/react/features/subtitles/components/web/LanguageSelector.tsx
index 9ea9d1bc58..eb28082f41 100644
--- a/react/features/subtitles/components/web/LanguageSelector.tsx
+++ b/react/features/subtitles/components/web/LanguageSelector.tsx
@@ -6,7 +6,7 @@ import { makeStyles } from 'tss-react/mui';
import { IReduxState } from '../../../app/types';
import Select from '../../../base/ui/components/web/Select';
import { setRequestingSubtitles } from '../../actions.any';
-import { getAvailableSubtitlesLanguages } from '../../functions.any';
+import { getAvailableSubtitlesLanguages, isTranslationEnabled } from '../../functions.any';
/**
* The styles for the LanguageSelector component.
@@ -52,9 +52,9 @@ function LanguageSelector() {
));
const isAsyncTranscriptionEnabled = useSelector((state: IReduxState) =>
state['features/base/conference'].conference?.getMetadataHandler()?.getMetadata()?.asyncTranscription);
+ const translationEnabled = useSelector(isTranslationEnabled);
- // Hide the "Translate to" option when asyncTranscription is enabled
- if (isAsyncTranscriptionEnabled) {
+ if (isAsyncTranscriptionEnabled || !translationEnabled) {
return null;
}
diff --git a/react/features/subtitles/functions.any.ts b/react/features/subtitles/functions.any.ts
index 7bdd019481..da639c66a6 100644
--- a/react/features/subtitles/functions.any.ts
+++ b/react/features/subtitles/functions.any.ts
@@ -47,6 +47,18 @@ export function getAvailableSubtitlesLanguages(stateful: IStateful, selectedLang
}
+/**
+ * Determines if translation (language selection) is enabled.
+ *
+ * @param {IReduxState} state - The Redux state object.
+ * @returns {boolean} A boolean indicating whether translation is enabled.
+ */
+export function isTranslationEnabled(state: IReduxState) {
+ const { transcription } = state['features/base/config'];
+
+ return transcription?.translationEnabled !== false;
+}
+
/**
* Determines if closed captions are enabled.
*