PageRenderTime 97ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/library/Zend/Translate/Adapter/Array.php

https://bitbucket.org/ksekar/campus
PHP | 81 lines | 31 code | 9 blank | 41 comment | 4 complexity | b0dec82e453070dc2f47de03adb7ec9d MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, MIT
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Translate
  17. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @version $Id: Array.php 24594 2012-01-05 21:27:01Z matthew $
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /** Zend_Locale */
  22. require_once 'Zend/Locale.php';
  23. /** Zend_Translate_Adapter */
  24. require_once 'Zend/Translate/Adapter.php';
  25. /**
  26. * @category Zend
  27. * @package Zend_Translate
  28. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. */
  31. class Zend_Translate_Adapter_Array extends Zend_Translate_Adapter
  32. {
  33. private $_data = array();
  34. /**
  35. * Load translation data
  36. *
  37. * @param string|array $data
  38. * @param string $locale Locale/Language to add data for, identical with locale identifier,
  39. * see Zend_Locale for more information
  40. * @param array $options OPTIONAL Options to use
  41. * @return array
  42. */
  43. protected function _loadTranslationData($data, $locale, array $options = array())
  44. {
  45. $this->_data = array();
  46. if (!is_array($data)) {
  47. if (file_exists($data)) {
  48. ob_start();
  49. $data = include($data);
  50. ob_end_clean();
  51. }
  52. }
  53. if (!is_array($data)) {
  54. require_once 'Zend/Translate/Exception.php';
  55. throw new Zend_Translate_Exception("Error including array or file '".$data."'");
  56. }
  57. if (!isset($this->_data[$locale])) {
  58. $this->_data[$locale] = array();
  59. }
  60. $this->_data[$locale] = $data + $this->_data[$locale];
  61. return $this->_data;
  62. }
  63. /**
  64. * returns the adapters name
  65. *
  66. * @return string
  67. */
  68. public function toString()
  69. {
  70. return "Array";
  71. }
  72. }