mirror of
https://git.meshkee.com/Meshkee/dashboards.git
synced 2026-08-11 22:30:58 +04:30
Add FA/EN locale, home activity charts, and theme-aware polish.
Ship shared LocaleProvider, business/customer i18n, branding defaultLocale, curated home tiles with dual 30-day charts, and chart/page aura tokens; refresh PROJECT_CONTEXT. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
f5b2193ba1
commit
66004a0fba
@@ -0,0 +1,37 @@
|
||||
export type DashboardLocale = 'en' | 'fa'
|
||||
|
||||
export const DASHBOARD_LOCALE_STORAGE_KEY = 'meshkee.dashboard.locale'
|
||||
|
||||
export function isDashboardLocale(value: unknown): value is DashboardLocale {
|
||||
return value === 'en' || value === 'fa'
|
||||
}
|
||||
|
||||
export function getLocaleDirection(locale: DashboardLocale): 'ltr' | 'rtl' {
|
||||
return locale === 'fa' ? 'rtl' : 'ltr'
|
||||
}
|
||||
|
||||
export function applyDocumentLocale(locale: DashboardLocale): void {
|
||||
if (typeof document === 'undefined') return
|
||||
const root = document.documentElement
|
||||
root.lang = locale
|
||||
root.dir = getLocaleDirection(locale)
|
||||
}
|
||||
|
||||
export function readStoredLocale(fallback: DashboardLocale = 'fa'): DashboardLocale {
|
||||
if (typeof localStorage === 'undefined') return fallback
|
||||
try {
|
||||
const raw = localStorage.getItem(DASHBOARD_LOCALE_STORAGE_KEY)
|
||||
return isDashboardLocale(raw) ? raw : fallback
|
||||
} catch {
|
||||
return fallback
|
||||
}
|
||||
}
|
||||
|
||||
export function writeStoredLocale(locale: DashboardLocale): void {
|
||||
if (typeof localStorage === 'undefined') return
|
||||
try {
|
||||
localStorage.setItem(DASHBOARD_LOCALE_STORAGE_KEY, locale)
|
||||
} catch {
|
||||
// ignore quota / private mode
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user