本文整理汇总了PHP中TTi18n::translation_handler方法的典型用法代码示例。如果您正苦于以下问题:PHP TTi18n::translation_handler方法的具体用法?PHP TTi18n::translation_handler怎么用?PHP TTi18n::translation_handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTi18n
的用法示例。
在下文中一共展示了TTi18n::translation_handler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTranslationHandler
public static function getTranslationHandler()
{
if (self::$translation_handler === NULL) {
if (self::useGetTextExtension() == TRUE) {
//Debug::Text('Using getText()...', __FILE__, __LINE__, __METHOD__,10);
return new NativeGettextTranslationHandler();
} else {
//Debug::Text('Using Translation2...', __FILE__, __LINE__, __METHOD__,10);
require_once 'Translation2.php';
$locale_dir = Environment::getBasePath() . DIRECTORY_SEPARATOR . 'interface' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR;
// The Translation2 Gettext example has this comment:
//
// "Better set prefetch to FALSE for the gettext container, so we don't need
// to read in the whole MO file with File_Gettext on every request."
//
// I haven't investigated this fully yet. So for now I am doing as they advise.
// Probably worth checking out for performance purposes. Also, it is unclear
// how this affects PO mode, as opposed to MO.
$params = array('prefetch' => FALSE, 'langs_avail_file' => $locale_dir . 'langs.ini', 'domains_path_file' => $locale_dir . 'domains.ini', 'default_domain' => 'messages', 'file_type' => 'mo', 'cacheDir' => '/tmp/timetrex/', 'lifeTime' => 86400 * 7);
self::$translation_handler = Translation2::factory('gettext', $params);
//self::$translation_handler->getDecorator('CacheLiteFunction');
// Okay, this is super-gross, as we are modifying private data of the
// Translation2::storage object. Why do we do it? Because the
// brain-dead Translation2 api for gettext only allows specifying
// fixed paths via domains.ini file. Our path depends on our environment
// and we need to tell it that. So, it appears we either do this nasty
// hack, or we have to start modifying the Translation2 code directly.
self::$translation_handler->storage->_domains = array('messages' => $locale_dir);
}
}
return self::$translation_handler;
}