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


PHP Translator::getPluginManager方法代码示例

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


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

示例1: testTranslate

 public function testTranslate()
 {
     $loader = new TestLoader();
     $loader->textDomain = new TextDomain(array('foo' => 'bar'));
     $this->translator->getPluginManager()->setService('test', $loader);
     $this->translator->addTranslationFile('test', null);
     $this->assertEquals('bar', $this->translator->translate('foo'));
 }
开发者ID:navassouza,项目名称:zf2,代码行数:8,代码来源:TranslatorTest.php

示例2: testTranslateWithCache

 public function testTranslateWithCache()
 {
     $cache = \Zend\Cache\StorageFactory::factory(array('adapter' => 'memory'));
     $this->translator->setCache($cache);
     $loader = new TestLoader();
     $loader->textDomain = new TextDomain(array('foo' => 'bar'));
     $this->translator->getPluginManager()->setService('test', $loader);
     $this->translator->addTranslationFile('test', null);
     $this->assertEquals('bar', $this->translator->translate('foo'));
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:10,代码来源:TranslatorTest.php

示例3: testTranslationsAreStoredInCache

 public function testTranslationsAreStoredInCache()
 {
     $cache = \Zend\Cache\StorageFactory::factory(array('adapter' => 'memory'));
     $this->translator->setCache($cache);
     $loader = new TestLoader();
     $loader->textDomain = new TextDomain(array('foo' => 'bar'));
     $this->translator->getPluginManager()->setService('test', $loader);
     $this->translator->addTranslationFile('test', null);
     $this->assertEquals('bar', $this->translator->translate('foo'));
     $item = $cache->getItem('Zend_I18n_Translator_Messages_' . md5('default' . 'en_EN'));
     $this->assertInstanceOf('Zend\\I18n\\Translator\\TextDomain', $item);
     $this->assertEquals('bar', $item['foo']);
 }
开发者ID:nieldm,项目名称:zf2,代码行数:13,代码来源:TranslatorTest.php

示例4: getTranslator

 /**
  * @return Translator
  */
 public function getTranslator()
 {
     $translator = new Translator();
     $translator->setLocale('en-US');
     $enLoader = $this->getMock('Zend\\I18n\\Translator\\Loader\\FileLoaderInterface');
     $deLoader = $this->getMock('Zend\\I18n\\Translator\\Loader\\FileLoaderInterface');
     $domainLoader = $this->getMock('Zend\\I18n\\Translator\\Loader\\FileLoaderInterface');
     $enLoader->expects($this->any())->method('load')->willReturn(new TextDomain(['fw' => 'framework']));
     $deLoader->expects($this->any())->method('load')->willReturn(new TextDomain(['fw' => 'baukasten']));
     $domainLoader->expects($this->any())->method('load')->willReturn(new TextDomain(['fw' => 'fw-alternative']));
     $translator->getPluginManager()->setService('test-en', $enLoader);
     $translator->getPluginManager()->setService('test-de', $deLoader);
     $translator->getPluginManager()->setService('test-domain', $domainLoader);
     $translator->addTranslationFile('test-en', null, 'default', 'en-US');
     $translator->addTranslationFile('test-de', null, 'default', 'de-DE');
     $translator->addTranslationFile('test-domain', null, 'alternative', 'en-US');
     return $translator;
 }
开发者ID:redokun,项目名称:zf-linguo,代码行数:21,代码来源:MultiLangSegmentTest.php

示例5: routeProvider

 public static function routeProvider()
 {
     $translator = new Translator();
     $translator->setLocale('en-US');
     $enLoader = new TestLoader();
     $deLoader = new TestLoader();
     $domainLoader = new TestLoader();
     $enLoader->textDomain = new TextDomain(array('fw' => 'framework'));
     $deLoader->textDomain = new TextDomain(array('fw' => 'baukasten'));
     $domainLoader->textDomain = new TextDomain(array('fw' => 'fw-alternative'));
     $translator->getPluginManager()->setService('test-en', $enLoader);
     $translator->getPluginManager()->setService('test-de', $deLoader);
     $translator->getPluginManager()->setService('test-domain', $domainLoader);
     $translator->addTranslationFile('test-en', null, 'default', 'en-US');
     $translator->addTranslationFile('test-de', null, 'default', 'de-DE');
     $translator->addTranslationFile('test-domain', null, 'alternative', 'en-US');
     return array('simple-match' => array(new Segment('/:foo'), '/bar', null, array('foo' => 'bar')), 'no-match-without-leading-slash' => array(new Segment(':foo'), '/bar/', null, null), 'no-match-with-trailing-slash' => array(new Segment('/:foo'), '/bar/', null, null), 'offset-skips-beginning' => array(new Segment(':foo'), '/bar', 1, array('foo' => 'bar')), 'offset-enables-partial-matching' => array(new Segment('/:foo'), '/bar/baz', 0, array('foo' => 'bar')), 'match-overrides-default' => array(new Segment('/:foo', array(), array('foo' => 'baz')), '/bar', null, array('foo' => 'bar')), 'constraints-prevent-match' => array(new Segment('/:foo', array('foo' => '\\d+')), '/bar', null, null), 'constraints-allow-match' => array(new Segment('/:foo', array('foo' => '\\d+')), '/123', null, array('foo' => '123')), 'constraints-override-non-standard-delimiter' => array(new Segment('/:foo{-}/bar', array('foo' => '[^/]+')), '/foo-bar/bar', null, array('foo' => 'foo-bar')), 'constraints-with-parantheses-dont-break-parameter-map' => array(new Segment('/:foo/:bar', array('foo' => '(bar)')), '/bar/baz', null, array('foo' => 'bar', 'bar' => 'baz')), 'simple-match-with-optional-parameter' => array(new Segment('/[:foo]', array(), array('foo' => 'bar')), '/', null, array('foo' => 'bar')), 'optional-parameter-is-ignored' => array(new Segment('/:foo[/:bar]'), '/bar', null, array('foo' => 'bar')), 'optional-parameter-is-provided-with-default' => array(new Segment('/:foo[/:bar]', array(), array('bar' => 'baz')), '/bar', null, array('foo' => 'bar', 'bar' => 'baz')), 'optional-parameter-is-consumed' => array(new Segment('/:foo[/:bar]'), '/bar/baz', null, array('foo' => 'bar', 'bar' => 'baz')), 'optional-group-is-discared-with-missing-parameter' => array(new Segment('/:foo[/:bar/:baz]', array(), array('bar' => 'baz')), '/bar', null, array('foo' => 'bar', 'bar' => 'baz')), 'optional-group-within-optional-group-is-ignored' => array(new Segment('/:foo[/:bar[/:baz]]', array(), array('bar' => 'baz', 'baz' => 'bat')), '/bar', null, array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'bat')), 'non-standard-delimiter-before-parameter' => array(new Segment('/foo-:bar'), '/foo-baz', null, array('bar' => 'baz')), 'non-standard-delimiter-between-parameters' => array(new Segment('/:foo{-}-:bar'), '/bar-baz', null, array('foo' => 'bar', 'bar' => 'baz')), 'non-standard-delimiter-before-optional-parameter' => array(new Segment('/:foo{-/}[-:bar]/:baz'), '/bar-baz/bat', null, array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'bat')), 'non-standard-delimiter-before-ignored-optional-parameter' => array(new Segment('/:foo{-/}[-:bar]/:baz'), '/bar/bat', null, array('foo' => 'bar', 'baz' => 'bat')), 'parameter-with-dash-in-name' => array(new Segment('/:foo-bar'), '/baz', null, array('foo-bar' => 'baz')), 'url-encoded-parameters-are-decoded' => array(new Segment('/:foo'), '/foo%20bar', null, array('foo' => 'foo bar')), 'urlencode-flaws-corrected' => array(new Segment('/:foo'), "/!\$&'()*,-.:;=@_~+", null, array('foo' => "!\$&'()*,-.:;=@_~+")), 'empty-matches-are-replaced-with-defaults' => array(new Segment('/foo[/:bar]/baz-:baz', array(), array('bar' => 'bar')), '/foo/baz-baz', null, array('bar' => 'bar', 'baz' => 'baz')), 'translate-with-default-locale' => array(new Segment('/{fw}', array(), array()), '/framework', null, array(), array('translator' => $translator)), 'translate-with-specific-locale' => array(new Segment('/{fw}', array(), array()), '/baukasten', null, array(), array('translator' => $translator, 'locale' => 'de-DE')), 'translate-uses-message-id-as-fallback' => array(new Segment('/{fw}', array(), array()), '/fw', null, array(), array('translator' => $translator, 'locale' => 'fr-FR')), 'translate-with-specific-text-domain' => array(new Segment('/{fw}', array(), array()), '/fw-alternative', null, array(), array('translator' => $translator, 'text_domain' => 'alternative')));
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:18,代码来源:SegmentTest.php

