Ini.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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-2015 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @version $Id$
  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-2015 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_Ini 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. * @throws Zend_Translate_Exception Ini file not found
  42. * @return array
  43. */
  44. protected function _loadTranslationData($data, $locale, array $options = array())
  45. {
  46. $this->_data = array();
  47. if (!file_exists($data)) {
  48. #require_once 'Zend/Translate/Exception.php';
  49. throw new Zend_Translate_Exception("Ini file '".$data."' not found");
  50. }
  51. $inidata = parse_ini_file($data, false);
  52. if (!isset($this->_data[$locale])) {
  53. $this->_data[$locale] = array();
  54. }
  55. $this->_data[$locale] = array_merge($this->_data[$locale], $inidata);
  56. return $this->_data;
  57. }
  58. /**
  59. * returns the adapters name
  60. *
  61. * @return string
  62. */
  63. public function toString()
  64. {
  65. return "Ini";
  66. }
  67. }