Skip to content

Commit

Permalink
Adding translations and unifying keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mamazu committed Sep 22, 2019
1 parent d430ea9 commit a83477f
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function it_adds_a_violation_if_the_product_exists_and_is_not_configurable(

$product->isConfigurable()->willReturn(false);

$executionContext->addViolation('sylius.shop_api.product.configurable')->shouldBeCalled();
$executionContext->addViolation('sylius.shop_api.product.not_configurable')->shouldBeCalled();

$this->validate('PRODUCT_CODE', new ConfigurableProduct());
}
Expand Down
2 changes: 1 addition & 1 deletion spec/Validator/Product/ProductExistsValidatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function it_adds_constraint_if_product_does_not_exists(
): void {
$productRepository->findOneByCode('BARBECUE_CODE')->willReturn(null);

$executionContext->addViolation('sylius.shop_api.product.exists')->shouldBeCalled();
$executionContext->addViolation('sylius.shop_api.product.not_exists')->shouldBeCalled();

$this->validate('BARBECUE_CODE', new ProductExists());
}
Expand Down
2 changes: 1 addition & 1 deletion spec/Validator/Product/SimpleProductValidatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function it_adds_constraint_if_is_not_simple(
$productRepository->findOneByCode('BARBECUE_CODE')->willReturn($product);
$product->isSimple()->willReturn(false);

$executionContext->addViolation('sylius.shop_api.product.simple')->shouldBeCalled();
$executionContext->addViolation('sylius.shop_api.product.not_simple')->shouldBeCalled();

$this->validate('BARBECUE_CODE', new SimpleProduct());
}
Expand Down
21 changes: 17 additions & 4 deletions src/Resources/translations/validators.en.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
sylius:
shop_api:
channel:
not_exists: Channel does not exist.
cart:
not_exists: Cart does not exists.
not_exists: Cart does not exist.
cart_item:
not_exists: Cart item does not exist.
token:
already_taken: There is already a cart with this token.
email:
not_blank: Please enter your email.
invalid: This email is invalid.
unique: This email is already used.
not_found: There is no user with this email address
password:
not_blank: Please enter your password.
first_name:
not_blank: Please enter your first name.
last_name:
not_blank: Please enter your last name.
address_id:
not_null: Please provide address id
not_null: Please provide address id.
address:
not_exists: Address doesn't exist
not_exists: Address does not exist.
country:
not_exists: The country does not exist
not_exists: The country does not exist.
product:
not_configurable: The product is not configurable.
not_found: The product does not exists.
not_simple: The product is not a simple product
product_variant:
not_exists: The product variant does not exist.
2 changes: 1 addition & 1 deletion src/Validator/Constraints/ConfigurableProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
final class ConfigurableProduct extends Constraint
{
/** @var string */
public $message = 'sylius.shop_api.product.configurable';
public $message = 'sylius.shop_api.product.not_configurable';

/** {@inheritdoc} */
public function getTargets()
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Constraints/ProductExists.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
final class ProductExists extends Constraint
{
/** @var string */
public $message = 'sylius.shop_api.product.exists';
public $message = 'sylius.shop_api.product.not_exists';

/** {@inheritdoc} */
public function getTargets()
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Constraints/SimpleProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
final class SimpleProduct extends Constraint
{
/** @var string */
public $message = 'sylius.shop_api.product.simple';
public $message = 'sylius.shop_api.product.not_simple';

/** {@inheritdoc} */
public function getTargets()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"message": "Validation failed",
"errors": {
"cartToken": [
"Cart does not exists."
"Cart does not exist."
],
"countryCode": [
"The country does not exist"
"The country does not exist."
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"message": "Validation failed",
"errors": {
"id": [
"sylius.shop_api.cart_item.not_exists"
"Cart item does not exist."
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"message": "Validation failed",
"errors": {
"token": [
"Cart does not exists."
"Cart does not exist."
],
"id": [
"sylius.shop_api.cart_item.not_exists"
"Cart item does not exist."
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"message": "Validation failed",
"errors": {
"id": [
"sylius.shop_api.cart_item.not_exists"
"Cart item does not exist."
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"message": "Validation failed",
"errors": {
"token": [
"Cart does not exists."
"Cart does not exist."
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"message": "Validation failed",
"errors": {
"productCode": [
"sylius.shop_api.product.configurable"
"The product is not configurable."
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"errors": {
"productCode": [
"sylius.shop_api.product.not_null",
"sylius.shop_api.product.exists"
"sylius.shop_api.product.not_exists"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"message": "Validation failed",
"errors": {
"productCode": [
"sylius.shop_api.product.exists"
"sylius.shop_api.product.not_exists"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"message": "Validation failed",
"errors": {
"productCode": [
"sylius.shop_api.product.simple"
"The product is not a simple product"
]
}
}

0 comments on commit a83477f

Please sign in to comment.