Skip to content

Commit

Permalink
Merge pull request #267 from nextcloud/backport/231/stable28
Browse files Browse the repository at this point in the history
[stable28] feat: translate controller status messages
  • Loading branch information
juliusknorr authored Mar 21, 2024
2 parents 05cb882 + 6c3dc04 commit 72c53b1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/Controller/LockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use OCP\Files\Lock\ILock;
use OCP\Files\Lock\LockContext;
use OCP\Files\Lock\OwnerLockedException;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUserSession;

Expand All @@ -56,18 +57,20 @@
class LockController extends OCSController {
use TLogger;

private IUserSession $userSession;
private FileService $fileService;
private LockService $lockService;
private int $ocsVersion;

public function __construct(
IRequest $request, IUserSession $userSession, FileService $fileService, LockService $lockService
IRequest $request,
private IUserSession $userSession,
private FileService $fileService,
private LockService $lockService,
private IL10N $l10n,
) {
parent::__construct(Application::APP_ID, $request);
$this->userSession = $userSession;
$this->fileService = $fileService;
$this->lockService = $lockService;
$this->l10n = $l10n;

// We need to overload some implementation from the OCSController here
// to be able to push a custom message and data when returning other
Expand Down Expand Up @@ -147,12 +150,12 @@ private function buildOCSResponse($format, DataResponse $data) {
if ($data->getStatus() === Http::STATUS_LOCKED) {
/** @var FileLock $lock */
$lock = $data->getData();
$message = 'File is currently locked by ' . $lock->getOwner();
$message = $this->l10n->t('File is currently locked by %s', [$lock->getOwner()]);
}
if ($data->getStatus() === Http::STATUS_PRECONDITION_FAILED) {
/** @var FileLock $lock */
$lock = $data->getData();
$message = 'File is not locked';
$message = $this->l10n->t('File is not locked');
}

$containedData = $data->getData();
Expand Down

0 comments on commit 72c53b1

Please sign in to comment.