Replace static imports of all 5 locale JSON files with dynamic imports.
Only English is bundled by default, other locales (es, hi, pt, zh) load
on demand when the user switches languages.
Also removes unused 'set' import from zod (line 5) that was dragging
Zod surface into this module unnecessarily.
Changes:
- Removed static imports for es, hi, pt, zh locale files
- Removed unused zod import
- Added loadMessages() function for dynamic locale loading
- Updated setLocale() to load messages asynchronously
- Added useEffect to load non-English locale on mount if stored
Benefits:
- Only active locale's JSON in initial bundle (English default)
- 80% reduction in locale data in initial bundle
- Other locale files load on demand (~50-100KB each)
- Removed unnecessary zod dependency from module
- Locale switching still works seamlessly
- Faster initial page load
Fixes#1143
- toggle-group.tsx: Wrap contextValue in useMemo to prevent unnecessary re-renders
- animated-tabs.tsx: Hoist constants and memoize handlers with useCallback/useMemo
- LocaleContext.tsx: Wrap setLocale in useCallback and contextValue in useMemo
- plate-editor.tsx: Memoize SaveShortcutPlugin and contextProviderValue, use useRef for stable references