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


PHP Translator::trans方法代码示例

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


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

示例1: translateNarrative

 /**
  * @param JsonSerializationVisitor $visitor
  * @param Narrative                $narrative
  * @param array                    $type
  * @param Context                  $context
  * @return array
  */
 public function translateNarrative(JsonSerializationVisitor $visitor, Narrative $narrative, array $type, Context $context)
 {
     $messageData = $narrative->getMessages();
     foreach ($messageData as $key => &$messages) {
         foreach ($messages as &$message) {
             $message = $this->translationService->trans($message, $narrative->getSubstitutions(), $key, 'en');
         }
     }
     return $messageData;
 }
开发者ID:TransformCore,项目名称:HayPersistenceApi,代码行数:17,代码来源:NarrativeService.php

示例2: testTrans

 public function testTrans()
 {
     $trans = new Translator('en');
     $trans->register(array('test' => 'test-en'));
     $trans->register(array('test2' => 'test2-en'), 'en');
     $trans->register(array('test' => 'test-fr'), 'fr');
     $this->assertEquals('en', $trans->getLang());
     $this->assertEquals('test-en', $trans->trans('test'));
     $this->assertEquals('test2-en', $trans->trans('test2'));
     $this->assertEquals('test-fr', $trans->trans('test', array(), 'fr'));
 }
开发者ID:nimetu,项目名称:ryzom_bmaker,代码行数:11,代码来源:TranslatorTest.php

示例3: addAction

 /**
  * Adds an action to the list of available .
  *
  * @param string $key    - a unique identifier; it is recommended that it be namespaced i.e. lead.action
  * @param array  $action - can contain the following keys:
  *  'label'           => (required) what to display in the list
  *  'description'     => (optional) short description of event
  *  'template'        => (optional) template to use for the action's HTML in the stage builder
  *      i.e AcmeMyBundle:StageAction:theaction.html.php
  *  'formType'        => (optional) name of the form type SERVICE for the action; will use a default form with stage change only
  *  'formTypeOptions' => (optional) array of options to pass to formType
  *  'callback'        => (optional) callback function that will be passed when the action is triggered; return true to
  *                       change the configured stages or false to ignore the action
  *      The callback function can receive the following arguments by name (via ReflectionMethod::invokeArgs())
  *          Mautic\CoreBundle\Factory\MauticFactory $factory
  *          Mautic\LeadBundle\Entity\Lead $lead
  *          $eventDetails - variable sent from firing function to call back function
  *          array $action = array(
  *              'id' => int
  *              'type' => string
  *              'name' => string
  *              'properties' => array()
  *         )
  *
  * @return void
  * @throws InvalidArgumentException
  */
 public function addAction($key, array $action)
 {
     if (array_key_exists($key, $this->actions)) {
         throw new InvalidArgumentException("The key, '{$key}' is already used by another action. Please use a different key.");
     }
     //check for required keys and that given functions are callable
     $this->verifyComponent(array('group', 'label'), array('callback'), $action);
     //translate the label and group
     $action['label'] = $this->translator->trans($action['label']);
     $action['group'] = $this->translator->trans($action['group']);
     $this->actions[$key] = $action;
 }
开发者ID:Yame-,项目名称:mautic,代码行数:39,代码来源:StageBuilderEvent.php

示例4: upload

 /**
  * Upload image and create entity
  *
  * @param UploadedFile $file
  * @param array        $attributes
  *
  * @return Local
  */
 public function upload(UploadedFile $file, array $attributes)
 {
     $filesystem = new Filesystem();
     $imagine = new Imagine();
     $errors = array();
     $mimeType = $file->getClientMimeType();
     if (!in_array($mimeType, $this->supportedTypes)) {
         $errors[] = $this->translator->trans('ads.error.unsupportedType', array('%type%' => $mimeType));
     }
     if (!file_exists($this->config['image_path']) || !is_writable($this->config['image_path'])) {
         $errors[] = $this->translator->trans('ads.error.notwritable', array('%dir%' => $this->config['image_dir']));
     }
     if (!file_exists($this->config['thumbnail_path']) || !is_writable($this->config['thumbnail_path'])) {
         $errors[] = $this->translator->trans('ads.error.notwritable', array('%dir%' => $this->config['thumbnail_dir']));
     }
     if (!empty($errors)) {
         return $errors;
     }
     $attributes = array_merge(array('content_type' => $mimeType), $attributes);
     $image = new Image($file->getClientOriginalName());
     $this->orm->persist($image);
     $this->fillImage($image, $attributes);
     $this->orm->flush();
     $imagePath = $this->generateImagePath($image->getId(), $file->getClientOriginalExtension());
     $thumbnailPath = $this->generateThumbnailPath($image->getId(), $file->getClientOriginalExtension());
     $image->setBasename($this->generateImagePath($image->getId(), $file->getClientOriginalExtension(), true));
     $image->setThumbnailPath($this->generateThumbnailPath($image->getId(), $file->getClientOriginalExtension(), true));
     $this->orm->flush();
     try {
         $file->move($this->config['image_path'], $this->generateImagePath($image->getId(), $file->getClientOriginalExtension(), true));
         $filesystem->chmod($imagePath, 0644);
         $imagine->open($imagePath)->resize(new Box($this->config['thumbnail_max_size'], $this->config['thumbnail_max_size']))->save($thumbnailPath, array());
         $filesystem->chmod($thumbnailPath, 0644);
     } catch (\Exceptiom $e) {
         $filesystem->remove($imagePath);
         $filesystem->remove($thumbnailPath);
         $this->orm->remove($image);
         $this->orm->flush();
         return array($e->getMessage());
     }
     return $image;
 }
