當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model\Message類代碼示例

本文整理匯總了PHP中JMS\TranslationBundle\Model\Message的典型用法代碼示例。如果您正苦於以下問題:PHP Message類的具體用法?PHP Message怎麽用?PHP Message使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Message類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: extract

 public function extract()
 {
     $catalogue = new MessageCatalogue();
     $collection = $this->router instanceof I18nRouter ? $this->router->getOriginalRouteCollection() : $this->router->getRouteCollection();
     foreach ($collection->all() as $name => $route) {
         if ($this->routeExclusionStrategy->shouldExcludeRoute($name, $route)) {
             continue;
         }
         ///////////////////////////////////////
         // Begin customizations
         $meaning = "Route Controller and method: " . $route->getDefault('_controller');
         // set a default value
         // prefix with zikula module url if requested
         if ($route->hasDefault('_zkModule')) {
             $zkNoBundlePrefix = $route->getOption('zkNoBundlePrefix');
             if (!isset($zkNoBundlePrefix) || !$zkNoBundlePrefix) {
                 $meaning = "This is a route from the " . $route->getDefault('_zkModule') . "Bundle and will include a translated prefix.";
             }
         }
         // End customizations
         ///////////////////////////////////////
         $message = new Message($name, $this->domain);
         $message->setDesc($route->getPath());
         if (isset($meaning)) {
             $message->setMeaning($meaning);
         }
         $catalogue->add($message);
     }
     return $catalogue;
 }
開發者ID:Silwereth,項目名稱:core,代碼行數:30,代碼來源:ZikulaRouteTranslationExtractor.php

示例2: has

 /**
  * @param Message $message
  * @return Boolean
  */
 public function has(Message $message)
 {
     if (!$this->hasDomain($message->getDomain())) {
         return false;
     }
     return $this->getDomain($message->getDomain())->has($message->getId());
 }
開發者ID:GabLeRoux,項目名稱:JMSTranslationBundle,代碼行數:11,代碼來源:MessageCatalogue.php

示例3: extract

 public function extract()
 {
     $catalogue = new MessageCatalogue();
     foreach ($this->i18nLoader->extract($this->router->getRouteCollection()) as $name => $route) {
         $message = new Message($name, $this->domain);
         $message->setDesc($route->getPattern());
         $catalogue->add($message);
     }
     return $catalogue;
 }
開發者ID:natxet,項目名稱:JMSI18nRoutingBundle,代碼行數:10,代碼來源:RouteTranslationExtractor.php

示例4: getTranslationMessages

 public static function getTranslationMessages()
 {
     $messages = array();
     foreach (self::$choices as $trans) {
         $message = new Message($trans);
         $message->addSource(new FileSource(__FILE__, 13));
         $messages[] = $message;
     }
     return $messages;
 }
開發者ID:pixel-cookers,項目名稱:JMSTranslationBundle,代碼行數:10,代碼來源:MyFormModel.php

示例5: testExtractFormModel

 public function testExtractFormModel()
 {
     $expected = new MessageCatalogue();
     $path = __DIR__ . '/Fixture/MyFormModel.php';
     $message = new Message('form.label.choice.foo');
     $message->addSource(new FileSource($path, 13));
     $expected->add($message);
     $message = new Message('form.label.choice.bar');
     $message->addSource(new FileSource($path, 13));
     $expected->add($message);
     $this->assertEquals($expected, $this->extract('MyFormModel.php'));
 }
開發者ID:pixel-cookers,項目名稱:JMSTranslationBundle,代碼行數:12,代碼來源:TranslationContainerExtractorTest.php

示例6: testExtractTemplate

 public function testExtractTemplate()
 {
     $expected = new MessageCatalogue();
     $path = __DIR__ . '/Fixture/template.html.php';
     $message = new Message('foo.bar');
     $message->addSource(new FileSource($path, 1));
     $expected->add($message);
     $message = new Message('baz', 'moo');
     $message->setDesc('Foo Bar');
     $message->addSource(new FileSource($path, 3));
     $expected->add($message);
     $this->assertEquals($expected, $this->extract('template.html.php'));
 }
