Skip to content

Commit

Permalink
Making the response message translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Oct 10, 2017
1 parent e7a5eff commit b4cf842
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Modules/Media/Http/Controllers/Api/MoveMediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,21 @@ public function __invoke(MoveMediaRequest $request)

return response()->json([
'errors' => $failedMoves > 0,
'message' => $failedMoves > 0 ? 'Some files were not moved' : 'Files moved successfully',
'message' => $this->getResponseMessage($failedMoves),
'folder_id' => $destination->id,
]);
}

/**
* @param int $failedMoves
* @return string
*/
protected function getResponseMessage(int $failedMoves) : string
{
if ($failedMoves > 0) {
return trans('media::media.some files not moved');
}

return trans('media::media.files moved successfully');
}
}
2 changes: 2 additions & 0 deletions Modules/Translation/Resources/lang/media/en/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@
'edit resource' => 'Edit media',
'destroy resource' => 'Delete media',
'file too large' => 'File is too large. Must be below :size MB.',
'some files not moved' => 'Some files were not moved',
'files moved successfully' => 'Files moved successfully',
];
2 changes: 2 additions & 0 deletions Modules/Translation/Resources/lang/media/fr/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@
'Browse' => 'Parcourir...',
'upload file' => 'Uploadez un fichier',
'remove media' => 'Supprimez le fichier',
'some files not moved' => 'Certains fichiers n\'ont pas été déplacés',
'files moved successfully' => 'Fichiers déplacés avec succès',
];
2 changes: 2 additions & 0 deletions Modules/Translation/Resources/lang/media/nl/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@
'Browse' => 'Bladeren ...',
'upload file' => 'File uploaded',
'remove media' => 'File verwijderen',
'some files not moved' => 'Sommige bestanden zijn niet verplaatst',
'files moved successfully' => 'Bestanden zijn succesvol verplaatst',
];

0 comments on commit b4cf842

Please sign in to comment.