我在使用zend制作url多语言时遇到问题,因为我所遵循的所有指南都没有用 我想要像
这样的网址 localhost/compare/public/en/controller/action
localhost/compare/public/it/controller/action
你能帮忙吗?
这是我的项目结构 不幸的是,这并没有让我加载
-compare
-application
-configs
application.ini
-controllers
ErrorController.php
IndexController.php
-layouts
-scripts
main.phtml
nav.phtml
-models
-views
-scripts
-index
index.phtml
...
Bootstrap.php
-languages
en.php
it.php
-library
-Zend
-public
-css
-js
index.php
这是bootstrap
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected $_view;
protected function _init()
{
$this->bootstrap('frontController');
}
protected function _initLanguage()
{
$locale = new Zend_Locale();
Zend_Registry::set('Zend_Locale', $locale);
$translationPath = dirname( APPLICATION_PATH ) . DIRECTORY_SEPARATOR . 'languages';
$translate = new Zend_Translate('array', $translationPath, $locale);
Zend_Registry::set('Zend_Translate', $translate);
Zend_Validate_Abstract::setDefaultTranslator($translate);
Zend_Form::setDefaultTranslator($translate);
}
protected function _initViewSettings()
{
$this->bootstrap('view');
$this->_view = $this->getResource('view');
}
protected function _initDefaultModuleAutoloader()
{
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('App_');
$this->getResourceLoader()
->addResourceType('modelResource','models/resources','Resource');
}
protected function _initDbParms()
{
$db = new Zend_Db_Adapter_Pdo_Mysql(array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'my_compare'
));
Zend_Db_Table_Abstract::setDefaultAdapter($db);
}
}
这是application.ini
[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 1
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.view.doctype = "HTML5"
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1