Files
speedBB/app/Http/Controllers/I18nController.php
2025-12-29 18:19:24 +01:00

23 lines
503 B
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\File;
class I18nController extends Controller
{
public function __invoke(string $locale): JsonResponse
{
$path = resource_path("lang/{$locale}.json");
if (!File::exists($path)) {
return response()->json([], 404);
}
$contents = File::get($path);
return response()->json(json_decode($contents, true, 512, JSON_THROW_ON_ERROR));
}
}