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 // Hides the dominant speaker name badge that hovers above the toolbox
// hideDominantSpeakerBadge: false, // hideDominantSpeakerBadge: false,
// Default language for the user interface. // Default language for the user interface. Cannot be overwritten.
// defaultLanguage: 'en', // defaultLanguage: 'en',
// Disables profile and the edit of all fields from the profile settings (display name and email) // 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. * configuration options defined in interface_config.js to be overridden.
* @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for * @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for
* authentication. * authentication.
* @param {string} [options.lang] - The meeting's default language.
* @param {string} [options.roomName] - The name of the room to join. * @param {string} [options.roomName] - The name of the room to join.
* @returns {string} The URL. * @returns {string} The URL.
*/ */
@ -208,7 +209,8 @@ function parseArguments(args) {
configOverwrite, configOverwrite,
interfaceConfigOverwrite, interfaceConfigOverwrite,
jwt, jwt,
onload onload,
lang
] = args; ] = args;
return { return {
@ -219,7 +221,8 @@ function parseArguments(args) {
configOverwrite, configOverwrite,
interfaceConfigOverwrite, interfaceConfigOverwrite,
jwt, jwt,
onload onload,
lang
}; };
} }
case 'object': // new arguments format 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. * configuration options defined in interface_config.js to be overridden.
* @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for * @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for
* authentication. * authentication.
* @param {string} [options.lang] - The meeting's default language.
* @param {string} [options.onload] - The onload function that will listen * @param {string} [options.onload] - The onload function that will listen
* for iframe onload event. * for iframe onload event.
* @param {Array<Object>} [options.invitees] - Array of objects containing * @param {Array<Object>} [options.invitees] - Array of objects containing
@ -301,6 +305,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
configOverwrite = {}, configOverwrite = {},
interfaceConfigOverwrite = {}, interfaceConfigOverwrite = {},
jwt = undefined, jwt = undefined,
lang = undefined,
onload = undefined, onload = undefined,
invitees, invitees,
devices, devices,
@ -314,6 +319,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
configOverwrite, configOverwrite,
interfaceConfigOverwrite, interfaceConfigOverwrite,
jwt, jwt,
lang,
roomName, roomName,
devices, devices,
userInfo, userInfo,

View File

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

View File

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