From 58f168dd97af42dedadd771655aa79a02b7e0bc3 Mon Sep 17 00:00:00 2001 From: Vasyka Date: Sat, 18 Jul 2026 11:04:30 +0000 Subject: [PATCH] i18n(users): wrap role Select options with I18n::opts + 2FA status + Locale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Both role selects (primary + additional roles multi) passed the raw roleLabels() array without translation; wrap with I18n::opts() so Proprietar/Administrator/… now render translated in RU/EN. - 2FA status text ('✓ Activat (TOTP)' / '✗ Dezactivat') split so the checkmark stays and label runs through __(). - +3 translations (Activat (TOTP), Dezactivat, Locale) — Locale is Filament's auto-generated headline from the `locale` field. Co-Authored-By: Claude Opus 4.7 (1M context) --- app/Filament/Tenant/Resources/UserResource.php | 6 +++--- lang/en.json | 3 +++ lang/ru.json | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Filament/Tenant/Resources/UserResource.php b/app/Filament/Tenant/Resources/UserResource.php index 795dc5d..2eb1cf1 100644 --- a/app/Filament/Tenant/Resources/UserResource.php +++ b/app/Filament/Tenant/Resources/UserResource.php @@ -79,7 +79,7 @@ class UserResource extends Resource ->schema([ Forms\Components\Select::make('role') ->label(__('Rol primar')) - ->options(\App\Auth\Permissions::roleLabels()) + ->options(\App\Support\I18n::opts(\App\Auth\Permissions::roleLabels())) ->required() ->default('mechanic') ->helperText(__('Rolul principal — sincronizat automat cu drepturile RBAC.')), @@ -98,7 +98,7 @@ class UserResource extends Resource Forms\Components\Select::make('roles_picked') ->label(__('Roluri suplimentare')) ->multiple() - ->options(\App\Auth\Permissions::roleLabels()) + ->options(\App\Support\I18n::opts(\App\Auth\Permissions::roleLabels())) ->afterStateHydrated(function ($component, $record) { if ($record) $component->state($record->roles->pluck('name')->all()); }) @@ -130,7 +130,7 @@ class UserResource extends Resource ->schema([ Forms\Components\Placeholder::make('mfa_status') ->label(__('Autentificare 2FA')) - ->content(fn ($record) => $record && $record->hasTwoFactorEnabled() ? '✓ Activat (TOTP)' : '✗ Dezactivat'), + ->content(fn ($record) => $record && $record->hasTwoFactorEnabled() ? '✓ ' . __('Activat (TOTP)') : '✗ ' . __('Dezactivat')), Forms\Components\Placeholder::make('last_login') ->label(__('Ultima autentificare')) ->content(fn ($record) => $record?->last_login_at?->diffForHumans() ?? '—'), diff --git a/lang/en.json b/lang/en.json index 1fc4fe6..b6d0fc0 100644 --- a/lang/en.json +++ b/lang/en.json @@ -65,6 +65,7 @@ "Actions": "Actions", "Activ": "Active", "Activare": "Activation", + "Activat (TOTP)": "Enabled (TOTP)", "Active": "Assets", "Active acum": "Active now", "Activează": "Activate", @@ -618,6 +619,7 @@ "Detalii comandă": "Order details", "Deviz": "Estimate", "Dezactivare": "Deactivation", + "Dezactivat": "Disabled", "Dezactivează": "Deactivate", "Dezactivează 2FA pentru acest utilizator. Va trebui să re-configureze TOTP la următoarea autentificare.": "Disables 2FA for this user. They will need to re-set up TOTP on the next login.", "Diagnosis": "Diagnosis", @@ -965,6 +967,7 @@ "Loading": "Loading...", "Loc.": "Loc.", "Local": "Local", + "Locale": "Locale", "Localizare & monedă": "Localization & currency", "Location": "Location", "Locație": "Location", diff --git a/lang/ru.json b/lang/ru.json index 4fc91ec..6ce3bcf 100644 --- a/lang/ru.json +++ b/lang/ru.json @@ -65,6 +65,7 @@ "Actions": "Действия", "Activ": "Активный", "Activare": "Активация", + "Activat (TOTP)": "Активирован (TOTP)", "Active": "Активы", "Active acum": "В работе сейчас", "Activează": "Активировать", @@ -618,6 +619,7 @@ "Detalii comandă": "Данные заказа", "Deviz": "Смета", "Dezactivare": "Деактивация", + "Dezactivat": "Отключено", "Dezactivează": "Деактивировать", "Dezactivează 2FA pentru acest utilizator. Va trebui să re-configureze TOTP la următoarea autentificare.": "Отключает 2FA для этого пользователя. Ему потребуется заново настроить TOTP при следующем входе.", "Diagnosis": "Диагноз", @@ -965,6 +967,7 @@ "Loading": "Загрузка...", "Loc.": "Loc.", "Local": "Локально", + "Locale": "Локаль", "Localizare & monedă": "Локализация и валюта", "Location": "Локация", "Locație": "Локация",