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


PHP Translator::getList方法代碼示例

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


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

示例1: testRoutingOnHttpHeader

    /**
     * @group ZF-10911
     */
    public function testRoutingOnHttpHeader()
    {
        $translate = new Translator\Translator(
            array(
                'adapter'   => Translator\Translator::AN_ARRAY,
                'content'   => __DIR__ . '/Adapter/_files/testarray/',
                'locale'    => 'auto',
                'scan'      => Translator\Translator::LOCALE_FILENAME,
                'ignore'    => array('.', 'ignoreme', 'LC_OTHER'),
                // needed because browser settings can not be simulated in phpunit
                'route'     => array('ja' => 'de_AT', 'de_AT' => 'de_DE', 'de_DE' => 'en_US'),
                'routeHttp' => true,
            )
        );

        $translate2 = new Translator\Translator(
            array(
                'adapter' => Translator\Translator::AN_CSV,
                'content' => __DIR__ . '/Adapter/_files/translation_en.csv',
                'locale'  => 'en_US',
            )
        );

        $translate->addTranslation($translate2);

        $langs = $translate->getList();
        $this->assertFalse(array_key_exists('de_AT', $langs));
        $this->assertTrue(array_key_exists('ja', $langs));
        $this->assertTrue(array_key_exists('en_US', $langs));
        $this->assertEquals('Message 5 (en)', $translate->translate('Message 5', 'ja'));
    }
開發者ID:niallmccrudden,項目名稱:zf2,代碼行數:34,代碼來源:TranslatorTest.php

示例2: testDoubleReroutingForTranslations

 /**
  * @group ZF-2736
  */
 public function testDoubleReroutingForTranslations()
 {
     $translate = new Translator\Translator(array('adapter' => Translator\Translator::AN_ARRAY, 'content' => __DIR__ . '/Adapter/_files/testarray/', 'locale' => 'auto', 'scan' => Translator\Translator::LOCALE_FILENAME, 'ignore' => array('.', 'ignoreme', 'LC_TEST'), 'route' => array('ja' => 'en_US', 'en_US' => 'ja')));
     $translate2 = new Translator\Translator(array('adapter' => Translator\Translator::AN_CSV, 'content' => __DIR__ . '/Adapter/_files/translation_en.csv', 'locale' => 'en_US'));
     $translate->addTranslation($translate2);
     $langs = $translate->getList();
     $this->assertFalse(array_key_exists('de_DE', $langs));
     $this->assertTrue(array_key_exists('ja', $langs));
     $this->assertTrue(array_key_exists('en_US', $langs));
     $this->assertEquals('Message 5 (en)', $translate->translate('Message 5', 'ja'));
     $this->assertEquals('Message 5 (en)', $translate->translate('Message 5', 'ja'));
 }
開發者ID:,項目名稱:,代碼行數:15,代碼來源:

示例3: testAddingAdapterToSourcealsUsingOwnRule

 /**
  * @group ZF-9489
  */
 public function testAddingAdapterToSourcealsUsingOwnRule()
 {
     $translate = new Translator\Translator(Translator\Translator::AN_ARRAY, array('singular' => array('plural_0 (en)', 'plural_1 (en)', 'plural_2 (en)', 'plural_3 (en)'), 'plural' => ''), 'en');
     $this->assertFalse($translate->isTranslated('Message 1'));
     $adapter = new Adapter\Gettext(dirname(__FILE__) . '/Adapter/_files/translation_en.mo', 'en');
     $translate->addTranslation($adapter);
     $this->assertTrue($adapter->isTranslated('Message 1'));
     $adapter2 = new Adapter\Gettext(dirname(__FILE__) . '/Adapter/_files/testmo/de_AT/LC_TEST/translation-de_DE.mo', 'de_AT');
     $adapter2->addTranslation(dirname(__FILE__) . '/Adapter/_files/translation_en2.mo', 'fr');
     $translate->addTranslation($adapter2, 'fr');
     $languages = $translate->getList();
     $this->assertFalse(array_key_exists('de_AT', $languages));
     $this->assertTrue(array_key_exists('fr', $languages));
 }
開發者ID:alab1001101,項目名稱:zf2,代碼行數:17,代碼來源:TranslateTest.php


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