Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

darkangel

By: a guest on Apr 16th, 2009  |  syntax: PHP  |  size: 2.75 KB  |  views: 252  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. // Sample config
  4. resources.translate.adapter = "gettext"
  5. resources.translate.data = APPLICATION_PATH "/../data/locales"
  6. resources.translate.options.disableNotices = true
  7. resources.translate.options.scan = "directory"
  8.  
  9. ?>
  10.  
  11. <?php
  12. /**
  13.  * Zend Framework
  14.  *
  15.  * LICENSE
  16.  *
  17.  * This source file is subject to the new BSD license that is bundled
  18.  * with this package in the file LICENSE.txt.
  19.  * It is also available through the world-wide-web at this URL:
  20.  * http://framework.zend.com/license/new-bsd
  21.  * If you did not receive a copy of the license and are unable to
  22.  * obtain it through the world-wide-web, please send an email
  23.  * to license@zend.com so we can send you a copy immediately.
  24.  *
  25.  * @category   Zend
  26.  * @package    Zend_Application
  27.  * @subpackage Resource
  28.  * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  29.  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  30.  * @version    $Id$
  31.  */
  32.  
  33. /**
  34.  * @see Zend_Translate
  35.  */
  36. require_once 'Zend/Translate.php';
  37.  
  38. /**
  39.  * Resource for setting translation options
  40.  *
  41.  * @uses       Zend_Application_Resource_ResourceAbstract
  42.  * @category   Zend
  43.  * @package    Zend_Application
  44.  * @subpackage Resource
  45.  * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  46.  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  47.  */
  48. class Zend_Application_Resource_Translate
  49.     extends Zend_Application_Resource_ResourceAbstract
  50. {
  51.     const DEFAULT_REGISTRY_KEY = 'Zend_Translate';
  52.  
  53.     /**
  54.      * @var Zend_Translate
  55.      */
  56.     protected $_translate;
  57.  
  58.     /**
  59.      * Defined by Zend_Application_Resource_Resource
  60.      *
  61.      * @return Zend_Translate
  62.      */
  63.     public function init()
  64.     {
  65.         return $this->getTranslate();
  66.     }
  67.  
  68.     /**
  69.      * Retrieve translate object
  70.      *
  71.      * @return Zend_Translate
  72.      */
  73.     public function getTranslate()
  74.     {
  75.         if (null === $this->_translate) {
  76.             $options = $this->getOptions();
  77.  
  78.             $adapter = isset($options['adapter']) ? $options['adapter'] : Zend_Translate::AN_ARRAY;
  79.             $data = isset($options['data']) ? $options['data'] : array();
  80.             $locale = isset($options['locale']) ? $options['locale'] : null;
  81.             $translateOptions = isset($options['options']) ? $options['options'] : null;
  82.  
  83.             $this->_translate = new Zend_Translate($adapter, $data, $locale, $translateOptions);
  84.  
  85.             $key = (isset($options['registry_key']) && !is_numeric($options['registry_key']))
  86.                 ? $options['registry_key']
  87.                 : self::DEFAULT_REGISTRY_KEY;
  88.             Zend_Registry::set($key, $this->_translate);
  89.         }
  90.         return $this->_translate;
  91.     }
  92. }