Skip to content

Commit dfe9bb0

Browse files
authored
Merge pull request #6149 from LibreSign/backport/6148/stable31
[stable31] refactor: centralize file status translations in FileStatus enum
2 parents b9a204c + 2b9e928 commit dfe9bb0

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

lib/Db/FileMapper.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -250,20 +250,7 @@ public function getTextOfStatus(int|FileStatus $status): string {
250250
if (is_int($status)) {
251251
$status = FileStatus::from($status);
252252
}
253-
return match ($status) {
254-
// TRANSLATORS Name of the status when document is not a LibreSign file
255-
FileStatus::NOT_LIBRESIGN_FILE => $this->l->t('not LibreSign file'),
256-
// TRANSLATORS Name of the status that the document is still as a draft
257-
FileStatus::DRAFT => $this->l->t('draft'),
258-
// TRANSLATORS Name of the status that the document can be signed
259-
FileStatus::ABLE_TO_SIGN => $this->l->t('available for signature'),
260-
// TRANSLATORS Name of the status when the document has already been partially signed
261-
FileStatus::PARTIAL_SIGNED => $this->l->t('partially signed'),
262-
// TRANSLATORS Name of the status when the document has been completely signed
263-
FileStatus::SIGNED => $this->l->t('signed'),
264-
// TRANSLATORS Name of the status when the document was deleted
265-
FileStatus::DELETED => $this->l->t('deleted'),
266-
};
253+
return $status->getLabel($this->l);
267254
}
268255

269256
public function neutralizeDeletedUser(string $userId, string $displayName): void {

lib/Enum/FileStatus.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace OCA\Libresign\Enum;
1111

12+
use OCP\IL10N;
13+
1214
/**
1315
* File status enum
1416
*
@@ -21,4 +23,21 @@ enum FileStatus: int {
2123
case PARTIAL_SIGNED = 2;
2224
case SIGNED = 3;
2325
case DELETED = 4;
26+
27+
public function getLabel(IL10N $l10n): string {
28+
return match($this) {
29+
// TRANSLATORS Name of the status when document is not a LibreSign file
30+
self::NOT_LIBRESIGN_FILE => $l10n->t('not LibreSign file'),
31+
// TRANSLATORS Name of the status that the document is still as a draft
32+
self::DRAFT => $l10n->t('draft'),
33+
// TRANSLATORS Name of the status that the document can be signed
34+
self::ABLE_TO_SIGN => $l10n->t('available for signature'),
35+
// TRANSLATORS Name of the status when the document has already been partially signed
36+
self::PARTIAL_SIGNED => $l10n->t('partially signed'),
37+
// TRANSLATORS Name of the status when the document has been completely signed
38+
self::SIGNED => $l10n->t('signed'),
39+
// TRANSLATORS Name of the status when the document was deleted
40+
self::DELETED => $l10n->t('deleted'),
41+
};
42+
}
2443
}

0 commit comments

Comments
 (0)