Skip to content

Commit 68ff694

Browse files
committed
Fix : Dynamically set html lang attribute based on selected language (#9193)
1 parent e6f8b09 commit 68ff694

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

app/initializers/set-html-lang.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export function initialize(appInstance) {
2+
try {
3+
const intl = appInstance.lookup('service:intl');
4+
5+
if (intl && typeof document !== 'undefined') {
6+
const lang = intl?.locale?.[0] || 'en';
7+
document.documentElement.lang = lang;
8+
}
9+
} catch (e) {
10+
console.error('Failed to set lang attribute:', e);
11+
}
12+
}
13+
14+
export default {
15+
initialize
16+
};

0 commit comments

Comments
 (0)