mirror of
https://github.com/grocy/grocy.git
synced 2025-08-15 02:04:38 +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()
|
||||
));
|
||||
}
|
||||
|
||||
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": {
|
||||
"description": "Returns all objects of the given entity",
|
||||
@@ -2197,6 +2238,14 @@
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"MissingLocalizationRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"text": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"examples": {
|
||||
|
@@ -3,6 +3,22 @@
|
||||
var localizedText = Grocy.LocalizationStrings[text];
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -64,7 +64,6 @@ $("#auto-reload-enabled").on("change", function()
|
||||
|
||||
jsonData = { };
|
||||
jsonData.value = value;
|
||||
console.log(jsonData);
|
||||
Grocy.Api.Post('user/settings/auto_reload_on_db_change', jsonData,
|
||||
function(result)
|
||||
{
|
||||
|
@@ -81,6 +81,7 @@ $app->group('/api', function()
|
||||
|
||||
// System
|
||||
$this->get('/system/get-db-changed-time', '\Grocy\Controllers\SystemApiController:GetDbChangedTime');
|
||||
$this->post('/system/log-missing-localization', '\Grocy\Controllers\SystemApiController:LogMissingLocalization');
|
||||
|
||||
// Files
|
||||
$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";
|
||||
|
||||
|
@@ -36,6 +36,7 @@
|
||||
<script>
|
||||
var Grocy = { };
|
||||
Grocy.Components = { };
|
||||
Grocy.Mode = '{{ GROCY_MODE }}';
|
||||
Grocy.BaseUrl = '{{ $U('/') }}';
|
||||
Grocy.LocalizationStrings = {!! json_encode($localizationStrings) !!};
|
||||
Grocy.ActiveNav = '@yield('activeNav', '')';
|
||||
|
Reference in New Issue
Block a user