Skip to content

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

fix(transcript) fix matching languages with variants

shooding9d7237dc24e0
diff --git a/react/features/subtitles/middleware.ts b/react/features/subtitles/middleware.ts
index a5cbb58e00..760aa82dd4 100644
--- a/react/features/subtitles/middleware.ts
+++ b/react/features/subtitles/middleware.ts
@@ -196,7 +196,7 @@ function _endpointMessageReceived(store: IStore, next: Function, action: AnyActi
// Regex to filter out all possible country codes after language code:
// this should catch all notations like 'en-GB' 'en_GB' and 'enGB'
// and be independent of the country code length
- if (json.language.replace(/[-_A-Z].*/, '') !== language) {
+ if (_getPrimaryLanguageCode(json.language) !== _getPrimaryLanguageCode(language)) {
return next(action);
}
@@ -260,6 +260,17 @@ function _endpointMessageReceived(store: IStore, next: Function, action: AnyActi
return next(action);
}
+/**
+ * Utility function to extract the primary language code like 'en-GB' 'en_GB'
+ * 'enGB' 'zh-CN' and 'zh-TW'.
+ *
+ * @param {string} language - The language to use for translation or user requested.
+ * @returns {string}
+ */
+function _getPrimaryLanguageCode(language: string) {
+ return language.replace(/[-_A-Z].*/, '');
+}
+
/**
* Toggle the local property 'requestingTranscription'. This will cause Jicofo
* and Jigasi to decide whether the transcriber needs to be in the room.