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


PHP MessageCatalogue::addFallbackCatalogue方法代碼示例

本文整理匯總了PHP中Symfony\Component\Translation\MessageCatalogue::addFallbackCatalogue方法的典型用法代碼示例。如果您正苦於以下問題:PHP MessageCatalogue::addFallbackCatalogue方法的具體用法?PHP MessageCatalogue::addFallbackCatalogue怎麽用?PHP MessageCatalogue::addFallbackCatalogue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Translation\MessageCatalogue的用法示例。


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

示例1: loadLocaleFromMemcache

 public function loadLocaleFromMemcache($locale)
 {
     $data = $this->memcached->get("trans.{$locale}", function ($memcache, $key, &$value) use($locale) {
         $value = $this->getDataToCache($locale);
         return true;
     });
     $ct = new MessageCatalogue($locale, $data['catalogue']);
     foreach ($data['fallbacks'] as $fallback => $fallbackMessages) {
         $ct->addFallbackCatalogue(new MessageCatalogue($fallback, $fallbackMessages));
     }
     $this->catalogues[$locale] = $ct;
 }
開發者ID:scottstuff,項目名稱:GCProtractorJS,代碼行數:12,代碼來源:Translator.php

示例2: testAddFallbackCatalogueWithFallbackCircularReference

 /**
  * @expectedException \LogicException
  */
 public function testAddFallbackCatalogueWithFallbackCircularReference()
 {
     $fr = new MessageCatalogue('fr');
     $en = new MessageCatalogue('en');
     $es = new MessageCatalogue('es');
     $fr->addFallbackCatalogue($en);
     $es->addFallbackCatalogue($en);
     $en->addFallbackCatalogue($fr);
 }
開發者ID:Ener-Getick,項目名稱:symfony,代碼行數:12,代碼來源:MessageCatalogueTest.php

示例3: testSimpleLocaleDefaultFallback

 public function testSimpleLocaleDefaultFallback()
 {
     $messageCatalogue = new MessageCatalogue('de_CH');
     $messageCatalogue->addFallbackCatalogue(new MessageCatalogue('de'));
     $defaultCreator = $this->setUpCreator();
     $defaultCreator->createTranslation('simple', 'messages', 'de', $messageCatalogue);
     $this->assertFileExists($this->getMessagesFilePath());
     $data = Yaml::parse($this->getMessagesFilePath());
     $this->assertCount(1, $data);
     $this->assertArrayHasKey('simple', $data);
     $this->assertEquals('simple', $data['simple']);
 }
開發者ID:Flask,項目名稱:IbrowsTranslationHelperBundle,代碼行數:12,代碼來源:TranslationTest.php

示例4: testAddFallbackCatalogueWithCircularReference

    /**
     * @expectedException LogicException
     */
    public function testAddFallbackCatalogueWithCircularReference()
    {
        $main = new MessageCatalogue('en_US');
        $fallback = new MessageCatalogue('fr_FR');

        $fallback->addFallbackCatalogue($main);
        $main->addFallbackCatalogue($fallback);
    }
開發者ID:usefulthink,項目名稱:symfony,代碼行數:11,代碼來源:MessageCatalogTest.php

示例5: testAddFallbackCatalogue

 public function testAddFallbackCatalogue()
 {
     $r = $this->getMock('Symfony\\Component\\Config\\Resource\\ResourceInterface');
     $r->expects($this->any())->method('__toString')->will($this->returnValue('r'));
     $r1 = $this->getMock('Symfony\\Component\\Config\\Resource\\ResourceInterface');
     $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1'));
     $catalogue = new MessageCatalogue('en_US', array('domain1' => array('foo' => 'foo'), 'domain2' => array('bar' => 'bar')));
     $catalogue->addResource($r);
     $catalogue1 = new MessageCatalogue('en', array('domain1' => array('foo' => 'bar', 'foo1' => 'foo1')));
     $catalogue1->addResource($r1);
     $catalogue->addFallbackCatalogue($catalogue1);
     $this->assertEquals('foo', $catalogue->get('foo', 'domain1'));
     $this->assertEquals('foo1', $catalogue->get('foo1', 'domain1'));
     $this->assertEquals(array($r, $r1), $catalogue->getResources());
 }
開發者ID:rooster,項目名稱:symfony,代碼行數:15,代碼來源:MessageCatalogTest.php


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