本文整理汇总了PHP中Zend_Controller_Router_Route::setDefaultTranslator方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Router_Route::setDefaultTranslator方法的具体用法?PHP Zend_Controller_Router_Route::setDefaultTranslator怎么用?PHP Zend_Controller_Router_Route::setDefaultTranslator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Router_Route
的用法示例。
在下文中一共展示了Zend_Controller_Router_Route::setDefaultTranslator方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: routeShutdown
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
$language = $request->getParam("language", Zend_Registry::get('Zend_Locale')->getLanguage());
$locale = new Zend_Locale($language);
Zend_Registry::get('Zend_Locale')->setLocale($locale);
$translate = Zend_Registry::get('Zend_Translate');
$translate->getAdapter()->setLocale(Zend_Registry::get('Zend_Locale'));
Zend_Controller_Router_Route::setDefaultTranslator($translate);
}
示例2: testTranslationAssembleTranslatorStaticOverride
public function testTranslationAssembleTranslatorStaticOverride()
{
$translator = new Zend_Translate('array', array('foo' => 'en_baz'), 'en');
Zend_Controller_Router_Route::setDefaultTranslator($translator);
$route = new Zend_Controller_Router_Route('foo/@foo');
$url = $route->assemble();
$this->assertEquals('foo/en_baz', $url);
}
示例3: _initTranslate
/**
* Initializes translator
*
* @return Zend_Translate_Adapter
*/
public function _initTranslate()
{
$log = new Zend_Log();
if (APPLICATION_ENV == 'development') {
$log = new Zend_Log();
$log->addWriter(new Zend_Log_Writer_Firebug());
//$log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/translate.log'));
} else {
$log->addWriter(new Zend_Log_Writer_Null());
}
$params['log'] = $log;
// Create the object and add a language
$translate = new Zend_Translate('Array', APPLICATION_PATH . '/languages/vi/vi.php', 'vi_VN');
// Add another translation
$translate->addTranslation(APPLICATION_PATH . '/languages/en/en.php', 'en_US');
// Set nb_NO as default translation
$translate->setLocale('vi_VN');
Zend_Registry::set('Zend_Translate', $translate);
Zend_Validate_Abstract::setDefaultTranslator($translate);
Zend_Form::setDefaultTranslator($translate);
Zend_Controller_Router_Route::setDefaultTranslator($translate);
return $translate;
}
示例4: Zend_Translate
<?php
$conf = Zend_Registry::get("conf");
try {
// Translation
$translateUrl = new Zend_Translate('gettext', APPLICATION_DIRECTORY . '/Joobsbox/Languages/' . $locale . '/LC_MESSAGES/url.mo', $locale, array('disableNotices' => true));
} catch (Exception $e) {
$translateUrl = new Zend_Translate('gettext', APPLICATION_DIRECTORY . '/Joobsbox/Languages/en/LC_MESSAGES/url.mo', 'en');
}
Zend_Registry::set("Joobsbox_Translate_URL", $translateUrl);
Zend_Controller_Router_Route::setDefaultTranslator($translateUrl);
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$rssRoute = new Zend_Controller_Router_Route('rss/@category/:category', array('controller' => 'rss', 'action' => 'index'));
$mainRoute = new Zend_Controller_Router_Route(':@controller/:@action/*', array('controller' => 'index', 'action' => 'index'));
$mainRoute2 = new Zend_Controller_Router_Route('index.php/:@controller/:@action/*', array('controller' => 'index', 'action' => 'index'));
$router->addRoute("main", $mainRoute);
$router->addRoute("main2", $mainRoute2);
$router->addRoute("rss", $rssRoute);
$mainRoute->assemble(array());
$mainRoute->assemble(array());
$mainRoute2->assemble(array());
$mainRoute2->assemble(array());
$front->setRouter($router);
示例5: _initTranslate
//.........这里部分代码省略.........
foreach( $it as $item ) {
if( $item->isDot() || !$item->isDir() ) {
continue;
}
$name = $item->getBasename();
if( !Zend_Locale::isLocale($name) ) {
continue;
}
$languages[] = $name;
}
*/
// If in development, log untranslated messages
$params = array('scan' => Zend_Translate_Adapter::LOCALE_DIRECTORY, 'logUntranslated' => true);
$log = new Zend_Log();
if (APPLICATION_ENV == 'development') {
$log = new Zend_Log();
$log->addWriter(new Zend_Log_Writer_Firebug());
$log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/translate.log'));
} else {
$log->addWriter(new Zend_Log_Writer_Null());
}
$params['log'] = $log;
// Check Locale
$locale = Zend_Locale::findLocale();
// Make Sure Language Folder Exist
$languageFolder = is_dir(APPLICATION_PATH . '/application/languages/' . $locale);
if ($languageFolder === false) {
$locale = substr($locale, 0, 2);
$languageFolder = is_dir(APPLICATION_PATH . '/application/languages/' . $locale);
if ($languageFolder == false) {
$locale = 'en';
}
}
// Check which Translation Adapter has been selected
$db = Engine_Db_Table::getDefaultAdapter();
$translationAdapter = $db->select()->from('engine4_core_settings', 'value')->where('`name` = ?', 'core.translate.adapter')->query()->fetchColumn();
// If adapter is 'array', Make sure array files exist
/*
if( $translationAdapter == 'array'){
// Check if Language File Exists
if( !file_exists(APPLICATION_PATH . '/application/languages/' . $locale . '/' . $locale . '.php')){
//echo 'Locale does not exist ' . APPLICATION_PATH . '/application/languages/' . $locale . '/' . $locale . '_array.php<br />';
// Try looking elsewhere
$newLocale = substr($locale, 0, 2);
//echo 'Attempting to Look for ' . $newLocale . '<br />';
if( file_exists(APPLICATION_PATH . '/application/languages/' . $newLocale . '/' . $newLocale . '.php')){
$locale = $newLocale;
//echo 'New Locale Found ' . APPLICATION_PATH . '/application/languages/' . $newLocale . '/' . $newLocale . '_array.php<br />';
} else { $translationAdapter = 'csv'; $locale = 'en'; }
}
}
*/
// Use Array Translation Adapter, Loop through all Availible Translations
if ($translationAdapter == 'array') {
// Find all Valid Language Arrays
// Check For Array Files
$languagePath = APPLICATION_PATH . '/application/languages';
// Get List of Folders
$languageFolders = array_filter(glob($languagePath . DIRECTORY_SEPARATOR . '*'), 'is_dir');
// Look inside Folders for PHP array
$locale_array = array();
foreach ($languageFolders as $folder) {
// Get Locale code
$locale_code = str_replace($languagePath . DIRECTORY_SEPARATOR, "", $folder);
$locale_array[] = $locale_code;
if (!file_exists($folder . DIRECTORY_SEPARATOR . $locale_code . '.php')) {
// If Array files do not exist, switch to CSV
$translationAdapter = 'csv';
}
}
$language_count = count($locale_array);
// Add the First One
$translate = new Zend_Translate(array('adapter' => 'array', 'content' => $languagePath . DIRECTORY_SEPARATOR . $locale_array[0] . DIRECTORY_SEPARATOR . $locale_array[0] . '.php', 'locale' => $locale_array[0]));
if ($language_count > 1) {
for ($i = 1; $i < $language_count; $i++) {
$translate->addTranslation(array('content' => $languagePath . DIRECTORY_SEPARATOR . $locale_array[$i] . DIRECTORY_SEPARATOR . $locale_array[$i] . '.php', 'locale' => $locale_array[$i]));
}
}
/*
if( $language_count > 1) {
for( $i = 1; $i < $language_count; $i++ ) {
$translate->addTranslation(
array(
'content' => $languageFolders[$i] . DIRECTORY_SEPARATOR . $locale_array[$i] . '.php',
'locale' => $locale_array[$i] )
);
echo $locale_array[$i] . ' Translation Added<br />';
}
}
* */
} else {
$translate = new Zend_Translate('Csv', APPLICATION_PATH . '/application/languages', null, $params);
}
Zend_Registry::set('Zend_Translate', $translate);
Zend_Validate_Abstract::setDefaultTranslator($translate);
Zend_Form::setDefaultTranslator($translate);
Zend_Controller_Router_Route::setDefaultTranslator($translate);
return $translate;
}
示例6: _initTranslate
/**
* Initializes translator
*
* @return Zend_Translate_Adapter
*/
public function _initTranslate()
{
// Create a log instance for untranslated messages
//$writer = new Zend_Log_Writer_Firebug();
//$log = new Zend_Log($writer);
// Create translate
/*
$translate = new Engine_Translate(array(
//'scan' => Zend_Translate::LOCALE_FILENAME,
'log' => $this->getContainer()->log, //$log,
'logUntranslated' => ( APPLICATION_ENV === 'development' )
));
*/
if (isset($this->getContainer()->cache)) {
Zend_Translate::setCache($this->getContainer()->cache);
}
// If in development, log untranslated messages
$params = array('scan' => Zend_Translate_Adapter::LOCALE_DIRECTORY, 'logUntranslated' => true);
$log = new Zend_Log();
if (APPLICATION_ENV == 'development') {
$log = new Zend_Log();
$log->addWriter(new Zend_Log_Writer_Firebug());
$log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/translate.log'));
} else {
$log->addWriter(new Zend_Log_Writer_Null());
}
$params['log'] = $log;
$translate = new Zend_Translate('Csv', APPLICATION_PATH . '/application/languages', null, $params);
Zend_Registry::set('Zend_Translate', $translate);
Zend_Validate_Abstract::setDefaultTranslator($translate);
Zend_Form::setDefaultTranslator($translate);
Zend_Controller_Router_Route::setDefaultTranslator($translate);
return $translate;
}
示例7: initRoutes
public function initRoutes()
{
$config = Zend_Registry::get('config');
$this->_front->setBaseUrl($config->system->web->baseurl);
$nl = array('content' => 'inhoud', 'news' => 'nieuws', 'events' => 'kalender', 'doctor' => 'team');
$fr = array('content' => 'contenu', 'news' => 'nouvelles', 'events' => 'kalender', 'doctor' => 'team');
$translator = new Zend_Translate('array', $nl, 'nl');
$translator->addTranslation($fr, 'fr');
$request = $this->getRequest();
$languageTranslator = substr($request->getRequestUri(), 1, 2);
$locales = $config->locale->list->toArray();
if (!isset($locales[$languageTranslator])) {
$languageTranslator = $config->locale->default;
}
$translator->setLocale($languageTranslator);
Zend_Controller_Router_Route::setDefaultTranslator($translator);
$router = $this->_front->getRouter();
$localeRoute = new Zend_Controller_Router_Route(':lng', array('controller' => 'index', 'action' => 'content', 'module' => 'default', 'lng' => 'nl'), array('lng' => '(nl|fr)'));
$router->addRoute('locale', $localeRoute);
$contentRoute = new Zend_Controller_Router_Route_Regex('(.+)', array('controller' => 'index', 'action' => 'content', 'url' => null), array(1 => 'url'), '%s');
$router->addRoute('content', $localeRoute->chain($contentRoute, '/'));
$router->addRoute('events-index', $localeRoute->chain(new Zend_Controller_Router_Route('@events/*', array('controller' => 'events', 'action' => 'index')), '/'));
$router->addRoute('events-detail', $localeRoute->chain(new Zend_Controller_Router_Route('@events/:id/:title', array('controller' => 'events', 'action' => 'detail'), array('id' => '\\d+')), '/'));
$router->addRoute('contact', $localeRoute->chain(new Zend_Controller_Router_Route('@contact/*', array('controller' => 'contact', 'action' => 'form')), '/'));
$router->addRoute('sitemap', $localeRoute->chain(new Zend_Controller_Router_Route('@sitemap/*', array('controller' => 'sitemap', 'action' => 'index')), '/'));
$router->addRoute('doctor-index', $localeRoute->chain(new Zend_Controller_Router_Route('@doctor/*', array('controller' => 'doctor', 'action' => 'index')), '/'));
$router->addRoute('doctor-detail', $localeRoute->chain(new Zend_Controller_Router_Route('@doctor/:id/:title', array('controller' => 'doctor', 'action' => 'detail'), array('id' => '\\d+')), '/'));
$router->addRoute('ajax-captcha', $localeRoute->chain(new Zend_Controller_Router_Route('captcha', array('controller' => 'index', 'action' => 'ajaxcaptcha')), '/'));
/* NEWS EXAMPLE */
$router->addRoute('news-index', $localeRoute->chain(new Zend_Controller_Router_Route('@news/*', array('controller' => 'news', 'action' => 'index')), '/'));
$router->addRoute('news-detail', $localeRoute->chain(new Zend_Controller_Router_Route('@news/:id/:title', array('controller' => 'news', 'action' => 'detail'), array('id' => '\\d+')), '/'));
/* NEWS EXAMPLE END */
$router->addRoute('admin', new Zend_Controller_Router_Route('admin/:controller/:action/*', array('controller' => 'index', 'action' => 'index', 'module' => 'admin')));
$router->addRoute('file-download', new Zend_Controller_Router_Route_Regex('files/(.*)', array('controller' => 'file', 'action' => 'download'), array(1 => 'filename'), 'files%s'));
}