Skip to content

[i18n] Language Switcher, Middleware & Locale Management #131

Description

@fbenmadani

Implement the core internationalization (i18n) foundation required before RTL support.

This issue is a dependency for: SF-13 (RTL Support).

Scope:

  • Backend locale handling
  • Middleware for language detection
  • Frontend language switcher UI

Tasks:

  1. Middleware (Backend)
  • Create SetLocale middleware
  • Detect locale from:
    • User preference (if authenticated)
    • Session / cookie
    • Fallback to default (config/app.php)
  • Apply App::setLocale()
  1. Language Persistence
  • Store selected language in session or cookie
  • (Optional) Persist in user profile
  1. Frontend Language Switcher
  • Add language selector component (dropdown)
  • Allow switching between at least: en, ar, fa
  • Trigger backend route to update locale
  1. Routes & Controller
  • Create route: /locale/{lang}
  • Validate allowed locales
  • Store selection and redirect back
  1. Config
  • Define supported locales in config (e.g. config/locales.php)
  • Example: ['en', 'ar', 'fa']
  1. Blade / Frontend Integration
  • Ensure all UI uses translation files (no hardcoded strings)
  • Prepare layout for dynamic dir() later (RTL dependency)

Outcome:

  • Users can switch language dynamically
  • Locale is persisted across sessions
  • Application is ready for RTL implementation (SF-13)

Notes:

  • Keep middleware lightweight (runs on every request)
  • Avoid coupling locale logic with tenancy unless required
  • Prepare for future translation file expansion

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions