本文整理汇总了PHP中Thelia\Core\Translation\Translator::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::getInstance方法的具体用法?PHP Translator::getInstance怎么用?PHP Translator::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thelia\Core\Translation\Translator
的用法示例。
在下文中一共展示了Translator::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
protected function buildForm()
{
parent::buildForm(true);
$this->formBuilder->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))->add("by_module", "checkbox", array("label" => Translator::getInstance()->trans("By Module"), "required" => false, "label_attr" => array("for" => "by_module", "help" => Translator::getInstance()->trans("This hook is specific to a module (delivery/payment modules)."))))->add("block", "checkbox", array("label" => Translator::getInstance()->trans("Hook block"), "required" => false, "label_attr" => array("for" => "block", "help" => Translator::getInstance()->trans("If checked, this hook will be used by a hook block. If not, by hook function."))));
// Add standard description fields, excluding title and locale, which a re defined in parent class
$this->addStandardDescFields(array('title', 'postscriptum', 'locale'));
}
示例2: verifyProfileId
public function verifyProfileId($value, ExecutionContextInterface $context)
{
$profile = ProfileQuery::create()->findPk($value);
if (null === $profile) {
$context->addViolation(Translator::getInstance()->trans("Profile ID not found"));
}
}
示例3: checkDuplicateCode
public function checkDuplicateCode($value, ExecutionContextInterface $context)
{
$currency = CurrencyQuery::create()->findOneByCode($value);
if ($currency) {
$context->addViolation(Translator::getInstance()->trans('A currency with code "%name" already exists.', ['%name' => $value]));
}
}
示例4: checkLocalizedDate
/**
* Validate a date entered with the default Language date format.
*
* @param string $value
* @param ExecutionContextInterface $context
*/
public function checkLocalizedDate($value, ExecutionContextInterface $context)
{
$format = LangQuery::create()->findOneByByDefault(true)->getDateFormat();
if (false === \DateTime::createFromFormat($format, $value)) {
$context->addViolation(Translator::getInstance()->trans("Date '%date' is invalid, please enter a valid date using %fmt format", ['%fmt' => $format, '%date' => $value]));
}
}
示例5: verifyExistingEmail
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = NewsletterQuery::create()->filterByUnsubscribed(false)->findOneByEmail($value);
if ($customer) {
$context->addViolation(Translator::getInstance()->trans("You are already registered!"));
}
}
示例6: verifyExistingEmail
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = CustomerQuery::create()->findOneByEmail($value);
if (null === $customer) {
$context->addViolation(Translator::getInstance()->trans("This email does not exists"));
}
}
示例7: buildForm
protected function buildForm()
{
parent::buildForm(true);
$this->formBuilder->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))->add("by_module", "checkbox", array("label" => Translator::getInstance()->trans("By Module"), "label_attr" => array("for" => "by_module")))->add("block", "checkbox", array("label" => Translator::getInstance()->trans("Hook block"), "label_attr" => array("for" => "block")));
// Add standard description fields, excluding title and locale, which a re defined in parent class
$this->addStandardDescFields(array('title', 'postscriptum', 'locale'));
}
示例8: buildForm
protected function buildForm()
{
$this->doBuilForm(Translator::getInstance()->trans('The brand name or title'));
$this->formBuilder->add('id', 'hidden', ['constraints' => [new GreaterThan(['value' => 0])], 'required' => true])->add("logo_image_id", "integer", ['constraints' => [], 'required' => false, 'label' => Translator::getInstance()->trans('Select the brand logo'), 'label_attr' => ['for' => 'logo_image_id', 'help' => Translator::getInstance()->trans("Select the brand logo amongst the brand images")]]);
// Add standard description fields, excluding title and locale, which are already defined
$this->addStandardDescFields(array('title', 'locale'));
}
示例9: createOrUpdate
/**
* @param int $titleId customer title id (from customer_title table)
* @param string $firstname customer first name
* @param string $lastname customer last name
* @param string $address1 customer address
* @param string $address2 customer adress complement 1
* @param string $address3 customer adress complement 2
* @param string $phone customer phone number
* @param string $cellphone customer cellphone number
* @param string $zipcode customer zipcode
* @param string $city
* @param int $countryId customer country id (from Country table)
* @param string $email customer email, must be unique
* @param string $plainPassword customer plain password, hash is made calling setPassword method. Not mandatory parameter but an exception is thrown if customer is new without password
* @param string $lang
* @param int $reseller
* @param null $sponsor
* @param int $discount
* @param null $company
* @param null $ref
* @param bool $forceEmailUpdate true if the email address could be updated.
* @param int $stateId customer state id (from State table)
* @throws \Exception
* @throws \Propel\Runtime\Exception\PropelException
*/
public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $countryId, $email = null, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0, $company = null, $ref = null, $forceEmailUpdate = false, $stateId = null)
{
$this->setTitleId($titleId)->setFirstname($firstname)->setLastname($lastname)->setEmail($email, $forceEmailUpdate)->setPassword($plainPassword)->setReseller($reseller)->setSponsor($sponsor)->setDiscount($discount)->setRef($ref);
if (!is_null($lang)) {
$this->setLangId($lang);
}
$con = Propel::getWriteConnection(CustomerTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
if ($this->isNew()) {
$address = new Address();
$address->setLabel(Translator::getInstance()->trans("Main address"))->setCompany($company)->setTitleId($titleId)->setFirstname($firstname)->setLastname($lastname)->setAddress1($address1)->setAddress2($address2)->setAddress3($address3)->setPhone($phone)->setCellphone($cellphone)->setZipcode($zipcode)->setCity($city)->setCountryId($countryId)->setStateId($stateId)->setIsDefault(1);
$this->addAddress($address);
if (ConfigQuery::isCustomerEmailConfirmationEnable()) {
$this->setConfirmationToken(bin2hex(random_bytes(32)));
}
} else {
$address = $this->getDefaultAddress();
$address->setCompany($company)->setTitleId($titleId)->setFirstname($firstname)->setLastname($lastname)->setAddress1($address1)->setAddress2($address2)->setAddress3($address3)->setPhone($phone)->setCellphone($cellphone)->setZipcode($zipcode)->setCity($city)->setCountryId($countryId)->setStateId($stateId)->save($con);
}
$this->save($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
示例10: transQuick
protected function transQuick($id, $locale, $parameters = [])
{
if ($this->translator === null) {
$this->translator = Translator::getInstance();
}
return $this->trans($id, $parameters, DealerTeam::DOMAIN_NAME, $locale);
}
示例11: verifyEmailField
public function verifyEmailField($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
if (isset($data["email_confirm"]) && $data["email"] != $data["email_confirm"]) {
$context->addViolation(Translator::getInstance()->trans("email confirmation is not the same as email field"));
}
}
示例12: getPostage
public function getPostage(Country $country)
{
if (!$this->isValidDelivery($country)) {
throw new DeliveryException(Translator::getInstance()->trans("This module cannot be used on the current cart."));
}
return 0.0;
}
示例13: validate
/**
* Checks if at least one phone number is provided
*
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*
* @api
*/
public function validate($value, Constraint $constraint)
{
$data = $this->context->getRoot()->getData();
if (empty($data["phone"]) && empty($data["cellphone"])) {
$this->context->addViolationAt("phone", Translator::getInstance()->trans("Please enter at least one phone number.", [], ForcePhone::DOMAIN_NAME));
}
}
示例14: trans
protected function trans($id, $parameters = [], $locale = null)
{
if (null === $this->translator) {
$this->translator = Translator::getInstance();
}
return $this->translator->trans($id, $parameters, self::MESSAGE_DOMAIN, $locale);
}
示例15: verifyTaxList
public function verifyTaxList($value, ExecutionContextInterface $context)
{
$jsonType = new JsonType();
if (!$jsonType->isValid($value)) {
$context->addViolation(Translator::getInstance()->trans("Tax list is not valid JSON"));
}
$taxList = json_decode($value, true);
/* check we have 2 level max */
foreach ($taxList as $taxLevel1) {
if (is_array($taxLevel1)) {
foreach ($taxLevel1 as $taxLevel2) {
if (is_array($taxLevel2)) {
$context->addViolation(Translator::getInstance()->trans("Bad tax list JSON"));
} else {
$taxModel = TaxQuery::create()->findPk($taxLevel2);
if (null === $taxModel) {
$context->addViolation(Translator::getInstance()->trans("Tax ID not found in tax list JSON"));
}
}
}
} else {
$taxModel = TaxQuery::create()->findPk($taxLevel1);
if (null === $taxModel) {
$context->addViolation(Translator::getInstance()->trans("Tax ID not found in tax list JSON"));
}
}
}
}