mirror of
https://github.com/grocy/grocy.git
synced 2025-10-14 09:11:11 +00:00
Browser-cache localization strings (+ new API endpoint to get them)
This commit is contained in:
@@ -17,8 +17,13 @@ class BaseApiController extends BaseController
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
protected function ApiResponse(\Psr\Http\Message\ResponseInterface $response, $data)
|
||||
protected function ApiResponse(\Psr\Http\Message\ResponseInterface $response, $data, $cache = false)
|
||||
{
|
||||
if ($cache)
|
||||
{
|
||||
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($data));
|
||||
return $response;
|
||||
}
|
||||
|
@@ -129,7 +129,6 @@ class BaseController
|
||||
$this->View->set('__n', function ($number, $singularForm, $pluralForm) use ($localizationService) {
|
||||
return $localizationService->__n($number, $singularForm, $pluralForm);
|
||||
});
|
||||
$this->View->set('GettextPo', $localizationService->GetPoAsJsonString());
|
||||
|
||||
// TODO: Better handle this generically based on the current language (header in .po file?)
|
||||
$dir = 'ltr';
|
||||
|
@@ -85,6 +85,11 @@ class SystemApiController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
public function GetLocalizationStrings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->ApiResponse($response, json_decode($this->getLocalizationService()->GetPoAsJsonString()), true);
|
||||
}
|
||||
|
||||
public function __construct(\DI\Container $container)
|
||||
{
|
||||
parent::__construct($container);
|
||||
|
Reference in New Issue
Block a user