Skip to content

Commit e3687cd

Browse files
committed
refactor: avoid translating dynamic reason strings
Signed-off-by: Vitor Mattos <[email protected]>
1 parent 699b132 commit e3687cd

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

lib/Service/Signature/PdfSignatureValidationService.php

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -166,25 +166,25 @@ private function mapSignatureValidation(ValidationResult $result): array {
166166
ValidationState::SIGNATURE_INVALID => [
167167
'id' => 2,
168168
'label' => $this->l10n->t('Signature is invalid.'),
169-
'reason' => $this->translateReason($result->reason),
169+
'reason' => $result->reason,
170170
'isValid' => false,
171171
],
172172
ValidationState::DIGEST_MISMATCH => [
173173
'id' => 3,
174174
'label' => $this->l10n->t('Digest mismatch.'),
175-
'reason' => $this->translateReason($result->reason),
175+
'reason' => $result->reason,
176176
'isValid' => false,
177177
],
178178
ValidationState::NOT_VERIFIED => [
179179
'id' => 5,
180180
'label' => $this->l10n->t('Signature has not yet been verified.'),
181-
'reason' => $this->translateReason($result->reason),
181+
'reason' => $result->reason,
182182
'isValid' => false,
183183
],
184184
default => [
185185
'id' => 6,
186186
'label' => $this->l10n->t('Unknown validation failure.'),
187-
'reason' => $this->translateReason($result->reason),
187+
'reason' => $result->reason,
188188
'isValid' => false,
189189
],
190190
};
@@ -203,50 +203,42 @@ private function mapCertificateValidation(ValidationResult $result): array {
203203
ValidationState::CERT_ISSUER_NOT_TRUSTED => [
204204
'id' => 2,
205205
'label' => $this->l10n->t("Certificate issuer isn't trusted."),
206-
'reason' => $this->translateReason($result->reason),
206+
'reason' => $result->reason,
207207
'isValid' => false,
208208
],
209209
ValidationState::CERT_ISSUER_UNKNOWN => [
210210
'id' => 3,
211211
'label' => $this->l10n->t('Certificate issuer is unknown.'),
212-
'reason' => $this->translateReason($result->reason),
212+
'reason' => $result->reason,
213213
'isValid' => false,
214214
],
215215
ValidationState::CERT_REVOKED => [
216216
'id' => 4,
217217
'label' => $this->l10n->t('Certificate has been revoked.'),
218-
'reason' => $this->translateReason($result->reason),
218+
'reason' => $result->reason,
219219
'isValid' => false,
220220
],
221221
ValidationState::CERT_EXPIRED => [
222222
'id' => 5,
223223
'label' => $this->l10n->t('Certificate has expired.'),
224-
'reason' => $this->translateReason($result->reason),
224+
'reason' => $result->reason,
225225
'isValid' => false,
226226
],
227227
ValidationState::CERT_NOT_VERIFIED => [
228228
'id' => 6,
229229
'label' => $this->l10n->t('Certificate has not yet been verified.'),
230-
'reason' => $this->translateReason($result->reason),
230+
'reason' => $result->reason,
231231
'isValid' => false,
232232
],
233233
default => [
234234
'id' => 7,
235235
'label' => $this->l10n->t('Unknown issue with certificate or corrupted data.'),
236-
'reason' => $this->translateReason($result->reason),
236+
'reason' => $result->reason,
237237
'isValid' => false,
238238
],
239239
};
240240
}
241241

242-
private function translateReason(?string $reason): ?string {
243-
if ($reason === null || $reason === '') {
244-
return $reason;
245-
}
246-
247-
return $this->l10n->t($reason);
248-
}
249-
250242
/**
251243
* Check if LibreSign CA is loaded.
252244
*/

0 commit comments

Comments
 (0)