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


PHP Translator::trans方法代码示例

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


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

示例1: trans

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

示例2: 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

示例3: trans

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

示例4: 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:nabil509,项目名称:Payzen,代码行数:7,代码来源:Payzen.php

示例5: checkOrders

 public function checkOrders(array $values)
 {
     foreach ($this->getOrder() as $order) {
         if (!array_key_exists($order, $values)) {
             throw new \ErrorException($this->translator->trans("The column %column that you want to sort doesn't exist", ["%column" => $order]));
         }
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:8,代码来源:AbstractFormatter.php

示例6: hasFlashMessage

 /**
  * Process the count function: executes a loop and return the number of items found
  *
  * @param array $params parameters array
  * @param \Smarty_Internal_Template $template
  *
  * @return int                       the item count
  * @throws \InvalidArgumentException if a parameter is missing
  *
  */
 public function hasFlashMessage($params, $template)
 {
     $type = $this->getParam($params, 'type', null);
     if (null == $type) {
         throw new \InvalidArgumentException($this->translator->trans("Missing 'type' parameter in {hasflash} function arguments"));
     }
     return $this->getSession()->getFlashBag()->has($type);
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:18,代码来源:FlashMessage.php

示例7: 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

示例8: checkMandatoryColumns

 protected function checkMandatoryColumns(array $row)
 {
     $mandatoryColumns = $this->getMandatoryColumns();
     sort($mandatoryColumns);
     $diff = [];
     foreach ($mandatoryColumns as $name) {
         if (!isset($row[$name]) || empty($row[$name])) {
             $diff[] = $name;
         }
     }
     if (!empty($diff)) {
         throw new \UnexpectedValueException($this->translator->trans("The following columns are missing: %columns", ["%columns" => implode(", ", $diff)]));
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:14,代码来源:ImportHandler.php

示例9: translate

 /**
  * Process translate function
  *
  * @param  array                     $params
  * @param  \Smarty_Internal_Template $smarty
  * @return string
  */
 public function translate($params, &$smarty)
 {
     // All parameters other than 'l' and 'd' and 'js' are supposed to be variables. Build an array of var => value pairs
     // and pass it to the translator
     $vars = array();
     foreach ($params as $name => $value) {
         if (!in_array($name, $this->protectedParams)) {
             $vars["%{$name}"] = $value;
         }
     }
     $str = $this->translator->trans($this->getParam($params, 'l'), $vars, $this->getParam($params, 'd', $this->defaultTranslationDomain), $this->getParam($params, 'locale', $this->defaultLocale), $this->getBoolean($this->getParam($params, 'default', true), true), $this->getBoolean($this->getParam($params, 'fallback', true), true));
     if ($this->getParam($params, 'js', 0)) {
         $str = preg_replace("/(['\"])/", "\\\\\$1", $str);
     }
     return $str;
 }
开发者ID:margery,项目名称:thelia,代码行数:23,代码来源:Translation.php

示例10: setEnvironment

 /**
  * @param  string $environment
  * @return $this
  *
  * Sets the execution environment of the Kernel,
  * used to know which cache is used.
  */
 public function setEnvironment($environment)
 {
     if (empty($environment)) {
         throw new \ErrorException($this->translator->trans("You must define an environment when you use an archive builder"));
     }
     if ($this->cacheFile === null) {
         $cacheFile = $this->generateCacheFile($environment);
         if (file_exists($cacheFile)) {
             unlink($cacheFile);
         }
     } else {
         $cacheFile = $this->cacheFile;
     }
     $errorMessage = null;
     try {
         $this->tar = new \PharData($cacheFile, null, null, static::PHAR_FORMAT);
         $this->compressionEntryPoint();
     } catch (\BadMethodCallException $e) {
         /**
          * This should not happen
          */
         $errorMessage = "You have badly called the method setEnvironment twice for %file";
     } catch (\UnexpectedValueException $e) {
         $errorMessage = "The file %file is corrupted";
     }
     if ($errorMessage !== null) {
         throw new TarArchiveException($this->translator->trans($errorMessage, ["%file" => $cacheFile]));
     }
     $this->cacheFile = $cacheFile;
     $this->environment = $environment;
     return $this;
 }
开发者ID:margery,项目名称:thelia,代码行数:39,代码来源:TarArchiveBuilder.php

示例11: checkInterface

 protected function checkInterface()
 {
     /* Must implement either :
      *  - PropelSearchLoopInterface
      *  - ArraySearchLoopInterface
      */
     $searchInterface = false;
     if ($this instanceof PropelSearchLoopInterface) {
         if (true === $searchInterface) {
             throw new LoopException($this->translator->trans('Loop cannot implements multiple Search Interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`'), LoopException::MULTIPLE_SEARCH_INTERFACE);
         }
         $searchInterface = true;
     }
     if ($this instanceof ArraySearchLoopInterface) {
         if (true === $searchInterface) {
             throw new LoopException($this->translator->trans('Loop cannot implements multiple Search Interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`'), LoopException::MULTIPLE_SEARCH_INTERFACE);
         }
         $searchInterface = true;
     }
     if (false === $searchInterface) {
         throw new LoopException($this->translator->trans('Loop must implements one of the following interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`'), LoopException::SEARCH_INTERFACE_NOT_FOUND);
     }
     /* Only PropelSearch allows timestamp and version */
     if (!$this instanceof PropelSearchLoopInterface) {
         if (true === $this->timestampable) {
             throw new LoopException($this->translator->trans("Loop must implements 'PropelSearchLoopInterface' to be timestampable"), LoopException::NOT_TIMESTAMPED);
         }
         if (true === $this->versionable) {
             throw new LoopException($this->translator->trans("Loop must implements 'PropelSearchLoopInterface' to be versionable"), LoopException::NOT_VERSIONED);
         }
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:32,代码来源:BaseLoop.php

示例12: setLoopList

 /**
  *
  * Injects an associative array containing information for loop execution
  *
  * key is loop name
  * value is the class implementing/extending base loop classes
  *
  * ex :
  *
  * $loop = array(
  *  "product" => "Thelia\Loop\Product",
  *  "category" => "Thelia\Loop\Category",
  *  "myLoop" => "My\Own\Loop"
  * );
  *
  * @param  array                     $loopDefinition
  * @throws \InvalidArgumentException if loop name already exists
  */
 public function setLoopList(array $loopDefinition)
 {
     foreach ($loopDefinition as $name => $className) {
         if (array_key_exists($name, $this->loopDefinition)) {
             throw new \InvalidArgumentException($this->translator->trans("The loop name '%name' is already defined in %className class", ['%name' => $name, '%className' => $className]));
         }
         $this->loopDefinition[$name] = $className;
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:27,代码来源:TheliaLoop.php

示例13: parseCustomerGroupAcl

 /**
  * Parse one customergroupacl
  *
  * @param SimpleXMLElement $customerGroupAcl A customergroupacl
  * @param CustomerGroup $customerGroupModel CustomerGroup propel object for who the access have to be created
  *
  * @throws \Exception When an error is detected on xml file (customer group or acl don't exist)
  */
 protected function parseCustomerGroupAcl(SimpleXMLElement $customerGroupAcl, CustomerGroup $customerGroupModel)
 {
     $acl = AclQuery::create()->findOneByCode($customerGroupAcl->getAttributeAsPhp('aclcode'));
     if (null === $customerGroupModel) {
         throw new \Exception($this->translator->trans("Error in %a file the customer group '%s' doesn't exist", ['%a' => $this->xmlFilePath, '%s' => $customerGroupModel->getCode()], CustomerGroupAcl::DOMAIN_MESSAGE));
     }
     if (null === $acl) {
         throw new \Exception($this->translator->trans("Error in %a file the acl '%s' doesn't exist", ['%a' => $this->xmlFilePath, '%s' => $customerGroupAcl->getAttributeAsPhp('aclcode')], CustomerGroupAcl::DOMAIN_MESSAGE));
     }
     $this->parseAccesses($customerGroupAcl->children(), $acl, $customerGroupModel);
 }
开发者ID:MaximeMorille,项目名称:CustomerGroupAcl,代码行数:19,代码来源:AclXmlFileloader.php

示例14: checkEmptyHook

 /**
  * Check if a hook has returned results. The hook should have been executed before, or an
  * InvalidArgumentException is thrown
  *
  * @param array $params
  *
  * @return boolean                   true if the hook is empty
  * @throws \InvalidArgumentException
  */
 protected function checkEmptyHook($params)
 {
     $hookName = $this->getParam($params, 'rel');
     if (null == $hookName) {
         throw new \InvalidArgumentException($this->translator->trans("Missing 'rel' parameter in ifhook/elsehook arguments"));
     }
     if (!isset($this->hookResults[$hookName])) {
         throw new \InvalidArgumentException($this->translator->trans("Related hook name '%name' is not defined.", ['%name' => $hookName]));
     }
     return is_string($this->hookResults[$hookName]) && '' === $this->hookResults[$hookName] || !is_string($this->hookResults[$hookName]) && $this->hookResults[$hookName]->isEmpty();
 }
开发者ID:badelas,项目名称:thelia,代码行数:20,代码来源:Hook.php

示例15: getRow

 /**
  * @param  int                   $index
  * @return array|bool
  * @throws \OutOfBoundsException
  */
 public function getRow($index = 0, $reverseAliases = false)
 {
     if (empty($this->data)) {
         return false;
     } elseif (!isset($this->data[$index])) {
         throw new \OutOfBoundsException($this->translator->trans("Bad index value %idx", ["%idx" => $index]));
     }
     $row = $this->data[$index];
     if ($reverseAliases === true) {
         $row = $this->reverseAliases($row, $this->aliases);
     }
     return $row;
 }
开发者ID:margery,项目名称:thelia,代码行数:18,代码来源:FormatterData.php


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