Implement localization for API responses and error messages
- Added localization support for API responses in English and Spanish. - Introduced a middleware to set the API locale based on the Accept-Language header. - Updated various exception messages and validation responses to use localized strings. - Created new language files for English and Spanish translations. - Refactored existing code to replace hardcoded messages with localized strings. - Added tests to verify localization functionality and response correctness.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Domains\Ticket\Controllers;
|
||||
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use App\Domains\Ticket\Exceptions\TicketNotAvailableException;
|
||||
use App\Domains\Ticket\Models\Ticket;
|
||||
use App\Domains\Ticket\Requests\DownloadTicketsPdfRequest;
|
||||
use App\Domains\Ticket\Resources\TicketResource;
|
||||
@@ -37,11 +38,9 @@ class TicketController extends Controller
|
||||
->orderByDesc('id')
|
||||
->get();
|
||||
|
||||
abort_if(
|
||||
$tickets->count() !== count($ticketIds),
|
||||
404,
|
||||
'Uno o más tickets no están disponibles.'
|
||||
);
|
||||
if ($tickets->count() !== count($ticketIds)) {
|
||||
throw new TicketNotAvailableException(__('api.ticket.not_available'));
|
||||
}
|
||||
|
||||
return $this->ticketPdfService->download($tenant, $tickets);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user