Skip to content

Commit a1a6919

Browse files
skjnldsvjuliusknorr
authored andcommitted
feat: translate controller status messages
Signed-off-by: John Molakvoæ <[email protected]>
1 parent ea5ba01 commit a1a6919

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/Controller/LockController.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use OCP\Files\Lock\ILock;
4646
use OCP\Files\Lock\LockContext;
4747
use OCP\Files\Lock\OwnerLockedException;
48+
use OCP\IL10N;
4849
use OCP\IRequest;
4950
use OCP\IUserSession;
5051

@@ -55,19 +56,24 @@
5556
*/
5657
class LockController extends OCSController {
5758
use TLogger;
58-
5959
private IUserSession $userSession;
6060
private FileService $fileService;
6161
private LockService $lockService;
62+
private IL10N $l10n;
6263
private int $ocsVersion;
6364

6465
public function __construct(
65-
IRequest $request, IUserSession $userSession, FileService $fileService, LockService $lockService
66+
IRequest $request,
67+
IUserSession $userSession,
68+
FileService $fileService,
69+
LockService $lockService,
70+
IL10N $l10n
6671
) {
6772
parent::__construct(Application::APP_ID, $request);
6873
$this->userSession = $userSession;
6974
$this->fileService = $fileService;
7075
$this->lockService = $lockService;
76+
$this->l10n = $l10n;
7177

7278
// We need to overload some implementation from the OCSController here
7379
// to be able to push a custom message and data when returning other
@@ -147,12 +153,12 @@ private function buildOCSResponse($format, DataResponse $data) {
147153
if ($data->getStatus() === Http::STATUS_LOCKED) {
148154
/** @var FileLock $lock */
149155
$lock = $data->getData();
150-
$message = 'File is currently locked by ' . $lock->getOwner();
156+
$message = $this->l10n->t('File is currently locked by %s', [$lock->getOwner()]);
151157
}
152158
if ($data->getStatus() === Http::STATUS_PRECONDITION_FAILED) {
153159
/** @var FileLock $lock */
154160
$lock = $data->getData();
155-
$message = 'File is not locked';
161+
$message = $this->l10n->t('File is not locked');
156162
}
157163

158164
$containedData = $data->getData();

0 commit comments

Comments
 (0)