示例6: _getTranslator

 /**
  * Returns translator
  *
  * @return Translator
  */
 protected function _getTranslator()
 {
     $loader = new TestAsset\ArrayTranslator();
     $loader->translations = array('Page 1' => 'Side 1', 'Page 1.1' => 'Side 1.1', 'Page 2' => 'Side 2', 'Page 2.3' => 'Side 2.3', 'Page 2.3.3.1' => 'Side 2.3.3.1', 'Home' => 'Hjem', 'Go home' => 'Gå hjem');
     $translator = new Translator();
     $translator->getPluginManager()->setService('default', $loader);
     $translator->addTranslationFile('default', null);
     return $translator;
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:14,代码来源:AbstractTest.php

示例7: _getTranslatorWithTextDomain

 /**
  * Returns translator with text domain
  *
  * @return Translator
  */
 protected function _getTranslatorWithTextDomain()
 {
     $loader1 = new TestAsset\ArrayTranslator();
     $loader1->translations = array('Page 1' => 'TextDomain1 1', 'Page 1.1' => 'TextDomain1 1.1', 'Page 2' => 'TextDomain1 2', 'Page 2.3' => 'TextDomain1 2.3', 'Page 2.3.3' => 'TextDomain1 2.3.3', 'Page 2.3.3.1' => 'TextDomain1 2.3.3.1');
     $loader2 = new TestAsset\ArrayTranslator();
     $loader2->translations = array('Page 1' => 'TextDomain2 1', 'Page 1.1' => 'TextDomain2 1.1', 'Page 2' => 'TextDomain2 2', 'Page 2.3' => 'TextDomain2 2.3', 'Page 2.3.3' => 'TextDomain2 2.3.3', 'Page 2.3.3.1' => 'TextDomain2 2.3.3.1');
     $translator = new Translator();
     $translator->getPluginManager()->setService('default1', $loader1);
     $translator->getPluginManager()->setService('default2', $loader2);
     $translator->addTranslationFile('default1', null, 'ZendTest_1');
     $translator->addTranslationFile('default2', null, 'ZendTest_2');
     return $translator;
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:18,代码来源:AbstractTest.php

示例8: testCanTranslateTitle

 public function testCanTranslateTitle()
 {
     $loader = new TestAsset\ArrayTranslator();
     $loader->translations = array('Message_1' => 'Message 1 (en)');
     $translator = new Translator();
     $translator->getPluginManager()->setService('default', $loader);
     $translator->addTranslationFile('default', null);
     $this->helper->setTranslatorEnabled(true);
     $this->helper->setTranslator($translator);
     $this->helper->__invoke('Message_1');
     $this->assertEquals('<title>Message 1 (en)</title>', $this->helper->toString());
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:12,代码来源:HeadTitleTest.php

示例9: testMaximumErrorMessageLength

 public function testMaximumErrorMessageLength()
 {
     $this->assertEquals(-1, AbstractValidator::getMessageLength());
     AbstractValidator::setMessageLength(10);
     $this->assertEquals(10, AbstractValidator::getMessageLength());
     $loader = new TestAsset\ArrayTranslator();
     $loader->translations = array(Alpha::INVALID => 'This is the translated message for %value%');
     $translator = new Translator\Translator();
     $translator->getPluginManager()->setService('default', $loader);
     $translator->addTranslationFile('default', null);
     $this->validator->setTranslator($translator);
     $this->assertFalse($this->validator->isValid(123));
     $messages = $this->validator->getMessages();
     $this->assertTrue(array_key_exists(Alpha::INVALID, $messages));
     $this->assertEquals('This is...', $messages[Alpha::INVALID]);
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:16,代码来源:StaticValidatorTest.php

示例10: testHostnameValidatorMessagesShouldBeTranslated

    /**
     * @group ZF-2861
     */
    public function testHostnameValidatorMessagesShouldBeTranslated()
    {
        $hostnameValidator = new Hostname();
        $translations = array(
            'hostnameIpAddressNotAllowed'   => 'hostnameIpAddressNotAllowed translation',
            'hostnameUnknownTld'            => 'hostnameUnknownTld translation',
            'hostnameDashCharacter'         => 'hostnameDashCharacter translation',
            'hostnameInvalidHostnameSchema' => 'hostnameInvalidHostnameSchema translation',
            'hostnameUndecipherableTld'     => 'hostnameUndecipherableTld translation',
            'hostnameInvalidHostname'       => 'hostnameInvalidHostname translation',
            'hostnameInvalidLocalName'      => 'hostnameInvalidLocalName translation',
            'hostnameLocalNameNotAllowed'   => 'hostnameLocalNameNotAllowed translation',
        );
        $loader = new TestAsset\ArrayTranslator();
        $loader->translations = $translations;
        $translator = new Translator();
        $translator->getPluginManager()->setService('test', $loader);
        $translator->addTranslationFile('test', null);

        $this->validator->setTranslator($translator)->setHostnameValidator($hostnameValidator);

        $this->validator->isValid('_XX.!!3xx@0.239,512.777');
        $messages = $hostnameValidator->getMessages();
        $found = false;
        foreach ($messages as $code => $message) {
            if (array_key_exists($code, $translations)) {
                $this->assertEquals($translations[$code], $message);
                $found = true;
                break;
            }
        }
        $this->assertTrue($found);
    }
开发者ID:benivaldo,项目名称:zf2-na-pratica,代码行数:36,代码来源:EmailAddressTest.php

示例11: testValidatorMessagesShouldBeTranslated

 /**
  * Test changed with ZF-6676, as IP check is only involved when IP patterns match
  *
  * @group ZF-2861
  * @group ZF-6676
  */
 public function testValidatorMessagesShouldBeTranslated()
 {
     $translations = array('hostnameInvalidLocalName' => 'this is the IP error message');
     $loader = new TestAsset\ArrayTranslator();
     $loader->translations = $translations;
     $translator = new Translator();
     $translator->getPluginManager()->setService('default', $loader);
     $translator->addTranslationFile('default', null);
     $this->validator->setTranslator($translator);
     $this->validator->isValid('0.239,512.777');
     $messages = $this->validator->getMessages();
     $found = false;
     foreach ($messages as $code => $message) {
         if (array_key_exists($code, $translations)) {
             $found = true;
             break;
         }
     }
     $this->assertTrue($found);
     $this->assertEquals($translations[$code], $message);
 }
开发者ID:navassouza,项目名称:zf2,代码行数:27,代码来源:HostnameTest.php

示例12: testCanDisableTranslator

 public function testCanDisableTranslator()
 {
     $loader = new TestAsset\ArrayTranslator();
     $loader->translations = array('%value% was passed' => 'This is the translated message for %value%');
     $translator = new Translator();
     $translator->getPluginManager()->setService('default', $loader);
     $translator->addTranslationFile('default', null);
     $this->validator->setTranslator($translator);
     $this->assertFalse($this->validator->isValid('bar'));
     $messages = $this->validator->getMessages();
     $this->assertTrue(array_key_exists('fooMessage', $messages));
     $this->assertContains('bar', $messages['fooMessage']);
     $this->assertContains('This is the translated message for ', $messages['fooMessage']);
     $this->validator->setTranslatorEnabled(false);
     $this->assertFalse($this->validator->isTranslatorEnabled());
     $this->assertFalse($this->validator->isValid('bar'));
     $messages = $this->validator->getMessages();
     $this->assertTrue(array_key_exists('fooMessage', $messages));
     $this->assertContains('bar', $messages['fooMessage']);
     $this->assertContains('bar was passed', $messages['fooMessage']);
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:21,代码来源:AbstractTest.php

示例13: testCanTranslateTitle

 public function testCanTranslateTitle()
 {
     if (!extension_loaded('intl')) {
         $this->markTestSkipped('ext/intl not enabled');
     }
     $loader = new TestAsset\ArrayTranslator();
     $loader->translations = array('Message_1' => 'Message 1 (en)');
     $translator = new Translator();
     $translator->getPluginManager()->setService('default', $loader);
     $translator->addTranslationFile('default', null);
     $this->helper->setTranslatorEnabled(true);
     $this->helper->setTranslator($translator);
     $this->helper->__invoke('Message_1');
     $this->assertEquals('Message 1 (en)', $this->helper->renderTitle());
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:15,代码来源:HeadTitleTest.php


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