fix(language) Add lang API option

- jwt from API overwrites any jwt sent as queryparam
- `defaultLanguage` from configOverwrite converts to `lang` query param
This commit is contained in:
Horatiu Muresan 2022-03-08 16:57:53 +02:00 committed by GitHub
parent 8b149f9138
commit 4b95a5d6cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 13 deletions

View File

@ -516,7 +516,7 @@ var config = {
// Hides the dominant speaker name badge that hovers above the toolbox
// hideDominantSpeakerBadge: false,
// Default language for the user interface.
// Default language for the user interface. Cannot be overwritten.
// defaultLanguage: 'en',
// Disables profile and the edit of all fields from the profile settings (display name and email)

View File

@ -170,6 +170,7 @@ function changeParticipantNumber(APIInstance, number) {
* configuration options defined in interface_config.js to be overridden.
* @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for
* authentication.
* @param {string} [options.lang] - The meeting's default language.
* @param {string} [options.roomName] - The name of the room to join.
* @returns {string} The URL.
*/
@ -208,7 +209,8 @@ function parseArguments(args) {
configOverwrite,
interfaceConfigOverwrite,
jwt,
onload
onload,
lang
] = args;
return {
@ -219,7 +221,8 @@ function parseArguments(args) {
configOverwrite,
interfaceConfigOverwrite,
jwt,
onload
onload,
lang
};
}
case 'object': // new arguments format
@ -280,6 +283,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
* configuration options defined in interface_config.js to be overridden.
* @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for
* authentication.
* @param {string} [options.lang] - The meeting's default language.
* @param {string} [options.onload] - The onload function that will listen
* for iframe onload event.
* @param {Array<Object>} [options.invitees] - Array of objects containing
@ -301,6 +305,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
configOverwrite = {},
interfaceConfigOverwrite = {},
jwt = undefined,
lang = undefined,
onload = undefined,
invitees,
devices,
@ -314,6 +319,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
configOverwrite,
interfaceConfigOverwrite,
jwt,
lang,
roomName,
devices,
userInfo,

View File

@ -81,7 +81,6 @@ export default [
'brandingRoomAlias',
'debug',
'debugAudioLevels',
'defaultLanguage',
'defaultLocalDisplayName',
'defaultRemoteDisplayName',
'desktopSharingFrameRate',

View File

@ -523,19 +523,25 @@ export function urlObjectToString(o: Object): ?string {
// query/search
// Web's ExternalAPI jwt
const { jwt } = o;
// Web's ExternalAPI jwt and lang
const { jwt, lang } = o;
const search = new URLSearchParams(url.search);
if (jwt) {
let { search } = url;
search.set('jwt', jwt);
}
if (search.indexOf('?jwt=') === -1 && search.indexOf('&jwt=') === -1) {
search.startsWith('?') || (search = `?${search}`);
search.length === 1 || (search += '&');
search += `jwt=${jwt}`;
const { defaultLanguage } = o.configOverwrite || {};
url.search = search;
}
if (lang || defaultLanguage) {
search.set('lang', lang || defaultLanguage);
}
const searchString = search.toString();
if (searchString) {
url.search = `?${searchString}`;
}
// fragment/hash