diff --git a/lib/Handler/SignEngine/SignEngineHandler.php b/lib/Handler/SignEngine/SignEngineHandler.php index af1b05e8ec..e100b14788 100644 --- a/lib/Handler/SignEngine/SignEngineHandler.php +++ b/lib/Handler/SignEngine/SignEngineHandler.php @@ -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. diff --git a/lib/Service/Certificate/ValidateService.php b/lib/Service/Certificate/ValidateService.php index 5bcc21d545..29c7f4e7d5 100644 --- a/lib/Service/Certificate/ValidateService.php +++ b/lib/Service/Certificate/ValidateService.php @@ -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']]) ); } } @@ -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']]) ); } diff --git a/lib/Service/NotifyService.php b/lib/Service/NotifyService.php index 088e9d9069..20b683b3ec 100644 --- a/lib/Service/NotifyService.php +++ b/lib/Service/NotifyService.php @@ -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. diff --git a/lib/Service/SignFileService.php b/lib/Service/SignFileService.php index 05f653c6c4..0aabe132cd 100644 --- a/lib/Service/SignFileService.php +++ b/lib/Service/SignFileService.php @@ -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'])); } }); } diff --git a/src/store/files.js b/src/store/files.js index 076fef216c..0a9500507d 100644 --- a/src/store/files.js +++ b/src/store/files.js @@ -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, diff --git a/src/views/Settings/PolicyWorkbench/settings/expiration-rules/realDefinitions.ts b/src/views/Settings/PolicyWorkbench/settings/expiration-rules/realDefinitions.ts index 1f4d508326..bbeedc2cb4 100644 --- a/src/views/Settings/PolicyWorkbench/settings/expiration-rules/realDefinitions.ts +++ b/src/views/Settings/PolicyWorkbench/settings/expiration-rules/realDefinitions.ts @@ -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' @@ -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 diff --git a/src/views/Settings/PolicyWorkbench/settings/identify-methods/realDefinition.ts b/src/views/Settings/PolicyWorkbench/settings/identify-methods/realDefinition.ts index 9a0ca3126b..a74f39181f 100644 --- a/src/views/Settings/PolicyWorkbench/settings/identify-methods/realDefinition.ts +++ b/src/views/Settings/PolicyWorkbench/settings/identify-methods/realDefinition.ts @@ -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' @@ -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) { diff --git a/src/views/Settings/PolicyWorkbench/settings/request-sign-groups/realDefinition.ts b/src/views/Settings/PolicyWorkbench/settings/request-sign-groups/realDefinition.ts index 9de5aea0a3..1f43b9baad 100644 --- a/src/views/Settings/PolicyWorkbench/settings/request-sign-groups/realDefinition.ts +++ b/src/views/Settings/PolicyWorkbench/settings/request-sign-groups/realDefinition.ts @@ -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' @@ -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) { @@ -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. diff --git a/tests/integration/features/admin/certificate_openssl.feature b/tests/integration/features/admin/certificate_openssl.feature index 400e56ab3e..2052093d37 100644 --- a/tests/integration/features/admin/certificate_openssl.feature +++ b/tests/integration/features/admin/certificate_openssl.feature @@ -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" @@ -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" @@ -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. | diff --git a/tests/php/Unit/Service/Certificate/ValidateServiceTest.php b/tests/php/Unit/Service/Certificate/ValidateServiceTest.php index a42866ecd8..74dba96858 100644 --- a/tests/php/Unit/Service/Certificate/ValidateServiceTest.php +++ b/tests/php/Unit/Service/Certificate/ValidateServiceTest.php @@ -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."], ]; } @@ -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!"], ]; } diff --git a/tests/php/Unit/Service/SignFileServiceTest.php b/tests/php/Unit/Service/SignFileServiceTest.php index a4c0fe68c1..cd5345911f 100644 --- a/tests/php/Unit/Service/SignFileServiceTest.php +++ b/tests/php/Unit/Service/SignFileServiceTest.php @@ -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' => [