本文整理汇总了PHP中i18n::register_translator方法的典型用法代码示例。如果您正苦于以下问题:PHP i18n::register_translator方法的具体用法?PHP i18n::register_translator怎么用?PHP i18n::register_translator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类i18n
的用法示例。
在下文中一共展示了i18n::register_translator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
SS_TemplateLoader::instance()->popManifest();
SS_ClassLoader::instance()->popManifest();
i18n::set_locale($this->originalLocale);
Config::inst()->update('Director', 'alternate_base_folder', null);
Config::inst()->update('SSViewer', 'theme', $this->_oldTheme);
i18n::register_translator($this->origAdapter, 'core');
parent::tearDown();
}
示例2: tearDown
public function tearDown()
{
SS_TemplateLoader::instance()->popManifest();
SS_ClassLoader::instance()->popManifest();
i18n::set_locale($this->originalLocale);
Director::setBaseFolder(null);
SSViewer::set_theme($this->_oldTheme);
i18n::register_translator($this->origAdapter, 'core');
parent::tearDown();
}
示例3: testMultipleTranslators
public function testMultipleTranslators()
{
// Looping through modules, so we can test the translation autoloading
// Load non-exclusive to retain core class autoloading
$classManifest = new SS_ClassManifest($this->alternateBasePath, true, true, false);
SS_ClassLoader::instance()->pushManifest($classManifest);
// Changed manifest, so we also need to unset all previously collected messages.
// The easiest way to do this it to register a new adapter.
$adapter = new Zend_Translate(array('adapter' => 'i18nRailsYamlAdapter', 'locale' => i18n::default_locale(), 'disableNotices' => true));
i18n::register_translator($adapter, 'core');
i18n::set_locale('en_US');
$this->assertEquals(i18n::_t('i18nTestModule.ENTITY'), 'Entity with "Double Quotes"');
$this->assertEquals(i18n::_t('AdapterEntity1', 'AdapterEntity1'), 'AdapterEntity1', 'Falls back to default string if not found');
// Add a new translator
$translator = new Zend_Translate(array('adapter' => 'i18nTest_CustomTranslatorAdapter', 'disableNotices' => true));
i18n::register_translator($translator, 'custom', 11);
$this->assertEquals(i18n::_t('i18nTestModule.ENTITY'), 'i18nTestModule.ENTITY CustomAdapter (en_US)', 'Existing entities overruled by adapter with higher priority');
$this->assertEquals(i18n::_t('AdapterEntity1', 'AdapterEntity1'), 'AdapterEntity1 CustomAdapter (en_US)', 'New entities only defined in new adapter are detected');
// Add a second new translator to test priorities
$translator = new Zend_Translate(array('adapter' => 'i18nTest_OtherCustomTranslatorAdapter', 'disableNotices' => true));
i18n::register_translator($translator, 'othercustom_lower_prio', 5);
$this->assertEquals(i18n::_t('i18nTestModule.ENTITY'), 'i18nTestModule.ENTITY CustomAdapter (en_US)', 'Adapter with lower priority loses');
// Add a third new translator to test priorities
$translator = new Zend_Translate(array('adapter' => 'i18nTest_OtherCustomTranslatorAdapter', 'disableNotices' => true));
i18n::register_translator($translator, 'othercustom_higher_prio', 15);
$this->assertEquals(i18n::_t('i18nTestModule.ENTITY'), 'i18nTestModule.ENTITY OtherCustomAdapter (en_US)', 'Adapter with higher priority wins');
i18n::unregister_translator('custom');
i18n::unregister_translator('othercustom_lower_prio');
i18n::unregister_translator('othercustom_higher_prio');
SS_ClassLoader::instance()->popManifest();
}