Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add override locale support - guest wait page #12897

Merged
merged 2 commits into from
Aug 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 36 additions & 2 deletions bigbluebutton-html5/private/static/guest-wait/guest-wait.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,45 @@
});
};

function fetchLocalizedMessages() {
async function fetchOverrideLocale() {
const token = findSessionToken();
let overrideLocale = false;

if (token) {
const sessionToken = token.split('=')[1];

// use enter api to get params for the client
const ENTER_ENDPOINT = `/bigbluebutton/api/enter?sessionToken=${sessionToken}`;
const url = new URL(`${window.location.origin}${ENTER_ENDPOINT}`);

const fetchContent = await fetch(url, { credentials: 'same-origin' });
const parseToJson = await fetchContent.json();
const { response } = parseToJson;

if (response.returncode !== 'FAILED') {
const { customdata } = response;

customdata.forEach((el) => {
const settingKey = Object.keys(el).shift();

if (settingKey === 'bbb_override_default_locale') {
overrideLocale = el[settingKey];
}
});
}
}
return overrideLocale;
}

async function fetchLocalizedMessages() {
const DEFAULT_LANGUAGE = 'en';
const LOCALES_ENDPOINT = '/html5client/locale';
const url = new URL(`${window.location.origin}${LOCALES_ENDPOINT}`);
url.search = `locale=${navigator.language}`;
const overrideLocale = await fetchOverrideLocale();

url.search = overrideLocale
? `locale=${overrideLocale}`
: `locale=${navigator.language}&init=true`;

const localesPath = 'locales';

Expand Down