feat: implement i18n lazy loading optimization
🚀 Performance improvements: - Replace static language imports with dynamic imports - Load only current language on startup instead of all 13 languages - Implement on-demand loading when switching languages 📦 Bundle optimization: - Reduce initial bundle size by avoiding preloading all language files - Add resource caching to prevent reloading same language - Support all 13 languages: en, ru, zh, fa, tt, id, ar, ko, tr, de, es, jp, zhtw 🔧 Technical changes: - Convert i18n.ts to use dynamic import() for language resources - Add async initializeLanguage() for app startup - Create useI18n hook for language management with loading states - Update main.tsx for async language initialization - Fix language display labels in settings dropdown - Maintain backward compatibility with existing language system ✅ Fixed issues: - Resolve infinite loop in React components - Fix missing language labels in settings UI - Prevent circular dependencies in language loading - Add proper error handling and fallback mechanisms
This commit is contained in:
@@ -19,7 +19,7 @@ import getSystem from "@/utils/get-system";
|
||||
import { routers } from "@/pages/_routers";
|
||||
import { TooltipIcon } from "@/components/base/base-tooltip-icon";
|
||||
import { ContentCopyRounded } from "@mui/icons-material";
|
||||
import { languages } from "@/services/i18n";
|
||||
import { supportedLanguages } from "@/services/i18n";
|
||||
import { showNotice } from "@/services/noticeService";
|
||||
|
||||
interface Props {
|
||||
@@ -28,7 +28,7 @@ interface Props {
|
||||
|
||||
const OS = getSystem();
|
||||
|
||||
const languageOptions = Object.entries(languages).map(([code, _]) => {
|
||||
const languageOptions = supportedLanguages.map((code) => {
|
||||
const labels: { [key: string]: string } = {
|
||||
en: "English",
|
||||
ru: "Русский",
|
||||
@@ -39,8 +39,13 @@ const languageOptions = Object.entries(languages).map(([code, _]) => {
|
||||
ar: "العربية",
|
||||
ko: "한국어",
|
||||
tr: "Türkçe",
|
||||
de: "Deutsch",
|
||||
es: "Español",
|
||||
jp: "日本語",
|
||||
zhtw: "繁體中文",
|
||||
};
|
||||
return { code, label: labels[code] };
|
||||
const label = labels[code] || code;
|
||||
return { code, label };
|
||||
});
|
||||
|
||||
const SettingVergeBasic = ({ onError }: Props) => {
|
||||
|
||||
Reference in New Issue
Block a user