23 lines
503 B
PHP
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));
|
|
}
|
|
}
|