Forum Discussion
NadineBergmann-
10 months 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...
PhilFoss
17 hours agoCommunity Member
MarcinZarod​ thanks for the script. This is a bit experimental, but I've modified it to include adding RTL direction on the body tag (on html tag doesn't work) for Arabic and other rtl languages. Only tested on a regular scorm output.
<script>
(function () {
try {
const preferredLanguage = "ar"; // example
// List of ISO language codes that use RTL direction
const rtlLangs = ["ar", "he", "fa", "ur", "ps", "dv", "ku", "syr", "ug", "yi"];
const langCode = preferredLanguage.split("-")[0].toLowerCase();
function applyLangAndDir() {
if (document && document.documentElement) {
document.documentElement.lang = preferredLanguage;
}
if (document && document.body) {
if (rtlLangs.includes(langCode)) {
document.body.setAttribute("dir", "rtl");
} else {
document.body.setAttribute("dir", "ltr");
}
}
}
// Apply immediately
applyLangAndDir();
// Monkey-patch __fetchCourse so Rise receives the preferred language
var origFetch = window.__fetchCourse;
if (typeof origFetch === 'function') {
window.__fetchCourse = async function () {
var data = await origFetch();
try {
if (data) {
if (data.labelSet && typeof data.labelSet === 'object') {
data.labelSet.iso639Code = preferredLanguage;
}
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
}
// Re-apply after Rise loads its course data
applyLangAndDir();
return data;
}
}
// Backup: watch for body changes and re-apply dir
const observer = new MutationObserver(() => applyLangAndDir());
observer.observe(document.body, { attributes: true, childList: true, subtree: false });
} catch (e) {
// ignore
}
})();
</script>