fix: use localStorage instead of URL path for language persistence

Telegram WebView caches URL and strips #tgWebAppData hash on reopens,
causing empty initData when URL path contained language prefix like /en.
This commit is contained in:
2026-02-22 21:04:29 +03:00
parent f2b809cb7c
commit c72782793a
4 changed files with 16 additions and 33 deletions
+2 -2
View File
@@ -12,8 +12,8 @@ import type { Translations, LanguageCode } from '@/i18n/types';
const translations: Record<LanguageCode, Translations> = { krd, en, tr, ckb, fa, ar };
function detectLang(): LanguageCode {
const seg = window.location.pathname.split('/').filter(Boolean)[0];
if (seg && seg in translations) return seg as LanguageCode;
const stored = localStorage.getItem('app_language');
if (stored && stored in translations) return stored as LanguageCode;
return 'krd';
}