開發者ID:clytemnestra,項目名稱:JMSTranslationBundle,代碼行數:13,代碼來源:DefaultPhpFileExtractorTest.php

示例7: testExtract

 public function testExtract()
 {
     $expected = new MessageCatalogue();
     $message = new Message('security.authentication_error.foo', 'authentication');
     $message->setDesc('%foo% is invalid.');
     $message->addSource(new FileSource(__DIR__ . '/Fixture/MyAuthException.php', 31));
     $expected->add($message);
     $message = new Message('security.authentication_error.bar', 'authentication');
     $message->setDesc('An authentication error occurred.');
     $message->addSource(new FileSource(__DIR__ . '/Fixture/MyAuthException.php', 35));
     $expected->add($message);
     $this->assertEquals($expected, $this->extract('MyAuthException.php'));
 }
開發者ID:clytemnestra,項目名稱:JMSTranslationBundle,代碼行數:13,代碼來源:AuthenticationMessagesExtractorTest.php

示例8: testExtractValidationMessages

 public function testExtractValidationMessages()
 {
     $fileSourceFactory = $this->getFileSourceFactory();
     $fixtureSplInfo = new \SplFileInfo(__DIR__ . '/Fixture/MyEntity.php');
     $expected = new MessageCatalogue();
     $message = new Message('entity.default');
     $message->addSource($fileSourceFactory->create($fixtureSplInfo, 15));
     $expected->add($message);
     $message = new Message('entity.custom-domain', 'custom-domain');
     $message->addSource($fileSourceFactory->create($fixtureSplInfo, 22));
     $expected->add($message);
     $this->assertEquals($expected, $this->extract('MyEntity.php'));
 }
開發者ID:php-community,項目名稱:JMSTranslationBundle,代碼行數:13,代碼來源:ValidationContextExtractorTest.php

示例9: testDumpStructureWithMetadata

 public function testDumpStructureWithMetadata()
 {
     $catalogue = new MessageCatalogue();
     $catalogue->setLocale('en');
     $message = new Message('foo.bar.baz');
     $message->setDesc('Foo');
     $catalogue->add($message);
     $message = new Message('foo.bar.moo');
     $message->setMeaning('Bar');
     $catalogue->add($message);
     $message = new Message('foo.baz');
     $catalogue->add($message);
     $this->assertEquals($this->getOutput('structure_with_metadata'), $this->dump($catalogue, 'messages'));
 }
開發者ID:pixel-cookers,項目名稱:JMSTranslationBundle,代碼行數:14,代碼來源:BaseDumperTest.php

示例10: extract

 public function extract()
 {
     $catalogue = new MessageCatalogue();
     $collection = $this->router instanceof I18nRouter ? $this->router->getOriginalRouteCollection() : $this->router->getRouteCollection();
     foreach ($collection->all() as $name => $route) {
         if ($this->routeExclusionStrategy->shouldExcludeRoute($name, $route)) {
             continue;
         }
         $message = new Message($name, $this->domain);
         $message->setDesc($route->getPath());
         $catalogue->add($message);
     }
     return $catalogue;
 }
開發者ID:DONIKAN,項目名稱:JMSI18nRoutingBundle,代碼行數:14,代碼來源:RouteTranslationExtractor.php

示例11: testExtractTemplate

 public function testExtractTemplate()
 {
     $expected = new MessageCatalogue();
     $fileSourceFactory = $this->getFileSourceFactory();
     $fixtureSplInfo = new \SplFileInfo(__DIR__ . '/Fixture/template.html.php');
     $message = new Message('foo.bar');
     $message->addSource($fileSourceFactory->create($fixtureSplInfo, 1));
     $expected->add($message);
     $message = new Message('baz', 'moo');
     $message->setDesc('Foo Bar');
     $message->addSource($fileSourceFactory->create($fixtureSplInfo, 3));
     $expected->add($message);
     $this->assertEquals($expected, $this->extract('template.html.php'));
 }
