feat(i18n): wrap 1103 hardcoded UI strings across Filament with __()

- Convert static $modelLabel/$pluralModelLabel/$title to getter methods
- Wrap ->label()/->placeholder()/->helperText()/->description()/->title()/->body() args
- Wrap Section::make()/Fieldset::make()/Notification::make()->title() args
- Fix RelationManagers::getTitle() signature to match parent (Model, string)
- Fix Pages::getTitle() to instance method (BasePage::getTitle is non-static)
- Extend lang/ru.json + lang/en.json with 700+ common terms; identity fallback for the rest
- Remove duplicate getters in 5 resources that had manual getModelLabel already

All 306 tests pass. Missing translations fall back to the RO key so the UI never breaks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-15 05:04:24 +00:00
parent 78ff8d4b43
commit f7fc69077b
83 changed files with 4212 additions and 1251 deletions
+70 -65
View File
@@ -27,7 +27,12 @@ class Settings extends Page
protected static ?int $navigationSort = 90;
protected static ?string $title = 'Setări companie';
protected static ?string $title = null;
public function getTitle(): string
{
return __('Setări companie');
}
protected string $view = 'filament.tenant.pages.settings';
@@ -81,23 +86,23 @@ class Settings extends Page
{
return $schema
->components([
Schemas\Components\Section::make('Brand & contact')
Schemas\Components\Section::make(__('Brand & contact'))
->columns(2)
->schema([
Forms\Components\TextInput::make('display_name')->label('Denumire afișată')->maxLength(120),
Forms\Components\TextInput::make('city')->label('Oraș')->maxLength(60),
Forms\Components\TextInput::make('phone')->label('Telefon')->tel()->maxLength(40),
Forms\Components\TextInput::make('display_name')->label(__('Denumire afișată'))->maxLength(120),
Forms\Components\TextInput::make('city')->label(__('Oraș'))->maxLength(60),
Forms\Components\TextInput::make('phone')->label(__('Telefon'))->tel()->maxLength(40),
Forms\Components\TextInput::make('email')->email()->maxLength(120),
]),
Schemas\Components\Section::make('Localizare & monedă')
Schemas\Components\Section::make(__('Localizare & monedă'))
->columns(3)
->schema([
Forms\Components\Select::make('language')
->label('Limbă default')
->label(__('Limbă default'))
->options(['ro' => 'Română', 'ru' => 'Русский', 'en' => 'English'])
->required(),
Forms\Components\Select::make('currency')
->label('Monedă')
->label(__('Monedă'))
->options([
'MDL' => 'MDL — Leu moldovenesc',
'EUR' => 'EUR — Euro',
@@ -108,133 +113,133 @@ class Settings extends Page
])
->required()
->searchable(),
Forms\Components\ColorPicker::make('theme_color')->label('Culoare brand'),
Forms\Components\ColorPicker::make('theme_color')->label(__('Culoare brand')),
]),
Schemas\Components\Section::make('Servicii & tarif')
Schemas\Components\Section::make(__('Servicii & tarif'))
->columns(2)
->schema([
Forms\Components\TextInput::make('labor_rate')->label('Tarif normo-oră')->numeric()->required(),
Forms\Components\TextInput::make('labor_rate')->label(__('Tarif normo-oră'))->numeric()->required(),
]),
Schemas\Components\Section::make('Marjă internă (nu TVA)')
->description('Procent implicit aplicat la manopere. Se scade din prețul de manoperă pentru a determina baza salariului mecanicului. Vizibilă doar rolurilor cu drept „finance.view_internal_margin".')
Schemas\Components\Section::make(__('Marjă internă (nu TVA)'))
->description(__('Procent implicit aplicat la manopere. Se scade din prețul de manoperă pentru a determina baza salariului mecanicului. Vizibilă doar rolurilor cu drept „finance.view_internal_margin".'))
->columns(2)
->visible(fn () => auth()->user()?->canDo(\App\Auth\Permissions::FINANCE_VIEW_INTERNAL_MARGIN) ?? false)
->schema([
Forms\Components\TextInput::make('default_internal_margin_pct')
->label('% marjă implicit')
->label(__('% marjă implicit'))
->numeric()
->step(0.01)
->minValue(0)
->maxValue(90)
->suffix('%')
->placeholder('Ex: 20')
->helperText('Fallback când mecanicul nu are marja proprie setată. Lasă gol = 0%.'),
->placeholder(__('Ex: 20'))
->helperText(__('Fallback când mecanicul nu are marja proprie setată. Lasă gol = 0%.')),
Forms\Components\Toggle::make('show_internal_margin_details')
->label('Afișează detalii marjă la procesele calculate')
->helperText('On = arată „Bază salariu: X · marjă Y%" sub Total în tabelul Manopere. Off = doar Total (util când review-uiești o Fișă cu clientul de față).')
->label(__('Afișează detalii marjă la procesele calculate'))
->helperText(__('On = arată „Bază salariu: X · marjă Y%" sub Total în tabelul Manopere. Off = doar Total (util când review-uiești o Fișă cu clientul de față).'))
->default(true),
]),
Schemas\Components\Section::make('Liste configurabile')
Schemas\Components\Section::make(__('Liste configurabile'))
->columns(1)
->schema([
Forms\Components\Textarea::make('services')
->label('Servicii oferite (separate prin virgulă)')
->label(__('Servicii oferite (separate prin virgulă)'))
->rows(2),
Forms\Components\Textarea::make('cars')
->label('Mărci auto suportate (separate prin virgulă)')
->label(__('Mărci auto suportate (separate prin virgulă)'))
->rows(2),
]),
Schemas\Components\Section::make('Logo & favicon')
Schemas\Components\Section::make(__('Logo & favicon'))
->columns(2)
->schema([
Forms\Components\FileUpload::make('logo')
->label('Logo')
->label(__('Logo'))
->image()
->imageEditor()
->disk('public')
->directory('tmp-uploads')
->visibility('public')
->maxSize(2048)
->helperText('PNG/SVG, max 2 MB. Apare în sidebar.'),
->helperText(__('PNG/SVG, max 2 MB. Apare în sidebar.')),
Forms\Components\FileUpload::make('favicon')
->label('Favicon')
->label(__('Favicon'))
->image()
->disk('public')
->directory('tmp-uploads')
->visibility('public')
->maxSize(512)
->helperText('PNG/ICO, max 512 KB.'),
->helperText(__('PNG/ICO, max 512 KB.')),
]),
Schemas\Components\Section::make('Notificări')
->description('Activează / dezactivează notificările auto către clienți. Telegram are prioritate dacă clientul are cont legat.')
Schemas\Components\Section::make(__('Notificări'))
->description(__('Activează / dezactivează notificările auto către clienți. Telegram are prioritate dacă clientul are cont legat.'))
->columns(2)
->schema([
Forms\Components\Toggle::make('notify_wo_ready')->label('Mașina e gata de ridicat')->default(true),
Forms\Components\Toggle::make('notify_payment')->label('Confirmare plată primită')->default(true),
Forms\Components\Toggle::make('notify_appointment')->label('Programare confirmată')->default(true),
Forms\Components\Toggle::make('notify_reminder')->label('Reminder ITP / revizie')->default(true),
Forms\Components\Toggle::make('notify_wo_ready')->label(__('Mașina e gata de ridicat'))->default(true),
Forms\Components\Toggle::make('notify_payment')->label(__('Confirmare plată primită'))->default(true),
Forms\Components\Toggle::make('notify_appointment')->label(__('Programare confirmată'))->default(true),
Forms\Components\Toggle::make('notify_reminder')->label(__('Reminder ITP / revizie'))->default(true),
]),
Schemas\Components\Section::make('Telegram bot')
->description('Creează un bot la @BotFather, lipește token-ul aici și apasă „Setează webhook". Clienții îți scriu la bot, partajează telefonul, iar codul se leagă automat de fișa lor.')
Schemas\Components\Section::make(__('Telegram bot'))
->description(__('Creează un bot la @BotFather, lipește token-ul aici și apasă „Setează webhook". Clienții îți scriu la bot, partajează telefonul, iar codul se leagă automat de fișa lor.'))
->columns(1)
->schema([
Forms\Components\TextInput::make('telegram_bot_token')
->label('Bot token')
->label(__('Bot token'))
->password()
->revealable()
->placeholder('123456:ABC-XYZ...')
->placeholder(__('123456:ABC-XYZ...'))
->helperText(fn () => 'Webhook URL: ' .
app(\App\Services\Notifications\TelegramService::class)
->webhookUrlFor(app(\App\Tenancy\TenantManager::class)->current())),
]),
Schemas\Components\Section::make('Reminder service auto')
Schemas\Components\Section::make(__('Reminder service auto'))
->columns(2)
->schema([
Forms\Components\TextInput::make('reminder_after_days')
->label('Trimite reminder după X zile fără vizită')
->label(__('Trimite reminder după X zile fără vizită'))
->numeric()
->minValue(30)
->default(365),
Forms\Components\TextInput::make('reminder_cooldown_days')
->label('Nu re-trimite mai des de X zile')
->label(__('Nu re-trimite mai des de X zile'))
->numeric()
->minValue(7)
->default(30),
]),
Schemas\Components\Section::make('Magazin online')
->description('Activează magazinul public la <slug>.service.mir.md/shop. Piesele apar doar dacă sunt marcate „Publicat".')
Schemas\Components\Section::make(__('Magazin online'))
->description(__('Activează magazinul public la <slug>.service.mir.md/shop. Piesele apar doar dacă sunt marcate „Publicat".'))
->columns(2)
->schema([
Forms\Components\Toggle::make('shop_enabled')->label('Magazin activ')->columnSpanFull(),
Forms\Components\Toggle::make('shop_enabled')->label(__('Magazin activ'))->columnSpanFull(),
Forms\Components\CheckboxList::make('shop_delivery_methods')
->label('Metode de livrare')
->label(__('Metode de livrare'))
->options(\App\Models\Tenant\OnlineOrder::DELIVERY)
->default(['pickup'])
->columnSpanFull(),
Forms\Components\TextInput::make('shop_delivery_fee')->label('Taxă livrare')->numeric()->default(0),
Forms\Components\TextInput::make('shop_free_delivery_over')->label('Livrare gratuită peste')->numeric()->default(0)->helperText('0 = dezactivat'),
Forms\Components\TextInput::make('shop_delivery_fee')->label(__('Taxă livrare'))->numeric()->default(0),
Forms\Components\TextInput::make('shop_free_delivery_over')->label(__('Livrare gratuită peste'))->numeric()->default(0)->helperText(__('0 = dezactivat')),
]),
Schemas\Components\Section::make('Asistent AI')
->description('Adaugă chei API ca să activezi asistentul. Cheile rămân la voi — nu sunt partajate.')
Schemas\Components\Section::make(__('Asistent AI'))
->description(__('Adaugă chei API ca să activezi asistentul. Cheile rămân la voi — nu sunt partajate.'))
->columns(2)
->schema([
Forms\Components\Select::make('ai_default_provider')
->label('Provider implicit')
->label(__('Provider implicit'))
->options(['claude' => 'Claude (Anthropic)', 'gpt' => 'ChatGPT (OpenAI)', 'gemini' => 'Gemini (Google)'])
->default('claude'),
Forms\Components\TextInput::make('ai_claude_key')->label('Claude API Key')->password()->revealable()->placeholder('sk-ant-...'),
Forms\Components\TextInput::make('ai_claude_key')->label(__('Claude API Key'))->password()->revealable()->placeholder('sk-ant-...'),
Forms\Components\Select::make('ai_model_claude')
->label('Model Claude')
->label(__('Model Claude'))
->options(\App\Services\Ai\AiAssistantService::MODEL_OPTIONS['claude'])
->default(\App\Services\Ai\AiAssistantService::MODEL_DEFAULTS['claude']),
Forms\Components\TextInput::make('ai_gpt_key')->label('OpenAI API Key')->password()->revealable()->placeholder('sk-proj-...'),
Forms\Components\TextInput::make('ai_gpt_key')->label(__('OpenAI API Key'))->password()->revealable()->placeholder('sk-proj-...'),
Forms\Components\Select::make('ai_model_gpt')
->label('Model OpenAI')
->label(__('Model OpenAI'))
->options(\App\Services\Ai\AiAssistantService::MODEL_OPTIONS['gpt'])
->default(\App\Services\Ai\AiAssistantService::MODEL_DEFAULTS['gpt']),
Forms\Components\TextInput::make('ai_gemini_key')->label('Gemini API Key')->password()->revealable(),
Forms\Components\TextInput::make('ai_gemini_key')->label(__('Gemini API Key'))->password()->revealable(),
Forms\Components\Select::make('ai_model_gemini')
->label('Model Gemini')
->label(__('Model Gemini'))
->options(\App\Services\Ai\AiAssistantService::MODEL_OPTIONS['gemini'])
->default(\App\Services\Ai\AiAssistantService::MODEL_DEFAULTS['gemini']),
]),
@@ -247,7 +252,7 @@ class Settings extends Page
$data = $this->form->getState();
$company = app(TenantManager::class)->current();
if (! $company) {
Notification::make()->title('Tenant not resolved')->danger()->send();
Notification::make()->title(__('Tenant not resolved'))->danger()->send();
return;
}
@@ -312,22 +317,22 @@ class Settings extends Page
}
}
Notification::make()->title('Setări salvate')->success()->send();
Notification::make()->title(__('Setări salvate'))->success()->send();
}
protected function getHeaderActions(): array
{
return [
Actions\Action::make('push_test')
->label('Test notificare push')
->label(__('Test notificare push'))
->icon('heroicon-m-bell-alert')
->color('gray')
->action(function () {
$svc = app(\App\Services\Notifications\WebPushService::class);
if (! $svc->configured()) {
Notification::make()
->title('Web Push neconfigurat')
->body('Rulează `php artisan push:vapid` și adaugă cheile în .env.')
->title(__('Web Push neconfigurat'))
->body(__('Rulează `php artisan push:vapid` și adaugă cheile în .env.'))
->warning()->send();
return;
}
@@ -344,7 +349,7 @@ class Settings extends Page
->send();
}),
Actions\Action::make('telegram_test')
->label('Testează bot Telegram')
->label(__('Testează bot Telegram'))
->icon('heroicon-m-bolt')
->color('gray')
->action(function () {
@@ -353,7 +358,7 @@ class Settings extends Page
$r = app(TelegramService::class)->getMe($company);
if (! ($r['ok'] ?? false)) {
Notification::make()
->title('Bot Telegram nu răspunde')
->title(__('Bot Telegram nu răspunde'))
->body($r['error'] ?? 'Verifică token-ul.')
->danger()->send();
return;
@@ -364,24 +369,24 @@ class Settings extends Page
->success()->send();
}),
Actions\Action::make('telegram_webhook')
->label('Setează webhook')
->label(__('Setează webhook'))
->icon('heroicon-m-link')
->color('primary')
->requiresConfirmation()
->modalDescription('Telegram va trimite mesajele primite la URL-ul webhook de mai jos.')
->modalDescription(__('Telegram va trimite mesajele primite la URL-ul webhook de mai jos.'))
->action(function () {
$company = app(TenantManager::class)->current();
if (! $company) return;
$r = app(TelegramService::class)->setWebhook($company);
if (! ($r['ok'] ?? false)) {
Notification::make()
->title('Webhook eșuat')
->title(__('Webhook eșuat'))
->body($r['error'] ?? json_encode($r['response'] ?? []))
->danger()->send();
return;
}
Notification::make()
->title('Webhook setat — botul e gata')
->title(__('Webhook setat — botul e gata'))
->success()->send();
}),
];