mirror of
https://github.com/grocy/grocy.git
synced 2025-08-15 10:14:39 +00:00
Also log missing localization found in frontend (only when MODE == dev)
This commit is contained in:
@@ -20,4 +20,22 @@ class SystemApiController extends BaseApiController
|
|||||||
'changed_time' => $this->DatabaseService->GetDbChangedTime()
|
'changed_time' => $this->DatabaseService->GetDbChangedTime()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function LogMissingLocalization(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
|
{
|
||||||
|
if (GROCY_MODE === 'dev')
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$requestBody = $request->getParsedBody();
|
||||||
|
|
||||||
|
$this->LocalizationService->LogMissingLocalization(GROCY_CULTURE, $requestBody['text']);
|
||||||
|
return $this->ApiResponse(array('success' => true));
|
||||||
|
}
|
||||||
|
catch (\Exception $ex)
|
||||||
|
{
|
||||||
|
return $this->VoidApiActionResponse($response, false, 400, $ex->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,47 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/system/log-missing-localization": {
|
||||||
|
"post": {
|
||||||
|
"description": "Logs a missing localization string (only when MODE == 'dev', so should only be called then)",
|
||||||
|
"tags": [
|
||||||
|
"System"
|
||||||
|
],
|
||||||
|
"requestBody": {
|
||||||
|
"description": "A valid MissingLocalizationRequest object",
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/MissingLocalizationRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A VoidApiActionResponse object",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/VoidApiActionResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "A VoidApiActionResponse object",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/ErrorExampleVoidApiActionResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/get-objects/{entity}": {
|
"/get-objects/{entity}": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "Returns all objects of the given entity",
|
"description": "Returns all objects of the given entity",
|
||||||
@@ -2197,6 +2238,14 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"MissingLocalizationRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"text": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"examples": {
|
"examples": {
|
||||||
|
@@ -3,6 +3,22 @@
|
|||||||
var localizedText = Grocy.LocalizationStrings[text];
|
var localizedText = Grocy.LocalizationStrings[text];
|
||||||
if (localizedText === undefined)
|
if (localizedText === undefined)
|
||||||
{
|
{
|
||||||
|
if (Grocy.Mode === 'dev')
|
||||||
|
{
|
||||||
|
jsonData = {};
|
||||||
|
jsonData.text = text;
|
||||||
|
Grocy.Api.Post('system/log-missing-localization', jsonData,
|
||||||
|
function(result)
|
||||||
|
{
|
||||||
|
// Nothing to do...
|
||||||
|
},
|
||||||
|
function(xhr)
|
||||||
|
{
|
||||||
|
console.log(xhr)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
localizedText = text;
|
localizedText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,7 +64,6 @@ $("#auto-reload-enabled").on("change", function()
|
|||||||
|
|
||||||
jsonData = { };
|
jsonData = { };
|
||||||
jsonData.value = value;
|
jsonData.value = value;
|
||||||
console.log(jsonData);
|
|
||||||
Grocy.Api.Post('user/settings/auto_reload_on_db_change', jsonData,
|
Grocy.Api.Post('user/settings/auto_reload_on_db_change', jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
|
@@ -81,6 +81,7 @@ $app->group('/api', function()
|
|||||||
|
|
||||||
// System
|
// System
|
||||||
$this->get('/system/get-db-changed-time', '\Grocy\Controllers\SystemApiController:GetDbChangedTime');
|
$this->get('/system/get-db-changed-time', '\Grocy\Controllers\SystemApiController:GetDbChangedTime');
|
||||||
|
$this->post('/system/log-missing-localization', '\Grocy\Controllers\SystemApiController:LogMissingLocalization');
|
||||||
|
|
||||||
// Files
|
// Files
|
||||||
$this->post('/files/upload/{group}', '\Grocy\Controllers\FilesApiController:Upload');
|
$this->post('/files/upload/{group}', '\Grocy\Controllers\FilesApiController:Upload');
|
||||||
|
@@ -34,7 +34,7 @@ class LocalizationService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function LogMissingLocalization(string $culture, string $text)
|
public function LogMissingLocalization(string $culture, string $text)
|
||||||
{
|
{
|
||||||
$file = GROCY_DATAPATH . "/missing_translations_$culture.json";
|
$file = GROCY_DATAPATH . "/missing_translations_$culture.json";
|
||||||
|
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
<script>
|
<script>
|
||||||
var Grocy = { };
|
var Grocy = { };
|
||||||
Grocy.Components = { };
|
Grocy.Components = { };
|
||||||
|
Grocy.Mode = '{{ GROCY_MODE }}';
|
||||||
Grocy.BaseUrl = '{{ $U('/') }}';
|
Grocy.BaseUrl = '{{ $U('/') }}';
|
||||||
Grocy.LocalizationStrings = {!! json_encode($localizationStrings) !!};
|
Grocy.LocalizationStrings = {!! json_encode($localizationStrings) !!};
|
||||||
Grocy.ActiveNav = '@yield('activeNav', '')';
|
Grocy.ActiveNav = '@yield('activeNav', '')';
|
||||||
|
Reference in New Issue
Block a user