Skip to content

Commit b54324c

Browse files
committed
Translate jitsi widget
Signed-off-by: Oliver Sand <oliver.sand@nordeck.net>
1 parent d8124d3 commit b54324c

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

src/i18n/strings/de_DE.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"Failed to start": "Start fehlgeschlagen",
1818
"%(brand)s Desktop (%(platformName)s)": "%(brand)s Desktop (%(platformName)s)",
1919
"%(appName)s (%(browserName)s, %(osName)s)": "%(appName)s (%(browserName)s, %(osName)s)",
20+
"Failed to load Jitsi widget": "Das Jitsi Widget konnte nicht geladen werden",
21+
"Jitsi Video Conference": "Videokonferenz",
22+
"Join Conference": "Videokonferenz beitreten",
2023
"Please install <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink>, or <safariLink>Safari</safariLink> for the best experience.": "Bitte installiere <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink> oder <safariLink>Safari</safariLink> für das beste Erlebnis.",
2124
"You can continue using your current browser, but some or all features may not work and the look and feel of the application may be incorrect.": "Du kannst deinen aktuellen Browser weiterhin verwenden. Es ist aber möglich, dass nicht alles richtig funktioniert oder das Aussehen der App inkorrekt ist.",
2225
"I understand the risks and wish to continue": "Ich verstehe die Risiken und möchte fortfahren",

src/i18n/strings/en_EN.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"Go to your browser to complete Sign In": "Go to your browser to complete Sign In",
1515
"Unknown device": "Unknown device",
1616
"%(appName)s (%(browserName)s, %(osName)s)": "%(appName)s (%(browserName)s, %(osName)s)",
17+
"Failed to load Jitsi widget": "Failed to load Jitsi widget",
18+
"Join Conference": "Join Conference",
19+
"Jitsi Video Conference": "Jitsi Video Conference",
1720
"Powered by Matrix": "Powered by Matrix",
1821
"Use %(brand)s on mobile": "Use %(brand)s on mobile",
1922
"Unsupported browser": "Unsupported browser",

src/vector/jitsi/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<div class="joinConferenceFloating">
1111
<div class="joinConferencePrompt">
1212
<span class="icon"><!-- managed by CSS --></span>
13-
<!-- TODO: i18n -->
1413
<h2>Jitsi Video Conference</h2>
1514
<div id="widgetActionContainer">
1615
<button type="button" id="joinButton">Join Conference</button>

src/vector/jitsi/index.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
import { ElementWidgetActions } from "matrix-react-sdk/src/stores/widgets/ElementWidgetActions";
2828
import { logger } from "matrix-js-sdk/src/logger";
2929
import { IConfigOptions } from "matrix-react-sdk/src/IConfigOptions";
30+
import { _t, setLanguage } from "matrix-react-sdk/src/languageHandler";
3031
import { SnakedObject } from "matrix-react-sdk/src/utils/SnakedObject";
3132

3233
import { getVectorConfig } from "../getconfig";
@@ -56,6 +57,7 @@ let roomName: string;
5657
let startAudioOnly: boolean;
5758
let isVideoChannel: boolean;
5859
let supportsScreensharing: boolean;
60+
let language: string;
5961

6062
let widgetApi: WidgetApi;
6163
let meetApi: any; // JitsiMeetExternalAPI
@@ -85,6 +87,7 @@ const setupCompleted = (async () => {
8587
const parentUrl = qsParam('parentUrl', true);
8688
const widgetId = qsParam('widgetId', true);
8789
const theme = qsParam('theme', true);
90+
language = qsParam('language', true) ?? 'en';
8891

8992
if (theme) {
9093
document.body.classList.add(`theme-${theme.replace(" ", "_")}`);
@@ -177,6 +180,8 @@ const setupCompleted = (async () => {
177180
logger.warn("No parent URL or no widget ID - assuming no widget API is available");
178181
}
179182

183+
await applyTranslation(language);
184+
180185
// Populate the Jitsi params now
181186
jitsiDomain = qsParam('conferenceDomain');
182187
conferenceId = qsParam('conferenceId');
@@ -219,10 +224,17 @@ const setupCompleted = (async () => {
219224
enableJoinButton(); // always enable the button
220225
} catch (e) {
221226
logger.error("Error setting up Jitsi widget", e);
222-
document.getElementById("widgetActionContainer").innerText = "Failed to load Jitsi widget";
227+
document.getElementById("widgetActionContainer").innerText = _t("Failed to load Jitsi widget");
223228
}
224229
})();
225230

231+
async function applyTranslation(language: string) {
232+
await setLanguage(language);
233+
234+
document.getElementById("joinButton").textContent = _t("Join Conference");
235+
document.querySelector(".joinConferencePrompt > h2").textContent = _t("Jitsi Video Conference");
236+
}
237+
226238
function enableJoinButton() {
227239
document.getElementById("joinButton").onclick = () => joinConference();
228240
}
@@ -321,7 +333,7 @@ function joinConference(audioInput?: string | null, videoInput?: string | null)
321333
if (!openIdToken?.access_token) { // eslint-disable-line camelcase
322334
// We've failing to get a token, don't try to init conference
323335
logger.warn('Expected to have an OpenID credential, cannot initialize widget.');
324-
document.getElementById("widgetActionContainer").innerText = "Failed to load Jitsi widget";
336+
document.getElementById("widgetActionContainer").innerText = _t("Failed to load Jitsi widget");
325337
return;
326338
}
327339
jwt = createJWTToken();
@@ -367,6 +379,7 @@ function joinConference(audioInput?: string | null, videoInput?: string | null)
367379
apiLogLevels: ["warn", "error"],
368380
} as any,
369381
jwt: jwt,
382+
lang: language,
370383
};
371384

372385
// Video channel widgets need some more tailored config options

0 commit comments

Comments
 (0)