Laravel developers ditch separate tables for JSON-based translations
Multilingual Architecture via JSON Fields
Managing 10 or more languages in a modern web application requires a shift away from cumbersome relational tables toward flexible JSON structures. Using the spatie/laravel-translatable package allows Laravel developers to store multiple language values within a single database column. This approach eliminates the need for complex joins or secondary translation tables, which can significantly clutter a schema as the application scales.
Global Middleware and Localized Routing
To ensure a seamless user experience, the application uses a custom SetLocale middleware. This logic extracts the language code directly from the URL prefix—such as /es/ for Spanish—and sets the application state accordingly. By validating these prefixes against a regex pattern, the system maintains SEO integrity while ensuring that every route remains strictly localized. Additionally, the middleware persists the user's choice in a cookie, allowing for a consistent experience during return visits.
Dynamic UI via Filament Tabs
The Filament admin panel provides a highly visual way to manage these translations. Instead of a single massive form, the implementation uses dynamic tabs that loop through a locales configuration file. Each tab displays an emoji flag and a set of input fields.
foreach (config('locales') as $code => $locale) {
$tabs[] = Tab::make($locale['name'])
->icon($locale['flag'])
->schema([
TextInput::make("title.$code")
->required($code === 'en'),
Textarea::make("description.$code"),
]);
}

This structure ensures that only the primary language (English) requires validation, while others remain optional.
Performance Tradeoffs with Astrotomic
While JSON fields offer flexibility, high-traffic applications with heavy SQL querying might struggle with performance. In these scenarios, the astrotomic/laravel-translatable package serves as a robust alternative. Unlike Spatie's JSON approach, Astrotomic utilizes separate relational tables to store translations. This allows for faster indexing and more efficient sorting at the database level, though it increases the complexity of the initial database migration and model setup.
- astrotomic/laravel-translatable
- 14%· products
- Filament
- 14%· products
- Google Translate
- 14%· companies
- Laravel
- 14%· products
- SEO
- 14%· products
- Other topics
- 29%

Laravel Multi-Language Travel Website with Filament Panel
WatchLaravel Daily // 9:47