Add Translator on all form text strings
This commit is contained in:
@@ -25,6 +25,7 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\AdminQuery;
|
||||
|
||||
class AdministratorModificationForm extends AdministratorCreationForm
|
||||
@@ -67,7 +68,7 @@ class AdministratorModificationForm extends AdministratorCreationForm
|
||||
->findPk($value);
|
||||
|
||||
if (null === $administrator) {
|
||||
$context->addViolation("Administrator ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Administrator ID not found"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +78,7 @@ class AdministratorModificationForm extends AdministratorCreationForm
|
||||
|
||||
$administrator = AdminQuery::create()->findOneByLogin($value);
|
||||
if ($administrator !== null && $administrator->getId() != $data['id']) {
|
||||
$context->addViolation("This login already exists");
|
||||
$context->addViolation(Translator::getInstance()->trans("This login already exists"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,11 +87,11 @@ class AdministratorModificationForm extends AdministratorCreationForm
|
||||
$data = $context->getRoot()->getData();
|
||||
|
||||
if ($data["password"] != $data["password_confirm"]) {
|
||||
$context->addViolation("password confirmation is not the same as password field");
|
||||
$context->addViolation(Translator::getInstance()->trans("password confirmation is not the same as password field"));
|
||||
}
|
||||
|
||||
if ($data["password"] !== '' && strlen($data["password"]) < 4) {
|
||||
$context->addViolation("password must be composed of at least 4 characters");
|
||||
$context->addViolation(Translator::getInstance()->trans("password must be composed of at least 4 characters"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class CartAdd extends BaseForm
|
||||
$product = ProductQuery::create()->findPk($value);
|
||||
|
||||
if (is_null($product) || $product->getVisible() == 0) {
|
||||
throw new ProductNotFoundException(sprintf("this product id does not exists : %d", $value));
|
||||
throw new ProductNotFoundException(Translator::getInstance()->trans(sprintf("this product id does not exists : %d", $value)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class CartAdd extends BaseForm
|
||||
->count();
|
||||
|
||||
if ($productSaleElements == 0) {
|
||||
throw new StockNotFoundException(sprintf("This product_sale_elements_id does not exists for this product : %d", $value));
|
||||
throw new StockNotFoundException(Translator::getInstance()->trans(sprintf("This product_sale_elements_id does not exists for this product : %d", $value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ class CartAdd extends BaseForm
|
||||
->findOne();
|
||||
|
||||
if ($productSaleElements->getQuantity() < $value && ConfigQuery::checkAvailableStock()) {
|
||||
$context->addViolation("quantity value is not valid");
|
||||
$context->addViolation(Translator::getInstance()->trans("quantity value is not valid"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class CustomerCreateForm extends AddressCreateForm
|
||||
// Add terms & conditions
|
||||
->add("agreed", "checkbox", array(
|
||||
"constraints" => array(
|
||||
new Constraints\True(array("message" => "Please accept the Terms and conditions in order to register."))
|
||||
new Constraints\True(array("message" => Translator::getInstance()->trans("Please accept the Terms and conditions in order to register.")))
|
||||
),
|
||||
"label"=>"Test",
|
||||
"label_attr" => array(
|
||||
@@ -114,7 +114,7 @@ class CustomerCreateForm extends AddressCreateForm
|
||||
$data = $context->getRoot()->getData();
|
||||
|
||||
if ($data["password"] != $data["password_confirm"]) {
|
||||
$context->addViolation("password confirmation is not the same as password field.");
|
||||
$context->addViolation(Translator::getInstance()->trans("password confirmation is not the same as password field"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ class CustomerCreateForm extends AddressCreateForm
|
||||
{
|
||||
$customer = CustomerQuery::getCustomerByEmail($value);
|
||||
if ($customer) {
|
||||
$context->addViolation("This email already exists.");
|
||||
$context->addViolation(Translator::getInstance()->trans("This email already exists."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ class CustomerLogin extends BaseForm
|
||||
if (false === $data['password'] || (empty($data['password']) && '0' != $data['password'])) {
|
||||
|
||||
$context->getViolations()->add(new ConstraintViolation(
|
||||
'This value should not be blank.',
|
||||
Translator::getInstance()->trans('This value should not be blank.'),
|
||||
'account_password',
|
||||
array(),
|
||||
$context->getRoot(),
|
||||
@@ -117,7 +117,7 @@ class CustomerLogin extends BaseForm
|
||||
if ($data["account"] == 0) {
|
||||
$customer = CustomerQuery::create()->findOneByEmail($value);
|
||||
if ($customer) {
|
||||
$context->addViolation("A user already exists with this email address. Please login or if you've forgotten your password, go to Reset Your Password.");
|
||||
$context->addViolation(Translator::getInstance()->trans("A user already exists with this email address. Please login or if you've forgotten your password, go to Reset Your Password."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class CustomerLostPasswordForm extends BaseForm
|
||||
{
|
||||
$customer = CustomerQuery::create()->findOneByEmail($value);
|
||||
if (null === $customer) {
|
||||
$context->addViolation("This email does not exists");
|
||||
$context->addViolation(Translator::getInstance()->trans("This email does not exists"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class CustomerPasswordUpdateForm extends BaseForm
|
||||
{
|
||||
// Check if value of the old password match the password of the current user
|
||||
if (!password_verify($value, $this->getRequest()->getSession()->getCustomerUser()->getPassword())) {
|
||||
$context->addViolation("Your current password does not match.");
|
||||
$context->addViolation(Translator::getInstance()->trans("Your current password does not match."));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class CustomerPasswordUpdateForm extends BaseForm
|
||||
$data = $context->getRoot()->getData();
|
||||
|
||||
if ($data["password"] != $data["password_confirm"]) {
|
||||
$context->addViolation("Password confirmation is not the same as password field.");
|
||||
$context->addViolation(Translator::getInstance()->trans("password confirmation is not the same as password field"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
|
||||
/**
|
||||
@@ -66,7 +67,7 @@ class CustomerProfileUpdateForm extends CustomerCreateForm
|
||||
$customer = CustomerQuery::getCustomerByEmail($value);
|
||||
// If there is already a customer for this email address and if the customer is different from the current user, do a violation
|
||||
if ($customer && $customer->getId() != $this->getRequest()->getSession()->getCustomerUser()->getId()) {
|
||||
$context->addViolation("This email already exists.");
|
||||
$context->addViolation(Translator::getInstance()->trans("This email already exists."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
class ModuleModificationForm extends BaseForm
|
||||
@@ -69,7 +70,7 @@ class ModuleModificationForm extends BaseForm
|
||||
->findPk($value);
|
||||
|
||||
if (null === $module) {
|
||||
$context->addViolation("Module ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Module ID not found"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class NewsletterForm extends BaseForm
|
||||
{
|
||||
$customer = NewsletterQuery::create()->findOneByEmail($value);
|
||||
if ($customer) {
|
||||
$context->addViolation("You are already registered!");
|
||||
$context->addViolation(Translator::getInstance()->trans("You are already registered!"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Module\BaseModule;
|
||||
@@ -68,7 +69,7 @@ class OrderDelivery extends BaseForm
|
||||
->findPk($value);
|
||||
|
||||
if (null === $address) {
|
||||
$context->addViolation("Address ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Address ID not found"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,13 +82,13 @@ class OrderDelivery extends BaseForm
|
||||
->findOne();
|
||||
|
||||
if (null === $module) {
|
||||
$context->addViolation("Delivery module ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Delivery module ID not found"));
|
||||
}
|
||||
|
||||
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
|
||||
if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) {
|
||||
$context->addViolation(
|
||||
sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $module->getCode())
|
||||
Translator::getInstance()->trans(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $module->getCode()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Module\BaseModule;
|
||||
@@ -68,7 +69,7 @@ class OrderPayment extends BaseForm
|
||||
->findPk($value);
|
||||
|
||||
if (null === $address) {
|
||||
$context->addViolation("Address ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Address ID not found"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +88,7 @@ class OrderPayment extends BaseForm
|
||||
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
|
||||
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
|
||||
$context->addViolation(
|
||||
sprintf("delivery module %s is not a Thelia\Module\PaymentModuleInterface", $module->getCode())
|
||||
Translator::getInstance()->trans(sprintf("delivery module %s is not a Thelia\Module\PaymentModuleInterface", $module->getCode()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ class OrderUpdateAddress extends BaseForm
|
||||
->findPk($value);
|
||||
|
||||
if (null === $address) {
|
||||
$context->addViolation("Order address ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Order address ID not found"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ class OrderUpdateAddress extends BaseForm
|
||||
->findPk($value);
|
||||
|
||||
if (null === $address) {
|
||||
$context->addViolation("Title ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Title ID not found"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ class OrderUpdateAddress extends BaseForm
|
||||
->findPk($value);
|
||||
|
||||
if (null === $address) {
|
||||
$context->addViolation("Country ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Country ID not found"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class ProfileCreationForm extends BaseForm
|
||||
->findOneByCode($value);
|
||||
|
||||
if (null !== $profile) {
|
||||
$context->addViolation("Profile `code` already exists");
|
||||
$context->addViolation(Translator::getInstance()->trans("Profile `code` already exists"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ProfileQuery;
|
||||
|
||||
/**
|
||||
@@ -67,7 +68,7 @@ class ProfileModificationForm extends ProfileCreationForm
|
||||
->findPk($value);
|
||||
|
||||
if (null === $profile) {
|
||||
$context->addViolation("Profile ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Profile ID not found"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ use Symfony\Component\Validator\Constraints;
|
||||
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ProfileQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
@@ -91,7 +92,7 @@ class ProfileUpdateModuleAccessForm extends BaseForm
|
||||
->findPk($value);
|
||||
|
||||
if (null === $profile) {
|
||||
$context->addViolation("Profile ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Profile ID not found"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ use Symfony\Component\Validator\Constraints;
|
||||
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ProfileQuery;
|
||||
use Thelia\Model\ResourceQuery;
|
||||
|
||||
@@ -91,7 +92,7 @@ class ProfileUpdateResourceAccessForm extends BaseForm
|
||||
->findPk($value);
|
||||
|
||||
if (null === $profile) {
|
||||
$context->addViolation("Profile ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Profile ID not found"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class TaxCreationForm extends BaseForm
|
||||
protected function buildForm($change_mode = false)
|
||||
{
|
||||
if ($this->taxEngine == null) {
|
||||
throw new \LogicException("The TaxEngine should be passed to this form before using it.");
|
||||
throw new \LogicException(Translator::getInstance()->trans("The TaxEngine should be passed to this form before using it."));
|
||||
}
|
||||
|
||||
$types = $this->taxEngine->getTaxTypeList();
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
|
||||
class TaxRuleModificationForm extends TaxRuleCreationForm
|
||||
@@ -60,7 +61,7 @@ class TaxRuleModificationForm extends TaxRuleCreationForm
|
||||
->findPk($value);
|
||||
|
||||
if (null === $taxRule) {
|
||||
$context->addViolation("Tax rule ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Tax rule ID not found"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\TaxQuery;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
@@ -89,7 +90,7 @@ class TaxRuleTaxListUpdateForm extends BaseForm
|
||||
->findPk($value);
|
||||
|
||||
if (null === $taxRule) {
|
||||
$context->addViolation("Tax rule ID not found");
|
||||
$context->addViolation(Translator::getInstance()->trans("Tax rule ID not found"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +98,7 @@ class TaxRuleTaxListUpdateForm extends BaseForm
|
||||
{
|
||||
$jsonType = new JsonType();
|
||||
if (!$jsonType->isValid($value)) {
|
||||
$context->addViolation("Tax list is not valid JSON");
|
||||
$context->addViolation(Translator::getInstance()->trans("Tax list is not valid JSON"));
|
||||
}
|
||||
|
||||
$taxList = json_decode($value, true);
|
||||
@@ -108,18 +109,18 @@ class TaxRuleTaxListUpdateForm extends BaseForm
|
||||
if (is_array($taxLevel1)) {
|
||||
foreach ($taxLevel1 as $taxLevel2) {
|
||||
if (is_array($taxLevel2)) {
|
||||
$context->addViolation("Bad tax list JSON");
|
||||
$context->addViolation(Translator::getInstance()->trans("Bad tax list JSON"));
|
||||
} else {
|
||||
$taxModel = TaxQuery::create()->findPk($taxLevel2);
|
||||
if (null === $taxModel) {
|
||||
$context->addViolation("Tax ID not found in tax list JSON");
|
||||
$context->addViolation(Translator::getInstance()->trans("Tax ID not found in tax list JSON"));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$taxModel = TaxQuery::create()->findPk($taxLevel1);
|
||||
if (null === $taxModel) {
|
||||
$context->addViolation("Tax ID not found in tax list JSON");
|
||||
$context->addViolation(Translator::getInstance()->trans("Tax ID not found in tax list JSON"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user