当前位置: 首页>>代码示例>>PHP>>正文


PHP Translation\Translator类代码示例

本文整理汇总了PHP中Thelia\Core\Translation\Translator的典型用法代码示例。如果您正苦于以下问题:PHP Translator类的具体用法?PHP Translator怎么用?PHP Translator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Translator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
 }
开发者ID:margery,项目名称:thelia,代码行数:7,代码来源:VirtualProductDelivery.php

示例2: trans

 protected function trans($id, $locale, $parameters = [])
 {
     if ($this->translator === null) {
         $this->translator = Translator::getInstance();
     }
     return $this->translator->trans($id, $parameters, self::MODULE_DOMAIN, $locale);
 }
开发者ID:Asenar,项目名称:thelia-FreeShipping,代码行数:7,代码来源:FreeShipping.php

示例3: registerValidatorTranslator

 public function registerValidatorTranslator(GetResponseEvent $event)
 {
     /** @var \Thelia\Core\HttpFoundation\Request $request */
     $request = $event->getRequest();
     $lang = $request->getSession()->getLang();
     $vendorFormDir = THELIA_VENDOR . 'symfony' . DS . 'form' . DS . 'Symfony' . DS . 'Component' . DS . 'Form';
     $vendorValidatorDir = THELIA_VENDOR . 'symfony' . DS . 'validator' . DS . 'Symfony' . DS . 'Component' . DS . 'Validator';
     $this->translator->addResource('xlf', sprintf($vendorFormDir . DS . 'Resources' . DS . 'translations' . DS . 'validators.%s.xlf', $lang->getCode()), $lang->getLocale(), 'validators');
     $this->translator->addResource('xlf', sprintf($vendorValidatorDir . DS . 'Resources' . DS . 'translations' . DS . 'validators.%s.xlf', $lang->getCode()), $lang->getLocale(), 'validators');
 }
开发者ID:NandoKstroNet,项目名称:thelia,代码行数:10,代码来源:RequestListener.php

示例4: getI18n

 /**
  * Get operator translation
  *
  * @param Translator $translator Provide necessary value from Thelia
  * @param string     $operator   Operator const
  *
  * @return string
  */
 public static function getI18n(Translator $translator, $operator)
 {
     $ret = $operator;
     switch ($operator) {
         case self::INFERIOR:
             $ret = $translator->trans('Less than', []);
             break;
         case self::INFERIOR_OR_EQUAL:
             $ret = $translator->trans('Less than or equals', []);
             break;
         case self::EQUAL:
             $ret = $translator->trans('Equal to', []);
             break;
         case self::SUPERIOR_OR_EQUAL:
             $ret = $translator->trans('Greater than or equals', []);
             break;
         case self::SUPERIOR:
             $ret = $translator->trans('Greater than', []);
             break;
         case self::DIFFERENT:
             $ret = $translator->trans('Not equal to', []);
             break;
         case self::IN:
             $ret = $translator->trans('In', []);
             break;
         case self::OUT:
             $ret = $translator->trans('Not in', []);
             break;
         default:
     }
     return $ret;
 }
开发者ID:margery,项目名称:thelia,代码行数:40,代码来源:Operators.php

示例5: 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]));
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:13,代码来源:CouponCreationForm.php

示例6: verifyCountry

 public function verifyCountry($value, ExecutionContextInterface $context)
 {
     $address = CountryQuery::create()->findPk($value);
     if (null === $address) {
         $context->addViolation(Translator::getInstance()->trans("Country ID not found"));
     }
 }
开发者ID:manuelbcd,项目名称:thelia,代码行数:7,代码来源:OrderUpdateAddress.php

示例7: verifyExistingCode

 public function verifyExistingCode($value, ExecutionContextInterface $context)
 {
     $coupon = CouponQuery::create()->findOneByCode($value);
     if (null === $coupon) {
         $context->addViolation(Translator::getInstance()->trans("This coupon does not exists"));
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:7,代码来源:CouponCode.php

示例8: verifyProfileId

 public function verifyProfileId($value, ExecutionContextInterface $context)
 {
     $profile = ProfileQuery::create()->findPk($value);
     if (null === $profile) {
         $context->addViolation(Translator::getInstance()->trans("Profile ID not found"));
     }
 }
开发者ID:margery,项目名称:thelia,代码行数:7,代码来源:ProfileModificationForm.php

示例9: 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"));
             }
         }
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:28,代码来源:TaxRuleTaxListUpdateForm.php

