Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/vector/jitsi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ let roomName: string;
let startAudioOnly: boolean;
let isVideoChannel: boolean;
let supportsScreensharing: boolean;
let language: string;

let widgetApi: WidgetApi;
let meetApi: any; // JitsiMeetExternalAPI
Expand Down Expand Up @@ -86,6 +87,7 @@ const setupCompleted = (async (): Promise<string | void> => {
const parentUrl = qsParam("parentUrl", true);
const widgetId = qsParam("widgetId", true);
const theme = qsParam("theme", true);
language = qsParam("language", true) ?? "en";

if (theme) {
document.body.classList.add(`theme-${theme.replace(" ", "_")}`);
Expand Down Expand Up @@ -313,6 +315,31 @@ function closeConference(): void {
}
}

// Converts from IETF language tags used by Element (en-US) to the format used
// by Jitsi (enUS)
function normalizeLanguage(language: string): string {
const [lang, variant] = language.replace("_", "-").split("-");

if (!variant || lang === variant) {
return lang;
}

return lang + variant.toUpperCase();
}

function mapLanguage(language: string): string {
// Element and Jitsi don't agree how to interpret en, so we go with Elements
// interpretation to stay consistent
switch (language) {
case "en":
return "enGB";
case "enUS":
return "en";
default:
return language;
}
}

// event handler bound in HTML
// An audio input of undefined instructs Jitsi to start unmuted with whatever
// audio input it can find, while an input of null instructs it to start muted,
Expand Down Expand Up @@ -371,6 +398,7 @@ function joinConference(audioInput?: string | null, videoInput?: string | null):
apiLogLevels: ["warn", "error"],
} as any,
jwt: jwt,
lang: mapLanguage(normalizeLanguage(language)),
};

// Video channel widgets need some more tailored config options
Expand Down