当前位置: 首页>>代码示例>>PHP>>正文


PHP TTi18n::translation_handler方法代码示例

本文整理汇总了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;
 }
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:32,代码来源:TTi18n.class.php


注:本文中的TTi18n::translation_handler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。