開發者ID:kazak,項目名稱:forum,代碼行數:14,代碼來源:DefaultPhpFileExtractorTest.php

示例12: testGet

 public function testGet()
 {
     $catalogue = new MessageCatalogue();
     $catalogue->add($message = Message::create('foo'));
     $this->assertTrue($catalogue->hasDomain('messages'));
     $this->assertSame($message, $catalogue->get('foo'));
 }
開發者ID:pixel-cookers,項目名稱:JMSTranslationBundle,代碼行數:7,代碼來源:MessageCatalogueTest.php

示例13: testCdataOutput

    public function testCdataOutput()
    {
        $dumper = $this->getDumper();
        $catalogue = new MessageCatalogue();
        $catalogue->add(Message::create('foo')->setLocaleString('<bar>')->setDesc('<baz>'));
        $expected = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
  <file source-language="en" target-language="" datatype="plaintext" original="not.available">
    <header>
      <tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
      <note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
    </header>
    <body>
      <trans-unit id="0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" resname="foo">
        <source><![CDATA[<baz>]]></source>
        <target state="new"><![CDATA[<bar>]]></target>
      </trans-unit>
    </body>
  </file>
</xliff>

EOF;
        $this->assertEquals($expected, $dumper->dump($catalogue, 'messages'));
    }
開發者ID:pixel-cookers,項目名稱:JMSTranslationBundle,代碼行數:25,代碼來源:XliffDumperTest.php

示例14: load

 /**
  * Converts Symfony's message catalogue to the catalogue of this
  * bundle.
  *
  * @param mixed $resource
  * @param string $locale
  * @param string $domain
  * @return MessageCatalogue
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $catalogue = new MessageCatalogue();
     $catalogue->setLocale($locale);
     foreach ($this->loader->load($resource, $locale, $domain)->all($domain) as $id => $message) {
         $catalogue->add(Message::create($id, $domain)->setLocaleString($message)->setNew(false));
     }
     return $catalogue;
 }
開發者ID:pixel-cookers,項目名稱:JMSTranslationBundle,代碼行數:18,代碼來源:SymfonyLoaderAdapter.php

示例15: enterNode

 public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
 {
     $this->stack[] = $node;
     if ($node instanceof \Twig_Node_Expression_Function) {
         $name = $node->getAttribute('name');
         if (in_array($name, $this->methodNames)) {
             $args = $node->getNode('arguments');
             switch ($name) {
                 case '_n':
                 case '_fn':
                     $id = $args->getNode(0)->getAttribute('value') . '|' . $args->getNode(1)->getAttribute('value');
                     break;
                 default:
                 case '__f':
                 case '__':
                     $id = $args->getNode(0)->getAttribute('value');
                     break;
             }
             // obtain translation domain from composer file
             $composerPath = str_replace($this->file->getRelativePathname(), '', $this->file->getPathname());
             if (isset(self::$domainCache[$composerPath])) {
                 $domain = self::$domainCache[$composerPath];
             } else {
                 $scanner = new Scanner();
                 $scanner->scan(array($composerPath), 1);
                 $metaData = $scanner->getModulesMetaData(true);
                 $domains = array_keys($metaData);
                 if (isset($domains[0])) {
                     $domain = strtolower($domains[0]);
                     // cache result of file lookup
                     self::$domainCache[$composerPath] = $domain;
                 } else {
                     $domain = 'messages';
                 }
             }
             $domainNode = array_search($name, $this->methodNames);
             $domain = $args->hasNode($domainNode) ? $args->getNode($domainNode)->getAttribute('value') : $domain;
             $message = new Message($id, $domain);
             $message->addSource(new FileSource((string) $this->file, $node->getLine()));
             $this->catalogue->add($message);
         }
     }
     return $node;
 }
開發者ID:rmaiwald,項目名稱:core,代碼行數:44,代碼來源:ZikulaTwigFileExtractor.php


注:本文中的JMS\TranslationBundle\Model\Message類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。