Feature: Added translations for label generation API endpoint

This commit is contained in:
NebelKreis 2024-11-19 14:16:06 +01:00
parent 889aff43c2
commit 66d6b01307
2 changed files with 12 additions and 9 deletions

View file

@ -1230,7 +1230,7 @@ class AssetsController extends Controller
// Validate that asset tags were provided in the request
if (!$request->filled('asset_tags')) {
return response()->json(Helper::formatStandardApiResponse('error', null,
'No assets selected.'), 400);
trans('admin/hardware/message.no_assets_selected')), 400);
}
// Convert asset tags from request into collection and fetch matching assets
@ -1240,7 +1240,7 @@ class AssetsController extends Controller
// Return error if no assets were found for the provided tags
if ($assets->isEmpty()) {
return response()->json(Helper::formatStandardApiResponse('error', null,
'Asset does not exist.'), 404);
trans('admin/hardware/message.does_not_exist')), 404);
}
try {
@ -1287,14 +1287,14 @@ class AssetsController extends Controller
return response()->json(Helper::formatStandardApiResponse('success', [
'pdf' => $encoded_content
], 'Labels were successfully generated.'));
], trans('admin/hardware/message.labels_generated')));
} catch (\Exception $e) {
return response()->json(Helper::formatStandardApiResponse('error', [
'error_message' => $e->getMessage(),
'error_line' => $e->getLine(),
'error_file' => $e->getFile()
], 'Error while generating labels.'), 500);
], trans('admin/hardware/message.error_generating_labels')), 500);
}
} catch (\Exception $e) {
return response()->json(Helper::formatStandardApiResponse('error', [

View file

@ -2,13 +2,16 @@
return [
'undeployable' => '<strong>Warning: </strong> This asset has been marked as currently undeployable. If this status has changed, please update the asset status.',
'does_not_exist' => 'Asset does not exist.',
'does_not_exist_var'=> 'Asset with tag :asset_tag not found.',
'no_tag' => 'No asset tag provided.',
'undeployable' => '<strong>Warning: </strong> This asset has been marked as currently undeployable. If this status has changed, please update the asset status.',
'does_not_exist' => 'Asset does not exist.',
'does_not_exist_var' => 'Asset with tag :asset_tag not found.',
'no_tag' => 'No asset tag provided.',
'does_not_exist_or_not_requestable' => 'That asset does not exist or is not requestable.',
'assoc_users' => 'This asset is currently checked out to a user and cannot be deleted. Please check the asset in first, and then try deleting again. ',
'assoc_users' => 'This asset is currently checked out to a user and cannot be deleted. Please check the asset in first, and then try deleting again. ',
'warning_audit_date_mismatch' => 'This asset\'s next audit date (:next_audit_date) is before the last audit date (:last_audit_date). Please update the next audit date.',
'labels_generated' => 'Labels were successfully generated.',
'error_generating_labels' => 'Error while generating labels.',
'no_assets_selected' => 'No assets selected.',
'create' => [
'error' => 'Asset was not created, please try again. :(',