mirror of
https://github.com/pezkuwichain/pezkuwi-telegram-miniapp.git
synced 2026-12-03 15:57:09 +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:
1 parent
f2b809cb7c
commit
c72782793a
4 files changed
+16
-33
No files matched your search
@@ -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