Zend Framework에서 경로 변환을 시도하고 싶지만 gettext 어댑터를 사용하고 있고 대부분의 튜토리얼에는 PHP 변환 어댑터가 있기 때문에 작동하게하는 데 문제가 있습니다.ZF의 gettext 어댑터를 사용하여 경로 세그먼트 번역하기
이$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$translator = Zend_Registry::get('Zend_Translate');
Zend_Controller_Router_Route::setDefaultTranslator($translator);
$routerRoute = new Zend_Controller_Router_Route('@about',
array(
'module' => 'default',
'controller' => 'index',
'action' => 'about'
)
);
$router->addRoute('about', $routerRoute);
이 /about
경로를 작동합니다
*.mo
파일을로드 :
$langParam = $this->getSessionLang();
$localeString = $languages[$langParam];
$locale = new Zend_Locale($localeString);
$moFilePath = $langFolder . $langParam . '.mo';
if (!file_exists($moFilePath)) {
throw new Zend_Exception('File does not exist: ' . $moFilePath);
}
$translate = new Zend_Translate(
array(
'adapter' => 'gettext',
'content' => $moFilePath,
'locale' => $locale,
'ignore' => array('.'), // ignore SVN folders
'disableNotices' => ('production' === APPLICATION_ENV) // disable notices in Production
)
);
Zend_Registry::set('Zend_Translate', $translate);
Zend_Registry::set('Zend_Locale' , $locale);
이를, OFC, 그것은 라우팅 prior
를 불렀다.
내 질문 : 길에 대한 번역 어댑터로 gettext를 사용할 수 있습니까? 내가 어떻게 @about
문자열을 잡을 수 있는지 파악할 수 없으므로, poedit을 가정 해 봅시다. 그럴 수있어? 만세! 방법?