From 68ff694ba4ff91637bf5bf40699e7439d1fc8b88 Mon Sep 17 00:00:00 2001 From: Shivang Date: Thu, 3 Jul 2025 23:33:20 +0530 Subject: [PATCH] Fix : Dynamically set html lang attribute based on selected language (#9193) --- app/initializers/set-html-lang.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 app/initializers/set-html-lang.js diff --git a/app/initializers/set-html-lang.js b/app/initializers/set-html-lang.js new file mode 100644 index 00000000000..4899cbf76f5 --- /dev/null +++ b/app/initializers/set-html-lang.js @@ -0,0 +1,16 @@ +export function initialize(appInstance) { + try { + const intl = appInstance.lookup('service:intl'); + + if (intl && typeof document !== 'undefined') { + const lang = intl?.locale?.[0] || 'en'; + document.documentElement.lang = lang; + } + } catch (e) { + console.error('Failed to set lang attribute:', e); + } +} + +export default { + initialize +};