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();
 }
 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();
 }
Esempio n. 3
0
 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();
 }