38 lines
937 B
PHP
38 lines
937 B
PHP
<?php
|
|
|
|
namespace Pterodactyl\Http\Controllers\Base;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Translation\Translator;
|
|
use Pterodactyl\Http\Controllers\Controller;
|
|
|
|
class LocaleController extends Controller
|
|
{
|
|
/**
|
|
* @var \Illuminate\Translation\Translator
|
|
*/
|
|
private $translator;
|
|
|
|
/**
|
|
* LocaleController constructor.
|
|
*/
|
|
public function __construct(Translator $translator)
|
|
{
|
|
$this->translator = $translator;
|
|
}
|
|
|
|
/**
|
|
* Returns translation data given a specific locale and namespace.
|
|
*
|
|
* @return \Illuminate\Http\JsonResponse
|
|
*/
|
|
public function __invoke(Request $request, string $locale, string $namespace)
|
|
{
|
|
$data = $this->translator->getLoader()->load($locale, str_replace('.', '/', $namespace));
|
|
|
|
return new JsonResponse($data, 200, [
|
|
'E-Tag' => md5(json_encode($data)),
|
|
]);
|
|
}
|
|
}
|