Improvement #31373
open
- Status changed from Assigned to In Progress
- Status changed from In Progress to Fixed not Tested
- % Done changed from 0 to 100
1. Infrastructure
Routing: Moved app pages to src/app/[locale]/ to support URL-based localization (e.g., /en, /ar).
Middleware: Updated middleware.ts to automatically detect valid locales and redirect if missing.
Fix: Excluded static assets (/css, /js, /images) to prevent 404s.
Resource Store: Created ResourceStore (src/lib/resource-store.ts) singleton to cache API resource keys.
API: Added get-resources.ts action to fetch localized strings from the backend.
Server Translations: Created getServerTranslations (src/lib/server-translation.ts) helper to standardize usage in Server Components.
2. Components & State
LanguageProvider: Created a React Context (src/providers/LanguageProvider.tsx) for Client Components.
Header & Footer: Refactored to use useLanguage hook.
Layout: Updated to use getServerTranslations and dynamically set lang/dir attributes.
Page: Refactored src/app/[locale]/page.tsx to use getServerTranslations for server-side content.
Verification
Code Structure: Verified file moves and imports.
Type Safety: Ensured type definitions for the new helper are correct.
Build: The build process configuration has been updated.
Also available in: Atom
PDF