i18n(users): wrap role Select options with I18n::opts + 2FA status + Locale

- 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) <noreply@anthropic.com>
This commit is contained in:
2026-07-18 11:04:30 +00:00
parent 00afca8a17
commit 58f168dd97
3 changed files with 9 additions and 3 deletions
@@ -79,7 +79,7 @@ class UserResource extends Resource
->schema([ ->schema([
Forms\Components\Select::make('role') Forms\Components\Select::make('role')
->label(__('Rol primar')) ->label(__('Rol primar'))
->options(\App\Auth\Permissions::roleLabels()) ->options(\App\Support\I18n::opts(\App\Auth\Permissions::roleLabels()))
->required() ->required()
->default('mechanic') ->default('mechanic')
->helperText(__('Rolul principal — sincronizat automat cu drepturile RBAC.')), ->helperText(__('Rolul principal — sincronizat automat cu drepturile RBAC.')),
@@ -98,7 +98,7 @@ class UserResource extends Resource
Forms\Components\Select::make('roles_picked') Forms\Components\Select::make('roles_picked')
->label(__('Roluri suplimentare')) ->label(__('Roluri suplimentare'))
->multiple() ->multiple()
->options(\App\Auth\Permissions::roleLabels()) ->options(\App\Support\I18n::opts(\App\Auth\Permissions::roleLabels()))
->afterStateHydrated(function ($component, $record) { ->afterStateHydrated(function ($component, $record) {
if ($record) $component->state($record->roles->pluck('name')->all()); if ($record) $component->state($record->roles->pluck('name')->all());
}) })
@@ -130,7 +130,7 @@ class UserResource extends Resource
->schema([ ->schema([
Forms\Components\Placeholder::make('mfa_status') Forms\Components\Placeholder::make('mfa_status')
->label(__('Autentificare 2FA')) ->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') Forms\Components\Placeholder::make('last_login')
->label(__('Ultima autentificare')) ->label(__('Ultima autentificare'))
->content(fn ($record) => $record?->last_login_at?->diffForHumans() ?? '—'), ->content(fn ($record) => $record?->last_login_at?->diffForHumans() ?? '—'),
+3
View File
@@ -65,6 +65,7 @@
"Actions": "Actions", "Actions": "Actions",
"Activ": "Active", "Activ": "Active",
"Activare": "Activation", "Activare": "Activation",
"Activat (TOTP)": "Enabled (TOTP)",
"Active": "Assets", "Active": "Assets",
"Active acum": "Active now", "Active acum": "Active now",
"Activează": "Activate", "Activează": "Activate",
@@ -618,6 +619,7 @@
"Detalii comandă": "Order details", "Detalii comandă": "Order details",
"Deviz": "Estimate", "Deviz": "Estimate",
"Dezactivare": "Deactivation", "Dezactivare": "Deactivation",
"Dezactivat": "Disabled",
"Dezactivează": "Deactivate", "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.", "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", "Diagnosis": "Diagnosis",
@@ -965,6 +967,7 @@
"Loading": "Loading...", "Loading": "Loading...",
"Loc.": "Loc.", "Loc.": "Loc.",
"Local": "Local", "Local": "Local",
"Locale": "Locale",
"Localizare & monedă": "Localization & currency", "Localizare & monedă": "Localization & currency",
"Location": "Location", "Location": "Location",
"Locație": "Location", "Locație": "Location",
+3
View File
@@ -65,6 +65,7 @@
"Actions": "Действия", "Actions": "Действия",
"Activ": "Активный", "Activ": "Активный",
"Activare": "Активация", "Activare": "Активация",
"Activat (TOTP)": "Активирован (TOTP)",
"Active": "Активы", "Active": "Активы",
"Active acum": "В работе сейчас", "Active acum": "В работе сейчас",
"Activează": "Активировать", "Activează": "Активировать",
@@ -618,6 +619,7 @@
"Detalii comandă": "Данные заказа", "Detalii comandă": "Данные заказа",
"Deviz": "Смета", "Deviz": "Смета",
"Dezactivare": "Деактивация", "Dezactivare": "Деактивация",
"Dezactivat": "Отключено",
"Dezactivează": "Деактивировать", "Dezactivează": "Деактивировать",
"Dezactivează 2FA pentru acest utilizator. Va trebui să re-configureze TOTP la următoarea autentificare.": "Отключает 2FA для этого пользователя. Ему потребуется заново настроить TOTP при следующем входе.", "Dezactivează 2FA pentru acest utilizator. Va trebui să re-configureze TOTP la următoarea autentificare.": "Отключает 2FA для этого пользователя. Ему потребуется заново настроить TOTP при следующем входе.",
"Diagnosis": "Диагноз", "Diagnosis": "Диагноз",
@@ -965,6 +967,7 @@
"Loading": "Загрузка...", "Loading": "Загрузка...",
"Loc.": "Loc.", "Loc.": "Loc.",
"Local": "Локально", "Local": "Локально",
"Locale": "Локаль",
"Localizare & monedă": "Локализация и валюта", "Localizare & monedă": "Локализация и валюта",
"Location": "Локация", "Location": "Локация",
"Locație": "Локация", "Locație": "Локация",