Skip to content

Only overwrite languageId when requested - #388

Merged
bearfriend merged 3 commits into
mainfrom
dgleckler/oslo-language-id-restriction
Jul 10, 2026
Merged

Only overwrite languageId when requested#388
bearfriend merged 3 commits into
mainfrom
dgleckler/oslo-language-id-restriction

Conversation

@bearfriend

@bearfriend bearfriend commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

GAUD-10152: OSLO > Custom languages are not resolved via oslo - falls back to parent language

In order for OSLO to pull down custom langpacks that use (via a custom locale) locale codes that we already support, we need to limit overwriting the languageId. Currently we always check if there is a mismatch between the document language and the OSLO languageId. With a custom langpack/locale, this mismatch could be intentional.

@bearfriend
bearfriend requested a review from a team as a code owner July 9, 2026 19:24
Comment thread lib/localize.js
if (oslo.collection) {
languageId = supportedLocalesDetails.find(l => l.code === osloLang || l.pack === osloLang)?.id;
const doc = document.documentElement;
if (doc.hasAttribute('data-custom-lang') && oslo.collection) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The attribute will come from https://github.com/Brightspace/lms/pull/89913

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused... where do data-custom-lang and data-language-id get set? That linked PR is just emptying out data-custom-lang in content pages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a boolean. Empty string sets the attribute. delete is what removes it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And data-language-id would be set by an author on their content in edge cases.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about this offline -- on the same page now.

@bearfriend
bearfriend force-pushed the dgleckler/oslo-language-id-restriction branch from 106d9e4 to 879cd05 Compare July 9, 2026 19:29
Comment thread lib/localize.js
languageId = supportedLocalesDetails.find(l => l.code === osloLang || l.pack === osloLang)?.id;
const doc = document.documentElement;
if (doc.hasAttribute('data-custom-lang') && oslo.collection) {
languageId = Number(doc.dataset.languageId) || supportedLocalesDetails.find(l => l.code === osloLang || l.pack === osloLang)?.id;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows content authors to declare a preferred (custom) languageId that will be respected regardless of any locale code confusion

Comment thread lib/localize.js
if (oslo.collection) {
languageId = supportedLocalesDetails.find(l => l.code === osloLang || l.pack === osloLang)?.id;
const doc = document.documentElement;
if (doc.hasAttribute('data-custom-lang') && oslo.collection) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about this offline -- on the same page now.

@bearfriend
bearfriend merged commit 480e5ee into main Jul 10, 2026
2 checks passed
@bearfriend
bearfriend deleted the dgleckler/oslo-language-id-restriction branch July 10, 2026 13:18
@d2l-github-release-tokens

Copy link
Copy Markdown

🎉 This PR is included in version 3.40.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants