Files
Momento/memento-note/components/direction-initializer.tsx
Antigravity 368b43cb8e
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 1m50s
feat: improve AI Chat UX, add notebook summary, and fix shared/reminders routing
2026-05-09 14:40:36 +00:00

28 lines
714 B
TypeScript

'use client'
import { useEffect } from 'react'
/**
* Sets document direction (RTL/LTR) on mount based on saved language.
* Runs before paint to prevent visual flash.
*/
export function DirectionInitializer() {
useEffect(() => {
try {
let lang = localStorage.getItem('user-language')
if (!lang) {
const c = document.cookie.split(';').map(s => s.trim()).find(s => s.startsWith('user-language='))
if (c) lang = c.split('=')[1]
}
if (lang === 'fa' || lang === 'ar') {
document.documentElement.dir = 'rtl'
document.documentElement.lang = lang
} else {
document.documentElement.dir = 'ltr'
}
} catch {}
}, [])
return null
}