Forum Discussion
NadineBergmann-
1 year agoCommunity Member
Change HTML source language in Rise course
Dear community, We developed an e-learning in Dutch using Articulate Rise and have gotten it tested on accessibility. One of the comments on the course was that in the HTML of the course the source...
MarcinZarod
3 months agoCommunity Member
I seemed to have solved the problem with overriding the language setting in the WEB export from RISE. In the index.html file add this script just before the closing </head>
Change "pl-PL" to your language designation.
<!begining of added script>
<script>
(function () {
try {
const preferredLanguage = "pl-PL";
// 1) Set <html lang> ASAP (prevents flashes of the wrong lang)
if (document && document.documentElement) {
document.documentElement.lang = preferredLanguage;
}
// 2) Make sure the URL always carries ?locale=pl-PL so Rise picks Polish
// (the app's locale resolver reads from location.search).
(function ensureLocaleParam() {
try {
const url = new URL(window.location.href);
const current = url.searchParams.get("locale");
if (current !== preferredLanguage) {
url.searchParams.set("locale", preferredLanguage);
// Use replaceState to avoid adding history entries.
window.history.replaceState(null, "", url.toString());
}
// Also patch pushState/replaceState so future navigations keep pl-PL
const wrap = (fn) => function () {
const ret = fn.apply(this, arguments);
try {
const u = new URL(window.location.href);
if (u.searchParams.get("locale") !== preferredLanguage) {
u.searchParams.set("locale", preferredLanguage);
window.history.replaceState(null, "", u.toString());
}
} catch (_) {}
return ret;
};
window.history.pushState = wrap(window.history.pushState);
window.history.replaceState = wrap(window.history.replaceState);
} catch (_) {}
})();
// 3) Patch the course boot JSON so defaults are Polish if app falls back
var origFetch = window.__fetchCourse;
if (typeof origFetch === "function") {
window.__fetchCourse = async function () {
let data = await origFetch();
try {
if (data) {
// l10n/default locale
if (data.l10n && typeof data.l10n === "object") {
data.l10n.defaultLocale = preferredLanguage;
// If locales array exists, prefer selecting pl-PL as the default entry
if (Array.isArray(data.l10n.locales)) {
const hasPL = data.l10n.locales.some(x => x.locale === preferredLanguage);
if (!hasPL) {
// If pl-PL is missing, add a minimal entry so the app accepts it
data.l10n.locales.push({ locale: preferredLanguage });
}
}
// Optional label set hint some builds look at:
if (data.l10n.languageCodeMetadata && !data.l10n.languageCodeMetadata[preferredLanguage]) {
data.l10n.languageCodeMetadata[preferredLanguage] = {
learnerDisplayName: "Polski",
authorDisplayName: "Polski"
};
}
}
// Older builds: labelSet / iso639Code sometimes used
if (data.labelSet && typeof data.labelSet === "object") {
data.labelSet.iso639Code = preferredLanguage;
}
// Course-level hints (harmless if absent)
if (data.course && typeof data.course === "object") {
data.course.locale = preferredLanguage;
if (data.course.defaultLocaleId == null || data.course.defaultLocaleId === "en") {
data.course.defaultLocaleId = preferredLanguage;
}
}
}
} catch (e) {
// ignore
}
return data;
};
}
} catch (e) {
// ignore
}
})();
</script>
<!end of added script