本文整理汇总了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);
}
示例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);
}
示例3: trans
protected function trans($id, $parameters = [])
{
if (null === $this->translator) {
$this->translator = Translator::getInstance();
}
return $this->translator->trans($id, $parameters, StockAlert::MESSAGE_DOMAIN);
}
示例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);
}
示例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]));
}
}
}
示例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);
}
示例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;
}
示例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)]));
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
}
示例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);
}
示例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();
}
示例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;
}