开发者ID:riverans,项目名称:AdvertsPluginBundle,代码行数:50,代码来源:ImageService.php

示例5: getCreatableTypes

 /**
  * @param string[]                                           $roles
  * @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $node
  *
  * @return array
  */
 public function getCreatableTypes(array $roles, ResourceNode $node)
 {
     $creatableTypes = array();
     $creationRights = $this->rightsRepo->findCreationRights($roles, $node);
     if (count($creationRights) !== 0) {
         foreach ($creationRights as $type) {
             $creatableTypes[$type['name']] = $this->translator->trans($type['name'], array(), 'resource');
         }
     }
     return $creatableTypes;
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:17,代码来源:RightsManager.php

示例6: fetchData

 public function fetchData(adUser $adUser, TokenInterface $token, adLDAP $adLdap)
 {
     $connected = $adLdap->connect();
     $isAD = $adLdap->authenticate($adUser->getUsername(), $token->getCredentials());
     if (!$isAD || !$connected) {
         $msg = $this->translator->trans('ztec.security.active_directory.ad.bad_response', array('%connection_status%' => var_export($connected, 1), '%is_AD%' => var_export($isAD, 1)));
         throw new \Exception($msg);
     }
     /** @var adLDAPUserCollection $user */
     $user = $adLdap->user()->infoCollection($adUser->getUsername());
     //$userInfo = $adLdap->user_info($this->username);
     if ($user) {
         $groups = array();
         //$allGroups = $adLdap->search_groups(ADLDAP_SECURITY_GLOBAL_GROUP,true);
         $groups = $adLdap->user()->groups($adUser->getUsername(), $this->recursiveGrouproles);
         /*if ($this->recursiveGrouproles == true) {
               // get recursive groups via adLdap
               $groups = $adLdap->user()->groups($adUser->getUsername(), true);
           } else {
               foreach ($user->memberOf as $k => $group) {
                   if ($k !== 'count' && $group) {
                       $reg = '#CN=([^,]*)#';
                       preg_match_all($reg, $group, $out);
                       $groups[] = $out[1][0];
                       /* if(array_key_exists($out[1][0],$allGroups)){
                            $groups[$out[1][0]] = $allGroups[$out[1][0]];
                        }*/
         /*}
               }
           }*/
         /** End Fetching */
         $sfRoles = array();
         $sfRolesTemp = array();
         foreach ($groups as $r) {
             if (in_array($r, $sfRolesTemp) === false) {
                 $sfRoles[] = 'ROLE_' . strtoupper(str_replace(' ', '_', $r));
                 $sfRolesTemp[] = $r;
             }
         }
         $adUser->setRoles($sfRoles);
         unset($sfRolesTemp);
         $adUser->setDisplayName($user->displayName);
         $adUser->setEmail($user->mail);
         return true;
     }
 }
开发者ID:staelche,项目名称:ZtecSecurityActiveDirectoryBundle,代码行数:46,代码来源:adUserProvider.php

示例7: handleRequest

 public function handleRequest(Request $request)
 {
     $translator = new Translator(@$_COOKIE['lang']);
     foreach ($this->fieldsMap as $field => $constraints) {
         /** @var Constraint $constraint */
         foreach ($constraints as $constraint) {
             if (!$constraint->validate($request->getValue($field))) {
                 $msg = $constraint->getMessage($data);
                 $this->errors[$field][] = $translator->trans($msg, $data);
             }
         }
     }
     if ($this->isValid()) {
         $this->record->setFromData($request->getRequestData());
     } else {
         $this->record = $request->getRequestData();
     }
     return $this;
 }
开发者ID:rchntrl,项目名称:auth-tt,代码行数:19,代码来源:Form.php

示例8: registerPermissions

 /**
  * Register plugin permissions in Newscoop ACL.
  *
  * @param PluginPermissionsEvent $event
  */
 public function registerPermissions(PluginPermissionsEvent $event)
 {
     $event->registerPermissions($this->translator->trans('aes.name'), array('plugin_editor_api' => $this->translator->trans('aes.permissions.api'), 'plugin_editor_permissions' => $this->translator->trans('aes.permissions.permissions'), 'plugin_editor_styles' => $this->translator->trans('aes.permissions.styles')));
 }
开发者ID:AtomLaw,项目名称:plugin-Scoopwriter,代码行数:9,代码来源:PermissionsListener.php

示例9: trans

 /**
  * {@inheritdoc}
  */
 public function trans($id, array $parameters = array(), $domain = null, $locale = null)
 {
     return sprintf($this->getStringFormat($id, $domain, $locale), parent::trans($id, $parameters, $domain, $locale));
 }
开发者ID:Maksold,项目名称:platform,代码行数:7,代码来源:DebugTranslator.php


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