fix(i18n): auto-translate labels on Filament columns/fields/filters/actions

Root cause of untranslated table headers: Filament's HasLabel::getLabel()
auto-generates a label from the field name (e.g. `name` → "Name") but only
calls __() on it if you also invoke ->translateLabel(). Without that, the
auto-generated label always renders in English regardless of app locale.

Fix: configureUsing() in AppServiceProvider makes translateLabel() the
default for every Column, BaseFilter, Field, Action and BulkAction.

Then added 175 human RU/EN translations for Filament's auto-generated
keys (Name, Phone, Email, Status, Balance, Created at, Plate, Make,
Model, Year, VIN, Mileage, Owner, Client, Vehicle, Amount, Total, Qty,
Actions, Search, Filter, Export, Import, plus enums/relationships).

All 306 tests pass. Deploy will fix table headers on
Clients / Vehicles / Work orders / Payments / Purchases / Suppliers etc.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-16 05:21:29 +00:00
parent 7077fff3b3
commit 38650da875
3 changed files with 359 additions and 6 deletions
+15
View File
@@ -21,5 +21,20 @@ class AppServiceProvider extends ServiceProvider
if (! $this->app->runningInConsole() && (str_starts_with(config('app.url'), 'https://') || env('FORCE_HTTPS'))) {
URL::forceScheme('https');
}
// Auto-translate labels on every Filament component that has one.
// Without this, auto-derived labels (e.g. `name` → "Name") bypass __()
// and always render in English regardless of the app locale.
foreach ([
\Filament\Tables\Columns\Column::class,
\Filament\Tables\Filters\BaseFilter::class,
\Filament\Forms\Components\Field::class,
\Filament\Actions\Action::class,
\Filament\Actions\BulkAction::class,
] as $class) {
if (class_exists($class) && method_exists($class, 'configureUsing')) {
$class::configureUsing(fn ($c) => method_exists($c, 'translateLabel') ? $c->translateLabel() : $c);
}
}
}
}