mirror of
https://github.com/pezkuwichain/pezkuwi-telegram-miniapp.git
synced 2026-06-15 04:31:15 +00:00
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:
@@ -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';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user