Fix WordPress.WP.I18n.NonSingularStringLiteralText errors
[MAILPOET-4524]
This commit is contained in:
@ -222,7 +222,7 @@ class Settings extends APIEndpoint {
|
||||
$response = ['status' => true];
|
||||
} else {
|
||||
return $this->badRequest([
|
||||
APIError::BAD_REQUEST => __($e->getMessage(), 'mailpoet'),
|
||||
APIError::BAD_REQUEST => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -301,7 +301,12 @@ class Settings extends APIEndpoint {
|
||||
return $this->deactivateReEngagementEmails();
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception(
|
||||
__('Unable to deactivate re-engagement emails: ' . $e->getMessage(), 'mailpoet'));
|
||||
sprintf(
|
||||
// translators: %s is the error message.
|
||||
__('Unable to deactivate re-engagement emails: %s', 'mailpoet'),
|
||||
$e->getMessage()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,11 +99,11 @@ class API {
|
||||
foreach ($foundSegments as $segment) {
|
||||
if ($segment->type === Segment::TYPE_WP_USERS) {
|
||||
// translators: %d is the ID of the segment
|
||||
throw new APIException(__(sprintf("Can't unsubscribe from a WordPress Users list with ID %d.", $segment->id), 'mailpoet'), APIException::SUBSCRIBING_TO_WP_LIST_NOT_ALLOWED);
|
||||
throw new APIException(sprintf(__("Can't unsubscribe from a WordPress Users list with ID %d.", 'mailpoet'), $segment->id), APIException::SUBSCRIBING_TO_WP_LIST_NOT_ALLOWED);
|
||||
}
|
||||
if ($segment->type === Segment::TYPE_WC_USERS) {
|
||||
// translators: %d is the ID of the segment
|
||||
throw new APIException(__(sprintf("Can't unsubscribe from a WooCommerce Customers list with ID %d.", $segment->id), 'mailpoet'), APIException::SUBSCRIBING_TO_WC_LIST_NOT_ALLOWED);
|
||||
throw new APIException(sprintf(__("Can't unsubscribe from a WooCommerce Customers list with ID %d.", 'mailpoet'), $segment->id), APIException::SUBSCRIBING_TO_WC_LIST_NOT_ALLOWED);
|
||||
}
|
||||
$foundSegmentsIds[] = $segment->id;
|
||||
}
|
||||
@ -171,7 +171,7 @@ class API {
|
||||
if ($newSubscriber->getErrors() !== false) {
|
||||
throw new APIException(
|
||||
// translators: %s is a comma-seperated list of errors.
|
||||
__(sprintf('Failed to add subscriber: %s', strtolower(implode(', ', $newSubscriber->getErrors()))), 'mailpoet'),
|
||||
sprintf(__('Failed to add subscriber: %s', 'mailpoet'), strtolower(implode(', ', $newSubscriber->getErrors()))),
|
||||
APIException::FAILED_TO_SAVE_SUBSCRIBER
|
||||
);
|
||||
}
|
||||
|
@ -116,15 +116,15 @@ class Subscribers {
|
||||
foreach ($foundSegments as $foundSegment) {
|
||||
if ($foundSegment->getType() === SegmentEntity::TYPE_WP_USERS) {
|
||||
// translators: %d is the ID of the segment
|
||||
throw new APIException(__(sprintf("Can't subscribe to a WordPress Users list with ID %d.", $foundSegment->getId()), 'mailpoet'), APIException::SUBSCRIBING_TO_WP_LIST_NOT_ALLOWED);
|
||||
throw new APIException(sprintf(__("Can't subscribe to a WordPress Users list with ID %d.", 'mailpoet'), $foundSegment->getId()), APIException::SUBSCRIBING_TO_WP_LIST_NOT_ALLOWED);
|
||||
}
|
||||
if ($foundSegment->getType() === SegmentEntity::TYPE_WC_USERS) {
|
||||
// translators: %d is the ID of the segment
|
||||
throw new APIException(__(sprintf("Can't subscribe to a WooCommerce Customers list with ID %d.", $foundSegment->getId()), 'mailpoet'), APIException::SUBSCRIBING_TO_WC_LIST_NOT_ALLOWED);
|
||||
throw new APIException(sprintf(__("Can't subscribe to a WooCommerce Customers list with ID %d.", 'mailpoet'), $foundSegment->getId()), APIException::SUBSCRIBING_TO_WC_LIST_NOT_ALLOWED);
|
||||
}
|
||||
if ($foundSegment->getType() !== SegmentEntity::TYPE_DEFAULT) {
|
||||
// translators: %d is the ID of the segment
|
||||
throw new APIException(__(sprintf("Can't subscribe to a list with ID %d.", $foundSegment->getId()), 'mailpoet'), APIException::SUBSCRIBING_TO_LIST_NOT_ALLOWED);
|
||||
throw new APIException(sprintf(__("Can't subscribe to a list with ID %d.", 'mailpoet'), $foundSegment->getId()), APIException::SUBSCRIBING_TO_LIST_NOT_ALLOWED);
|
||||
}
|
||||
$foundSegmentsIds[] = $foundSegment->getId();
|
||||
}
|
||||
@ -154,7 +154,7 @@ class Subscribers {
|
||||
} catch (\Exception $e) {
|
||||
throw new APIException(
|
||||
// translators: %s is the error message
|
||||
__(sprintf('Failed to save a status of a subscriber : %s', $e->getMessage()), 'mailpoet'),
|
||||
sprintf(__('Failed to save a status of a subscriber : %s', 'mailpoet'), $e->getMessage()),
|
||||
APIException::FAILED_TO_SAVE_SUBSCRIBER
|
||||
);
|
||||
}
|
||||
@ -201,7 +201,7 @@ class Subscribers {
|
||||
if ($queue instanceof Sending && $queue->getErrors()) {
|
||||
throw new APIException(
|
||||
// translators: %s is a comma-separated list of errors
|
||||
__(sprintf('Subscriber added, but welcome email failed to send: %s', strtolower(implode(', ', $queue->getErrors()))), 'mailpoet'),
|
||||
sprintf(__('Subscriber added, but welcome email failed to send: %s', 'mailpoet'), strtolower(implode(', ', $queue->getErrors()))),
|
||||
APIException::WELCOME_FAILED_TO_SEND
|
||||
);
|
||||
}
|
||||
@ -218,7 +218,7 @@ class Subscribers {
|
||||
} catch (\Exception $e) {
|
||||
throw new APIException(
|
||||
// translators: %s is the error message
|
||||
__(sprintf('Subscriber added to lists, but confirmation email failed to send: %s', strtolower($e->getMessage())), 'mailpoet'),
|
||||
sprintf(__('Subscriber added to lists, but confirmation email failed to send: %s', 'mailpoet'), strtolower($e->getMessage())),
|
||||
APIException::CONFIRMATION_FAILED_TO_SEND
|
||||
);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class UpdateWorkflowController {
|
||||
private function checkWorkflowStatus(string $status): void {
|
||||
if (!in_array($status, [Workflow::STATUS_ACTIVE, Workflow::STATUS_INACTIVE, Workflow::STATUS_DRAFT], true)) {
|
||||
// translators: %s is the status.
|
||||
throw UnexpectedValueException::create()->withMessage(__(sprintf('Invalid status: %s', $status), 'mailpoet'));
|
||||
throw UnexpectedValueException::create()->withMessage(sprintf(__('Invalid status: %s', 'mailpoet'), $status));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,14 +33,14 @@ class Exceptions {
|
||||
return InvalidStateException::create()
|
||||
->withErrorCode(self::MIGRATION_FAILED)
|
||||
// translators: %s is the error message.
|
||||
->withMessage(__(sprintf('Migration failed: %s', $error), 'mailpoet'));
|
||||
->withMessage(sprintf(__('Migration failed: %s', 'mailpoet'), $error));
|
||||
}
|
||||
|
||||
public static function databaseError(string $error): InvalidStateException {
|
||||
return InvalidStateException::create()
|
||||
->withErrorCode(self::DATABASE_ERROR)
|
||||
// translators: %s is the error message.
|
||||
->withMessage(__(sprintf('Database error: %s', $error), 'mailpoet'));
|
||||
->withMessage(sprintf(__('Database error: %s', 'mailpoet'), $error));
|
||||
}
|
||||
|
||||
public static function apiMethodNotAllowed(): UnexpectedValueException {
|
||||
@ -60,70 +60,70 @@ class Exceptions {
|
||||
return UnexpectedValueException::create()
|
||||
->withErrorCode(self::JSON_NOT_OBJECT)
|
||||
// translators: %s is the mentioned JSON string.
|
||||
->withMessage(__(sprintf("JSON string '%s' doesn't encode an object.", $json), 'mailpoet'));
|
||||
->withMessage(sprintf(__("JSON string '%s' doesn't encode an object.", 'mailpoet'), $json));
|
||||
}
|
||||
|
||||
public static function workflowNotFound(int $id): NotFoundException {
|
||||
return NotFoundException::create()
|
||||
->withErrorCode(self::WORKFLOW_NOT_FOUND)
|
||||
// translators: %d is the ID of the workflow.
|
||||
->withMessage(__(sprintf("Workflow with ID '%d' not found.", $id), 'mailpoet'));
|
||||
->withMessage(sprintf(__("Workflow with ID '%d' not found.", 'mailpoet'), $id));
|
||||
}
|
||||
|
||||
public static function workflowRunNotFound(int $id): NotFoundException {
|
||||
return NotFoundException::create()
|
||||
->withErrorCode(self::WORKFLOW_RUN_NOT_FOUND)
|
||||
// translators: %d is the ID of the workflow run.
|
||||
->withMessage(__(sprintf("Workflow run with ID '%d' not found.", $id), 'mailpoet'));
|
||||
->withMessage(sprintf(__("Workflow run with ID '%d' not found.", 'mailpoet'), $id));
|
||||
}
|
||||
|
||||
public static function workflowStepNotFound(string $id): NotFoundException {
|
||||
return NotFoundException::create()
|
||||
->withErrorCode(self::WORKFLOW_STEP_NOT_FOUND)
|
||||
// translators: %s is the ID of the workflow step.
|
||||
->withMessage(__(sprintf("Workflow step with ID '%s' not found.", $id), 'mailpoet'));
|
||||
->withMessage(sprintf(__("Workflow step with ID '%s' not found.", 'mailpoet'), $id));
|
||||
}
|
||||
|
||||
public static function workflowTriggerNotFound(int $workflowId, string $key): NotFoundException {
|
||||
return NotFoundException::create()
|
||||
->withErrorCode(self::WORKFLOW_TRIGGER_NOT_FOUND)
|
||||
// translators: %1$s is the key, %2$d is the workflow ID.
|
||||
->withMessage(__(sprintf('Workflow trigger with key "%1$s" not found in workflow ID "%2$d".', $key, $workflowId), 'mailpoet'));
|
||||
->withMessage(sprintf(__('Workflow trigger with key "%1$s" not found in workflow ID "%2$d".', 'mailpoet'), $key, $workflowId));
|
||||
}
|
||||
|
||||
public static function workflowRunNotRunning(int $id, string $status): InvalidStateException {
|
||||
return InvalidStateException::create()
|
||||
->withErrorCode(self::WORKFLOW_RUN_NOT_RUNNING)
|
||||
// translators: %1$d is the ID of the workflow run, %2$s it's current status.
|
||||
->withMessage(__(sprintf('Workflow run with ID "%1$d" is not running. Status: %2$s', $id, $status), 'mailpoet'));
|
||||
->withMessage(sprintf(__('Workflow run with ID "%1$d" is not running. Status: %2$s', 'mailpoet'), $id, $status));
|
||||
}
|
||||
|
||||
public static function subjectNotFound(string $key): NotFoundException {
|
||||
return NotFoundException::create()
|
||||
->withErrorCode(self::SUBJECT_NOT_FOUND)
|
||||
// translators: %s is the key of the subject not found.
|
||||
->withMessage(__(sprintf("Subject with key '%s' not found.", $key), 'mailpoet'));
|
||||
->withMessage(sprintf(__("Subject with key '%s' not found.", 'mailpoet'), $key));
|
||||
}
|
||||
|
||||
public static function subjectClassNotFound(string $key): NotFoundException {
|
||||
return NotFoundException::create()
|
||||
->withErrorCode(self::SUBJECT_NOT_FOUND)
|
||||
// translators: %s is the key of the subject class not found.
|
||||
->withMessage(__(sprintf("Subject of class '%s' not found.", $key), 'mailpoet'));
|
||||
->withMessage(sprintf(__("Subject of class '%s' not found.", 'mailpoet'), $key));
|
||||
}
|
||||
|
||||
public static function subjectLoadFailed(string $key, array $args): InvalidStateException {
|
||||
return InvalidStateException::create()
|
||||
->withErrorCode(self::SUBJECT_LOAD_FAILED)
|
||||
// translators: %1$s is the name of the key, %2$s the arguments.
|
||||
->withMessage(__(sprintf('Subject with key "%1$s" and args "%2$s" failed to load.', $key, Json::encode($args)), 'mailpoet'));
|
||||
->withMessage(sprintf(__('Subject with key "%1$s" and args "%2$s" failed to load.', 'mailpoet'), $key, Json::encode($args)));
|
||||
}
|
||||
|
||||
public static function multipleSubjectsFound(string $key): InvalidStateException {
|
||||
return InvalidStateException::create()
|
||||
->withErrorCode(self::MULTIPLE_SUBJECTS_FOUND)
|
||||
// translators: %s is the name of the key.
|
||||
->withMessage(__(sprintf("Multiple subjects with key '%s' found, only one expected.", $key), 'mailpoet'));
|
||||
->withMessage(sprintf(__("Multiple subjects with key '%s' found, only one expected.", 'mailpoet'), $key));
|
||||
}
|
||||
|
||||
public static function workflowStructureModificationNotSupported(): UnexpectedValueException {
|
||||
|
@ -61,7 +61,7 @@ class SegmentSubject implements Subject {
|
||||
$this->segment = $this->segmentsRepository->findOneById($args['segment_id']);
|
||||
if (!$this->segment) {
|
||||
// translators: %d is the ID.
|
||||
throw NotFoundException::create()->withMessage(__(sprintf("Segment with ID '%d' not found.", $id), 'mailpoet'));
|
||||
throw NotFoundException::create()->withMessage(sprintf(__("Segment with ID '%d' not found.", 'mailpoet'), $id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ class SubscriberSubject implements Subject {
|
||||
$this->subscriber = $this->subscribersRepository->findOneById($id);
|
||||
if (!$this->subscriber) {
|
||||
// translators: %d is the ID.
|
||||
throw NotFoundException::create()->withMessage(__(sprintf("Subscriber with ID '%d' not found.", $id), 'mailpoet'));
|
||||
throw NotFoundException::create()->withMessage(sprintf(__("Subscriber with ID '%d' not found.", 'mailpoet'), $id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ class RequiredCustomFieldValidator {
|
||||
if ($this->isCustomFieldMissing($customFieldId, $data)) {
|
||||
throw new Exception(
|
||||
// translators: %s is the name of the custom field.
|
||||
__(sprintf('Missing value for custom field "%s"', $customFieldName), 'mailpoet')
|
||||
sprintf(__('Missing value for custom field "%s"', 'mailpoet'), $customFieldName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ class SubscriberSaveController {
|
||||
$existingSubscriber = $this->subscribersRepository->findOneBy(['email' => $email]);
|
||||
if ($existingSubscriber) {
|
||||
// translators: %s is email address which already exists.
|
||||
$exceptionMessage = __(sprintf('A subscriber with E-mail "%s" already exists.', $email), 'mailpoet');
|
||||
$exceptionMessage = sprintf(__('A subscriber with E-mail "%s" already exists.', 'mailpoet'), $email);
|
||||
throw new ConflictException($exceptionMessage);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user