Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] feat: translate controller status messages #268

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 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 @@ -55,19 +56,24 @@
*/
class LockController extends OCSController {
use TLogger;

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

public function __construct(
IRequest $request, IUserSession $userSession, FileService $fileService, LockService $lockService
IRequest $request,
IUserSession $userSession,
FileService $fileService,
LockService $lockService,
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 +153,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
Loading