Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/Handler/SignEngine/SignEngineHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function generateCertificate(array $user, string $signPassword, string $f
throw new LibresignException($this->l10n->t('Invalid data to generate certificate'));
} catch (\Throwable) {
// TRANSLATORS Error while LibreSign creates a user's signing certificate: the certificate engine failed unexpectedly during generation.
throw new LibresignException($this->l10n->t('Failure on generate certificate'));
throw new LibresignException($this->l10n->t('Failure to generate certificate'));
}
if (!$content) {
// TRANSLATORS Error while LibreSign creates a user's signing certificate: generation finished without returning a PFX/certificate payload.
Expand Down
6 changes: 3 additions & 3 deletions lib/Service/Certificate/ValidateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private function validateString(string $fieldName, string $value, array $rule):
if ($length > $rule['max'] || $length < $rule['min']) {
throw new InvalidArgumentException(
// TRANSLATORS Error shown when a certificate subject field length is outside the allowed range. %s is the field name; the next values are the minimum and maximum length.
$this->l10n->t("Parameter '%s' should be betweeen %s and %s.", [$fieldName, $rule['min'], $rule['max']])
$this->l10n->t("Parameter '%s' should be between %s and %s.", [$fieldName, $rule['min'], $rule['max']])
);
}
}
Expand All @@ -67,13 +67,13 @@ private function validateArray(string $fieldName, array $values, array $rule): v
if (isset($rule['minItems']) && $arrayLength < $rule['minItems']) {
throw new InvalidArgumentException(
// TRANSLATORS Error shown when a certificate subject field has too few values. %s is the field name with "items"; the next values are the allowed minimum and maximum counts.
$this->l10n->t("Parameter '%s' should be betweeen %s and %s.", [$fieldName . ' items', $rule['minItems'], $rule['maxItems'] ?? '∞'])
$this->l10n->t("Parameter '%s' should be between %s and %s.", [$fieldName . ' items', $rule['minItems'], $rule['maxItems'] ?? '∞'])
);
}
if (isset($rule['maxItems']) && $arrayLength > $rule['maxItems']) {
throw new InvalidArgumentException(
// TRANSLATORS Error shown when a certificate subject field has too many values. %s is the field name with "items"; the next values are the allowed minimum and maximum counts.
$this->l10n->t("Parameter '%s' should be betweeen %s and %s.", [$fieldName . ' items', $rule['minItems'] ?? 0, $rule['maxItems']])
$this->l10n->t("Parameter '%s' should be between %s and %s.", [$fieldName . ' items', $rule['minItems'] ?? 0, $rule['maxItems']])
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Service/NotifyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private function validateSignerForNotification(array $signer, array $signRequest
if ($error !== null) {
$message = match ($error['code']) {
// TRANSLATORS Error shown when notifying a person who was never asked to sign. %s is the signer identifier.
'not_requested' => $this->l10n->t('No signature was requested to %s', $error['params']),
'not_requested' => $this->l10n->t('No signature was requested from %s', $error['params']),
// TRANSLATORS Error shown when notifying a signer who already completed their signature. %s is the signer name.
'already_signed' => $this->l10n->t('%s already signed this file', $error['params']),
// TRANSLATORS Error shown when the signer data used for a notification is invalid.
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/SignFileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function canDeleteRequestSignature(array $data): void {
});
if (!$exists) {
// TRANSLATORS Error shown when notifying or signing for a person who was never asked to sign. %s is their email.
throw new \Exception($this->l10n->t('No signature was requested to %s', $signer['email']));
throw new \Exception($this->l10n->t('No signature was requested from %s', $signer['email']));
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ const _filesStore = defineStore('files', () => {
}
})
.catch((error) => {
const message = error.response?.data?.ocs?.data?.message || t('libresign', 'Failed to remove file(s) from envelope')
const message = error.response?.data?.ocs?.data?.message || t('libresign', 'Failed to remove one or more files from the envelope')
return {
success: false,
message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { t } from '@nextcloud/l10n'
import { n, t } from '@nextcloud/l10n'

import type { EffectivePolicyValue } from '../../../../../types/index'
import type { RealPolicySettingDefinition } from '../realTypes'
Expand Down Expand Up @@ -146,8 +146,8 @@ export const expiryInDaysRealDefinition: RealPolicySettingDefinition = {
},
summarizeValue: (value: EffectivePolicyValue) => {
const normalized = normalizePositiveInt(value, DEFAULT_EXPIRY_IN_DAYS)
// TRANSLATORS Summary value. {value} is number of days before generated certificate expiration.
return t('libresign', '{value} days', { value: String(normalized) })
// TRANSLATORS Summary value. %n is number of days before generated certificate expiration.
return n('libresign', '%n day', '%n days', normalized)
},
formatAllowOverride: (allowChildOverride: boolean) =>
allowChildOverride
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { loadState } from '@nextcloud/initial-state'
import { t } from '@nextcloud/l10n'
import { n, t } from '@nextcloud/l10n'

import IdentifyMethodsRuleEditor from './IdentifyMethodsRuleEditor.vue'

Expand Down Expand Up @@ -105,8 +105,8 @@ export const identifyMethodsRealDefinition: RealPolicySettingDefinition = {
return enabled.map((entry) => entry.friendly_name ?? entry.name).join(', ')
}

// TRANSLATORS Summary showing how many identification factors are enabled. {count} is the number of enabled factors.
return t('libresign', '{count} enabled factors', { count: String(enabled.length) })
// TRANSLATORS Summary showing how many identification factors are enabled. %n is the number of enabled factors.
return n('libresign', '%n enabled factor', '%n enabled factors', enabled.length)
},
formatAllowOverride: (allowChildOverride: boolean) => {
if (allowChildOverride) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { t } from '@nextcloud/l10n'
import { n, t } from '@nextcloud/l10n'

import RequestSignGroupsRuleEditor from './RequestSignGroupsRuleEditor.vue'

Expand Down Expand Up @@ -100,8 +100,8 @@ export const requestSignGroupsRealDefinition: RealPolicySettingDefinition = {
return denyGroups.join(', ')
}

// TRANSLATORS {count} is the number of groups explicitly denied from creating signature requests.
return t('libresign', '{count} denied requester groups', { count: String(denyGroups.length) })
// TRANSLATORS %n is the number of groups explicitly denied from creating signature requests.
return n('libresign', '%n denied requester group', '%n denied requester groups', denyGroups.length)
}

if (allowGroups.length === 0) {
Expand All @@ -114,8 +114,8 @@ export const requestSignGroupsRealDefinition: RealPolicySettingDefinition = {
}

if (denyGroups.length === 0) {
// TRANSLATORS {count} is the number of groups authorized to create signature requests.
return t('libresign', '{count} authorized requester groups', { count: String(allowGroups.length) })
// TRANSLATORS %n is the number of groups authorized to create signature requests.
return n('libresign', '%n authorized requester group', '%n authorized requester groups', allowGroups.length)
}

// TRANSLATORS Summary for composed request-sign policy. {allowCount} is allowed groups count and {denyCount} denied groups count.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Feature: admin/certificate_openssl
Then the response should have a status code 401
And the response should be a JSON array with the following mandatory values
| key | value |
| (jq).ocs.data.message | Parameter 'CN' should be betweeen 1 and 64. |
| (jq).ocs.data.message | Parameter 'CN' should be between 1 and 64. |

Scenario: Generate root cert with success using optional names values
Given as user "admin"
Expand All @@ -56,7 +56,7 @@ Feature: admin/certificate_openssl
Then the response should have a status code 401
And the response should be a JSON array with the following mandatory values
| key | value |
| (jq).ocs.data.message | Parameter 'C' should be betweeen 2 and 2. |
| (jq).ocs.data.message | Parameter 'C' should be between 2 and 2. |

Scenario: Generate root cert with fail when country have more then 2 characters
Given as user "admin"
Expand All @@ -65,4 +65,4 @@ Feature: admin/certificate_openssl
Then the response should have a status code 401
And the response should be a JSON array with the following mandatory values
| key | value |
| (jq).ocs.data.message | Parameter 'C' should be betweeen 2 and 2. |
| (jq).ocs.data.message | Parameter 'C' should be between 2 and 2. |
16 changes: 8 additions & 8 deletions tests/php/Unit/Service/Certificate/ValidateServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public static function providerInvalidStringFields(): array {
return [
['CN', '', "Parameter 'CN' is required!"],
['CN', ' ', "Parameter 'CN' is required!"],
['C', 'BRA', "Parameter 'C' should be betweeen 2 and 2."],
['C', 'B', "Parameter 'C' should be betweeen 2 and 2."],
['ST', str_repeat('a', 129), "Parameter 'ST' should be betweeen 1 and 128."],
['L', str_repeat('a', 129), "Parameter 'L' should be betweeen 1 and 128."],
['O', str_repeat('a', 65), "Parameter 'O' should be betweeen 1 and 64."],
['C', 'BRA', "Parameter 'C' should be between 2 and 2."],
['C', 'B', "Parameter 'C' should be between 2 and 2."],
['ST', str_repeat('a', 129), "Parameter 'ST' should be between 1 and 128."],
['L', str_repeat('a', 129), "Parameter 'L' should be between 1 and 128."],
['O', str_repeat('a', 65), "Parameter 'O' should be between 1 and 64."],
];
}

Expand Down Expand Up @@ -106,9 +106,9 @@ public function testValidateArrayFieldsFailure(string $fieldName, array $value,

public static function providerInvalidArrayFields(): array {
return [
['OU', array_fill(0, 11, 'test'), "Parameter 'OU items' should be betweeen 0 and 10."],
['OU', [str_repeat('a', 65)], "Parameter 'OU' should be betweeen 1 and 64."],
['OU', ['valid', str_repeat('a', 65)], "Parameter 'OU' should be betweeen 1 and 64."],
['OU', array_fill(0, 11, 'test'), "Parameter 'OU items' should be between 0 and 10."],
['OU', [str_repeat('a', 65)], "Parameter 'OU' should be between 1 and 64."],
['OU', ['valid', str_repeat('a', 65)], "Parameter 'OU' should be between 1 and 64."],
['OU', ['valid', []], "Parameter 'OU' is required!"],
];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Unit/Service/SignFileServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ public function testCanDeleteRequestSignatureWhenNoSignatureWasRequested():void
}
);
$this->signRequestMapper->method('getByFileUuid')->willReturn([$signRequest]);
$this->expectExceptionMessage('No signature was requested to %');
$this->expectExceptionMessage('No signature was requested from %');
$this->getService()->canDeleteRequestSignature([
'uuid' => 'valid',
'signers' => [
Expand Down
Loading