示例10: buildForm

 /**
  * @inherited
  */
 protected function buildForm()
 {
     $translator = Translator::getInstance();
     BaseProductCreationForm::buildForm();
     $this->formBuilder->add("brand_id", "integer", ['required' => true, 'label' => $translator->trans('Brand / Supplier'), 'label_attr' => ['for' => 'mode', 'help' => $translator->trans("Select the product brand, or supplier.")]]);
     $this->addStandardDescFields(array('title', 'locale'));
 }
开发者ID:NandoKstroNet,项目名称:thelia,代码行数:10,代码来源:ProductCreationForm.php

示例11: checkCityName

 public function checkCityName($value, ExecutionContextInterface $context)
 {
     $isValid = InseeGeoMunicipalityQuery::create()->findOneById($value);
     if (!isset($isValid)) {
         $context->addViolation(Translator::getInstance()->trans('city.error', [], INSEEGeo::DOMAIN_NAME));
     }
 }
开发者ID:enurit,项目名称:INSEEGeo,代码行数:7,代码来源:SelectCityFormType.php

示例12: checkAtLeastOnePhoneNumberIsDefined

 public function checkAtLeastOnePhoneNumberIsDefined($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if (empty($data["phone"]) && empty($data["cellphone"])) {
         $context->addViolationAt("phone", Translator::getInstance()->trans("Please enter a home or mobile phone number"));
     }
 }
开发者ID:thelia-modules,项目名称:ForcePhone,代码行数:7,代码来源:ForcePhoneEventListener.php

示例13: verifyPasswordField

 public function verifyPasswordField($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if ($data["password"] != $data["password_confirm"]) {
         $context->addViolation(Translator::getInstance()->trans("password confirmation is not the same as password field"));
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:7,代码来源:CustomerPasswordUpdateForm.php

示例14: checkDuplicateRef

 public function checkDuplicateRef($value, ExecutionContextInterface $context)
 {
     $count = ProductQuery::create()->filterByRef($value)->count();
     if ($count > 0) {
         $context->addViolation(Translator::getInstance()->trans("A product with reference %ref already exists. Please choose another reference.", array('%ref' => $value)));
     }
 }
开发者ID:margery,项目名称:thelia,代码行数:7,代码来源:ProductCreationForm.php

示例15: generateUrlFunction

 /**
  * Process url generator function
  *
  * @param  array   $params
  * @param  \Smarty $smarty
  * @return string  no text is returned.
  */
 public function generateUrlFunction($params, &$smarty)
 {
     // the path to process
     $current = $this->getParam($params, 'current', false);
     $path = $this->getParam($params, 'path', null);
     $file = $this->getParam($params, 'file', null);
     // Do not invoke index.php in URL (get a static file in web space
     if ($current) {
         $path = $this->request->getPathInfo();
         unset($params["current"]);
         // Delete the current param, so it isn't included in the url
         // Then build the query variables
         $params = array_merge($this->request->query->all(), $params);
     }
     if ($file !== null) {
         $path = $file;
         $mode = URL::PATH_TO_FILE;
     } elseif ($path !== null) {
         $mode = URL::WITH_INDEX_PAGE;
     } else {
         throw new \InvalidArgumentException(Translator::getInstance()->trans("Please specify either 'path' or 'file' parameter in {url} function."));
     }
     $excludeParams = $this->resolvePath($params, $path, $smarty);
     $url = URL::getInstance()->absoluteUrl($path, $this->getArgsFromParam($params, array_merge(['noamp', 'path', 'file', 'target'], $excludeParams)), $mode);
     $this->applyNoAmpAndTarget($params, $url);
     return $url;
 }
开发者ID:NandoKstroNet,项目名称:thelia,代码行数:34,代码来源:UrlGenerator.php


注:本文中的Thelia\Core\Translation\Translator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。