Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions
Zend_Translate_Adapter_Csv Class Reference
Inheritance diagram for Zend_Translate_Adapter_Csv:
Zend_Translate_Adapter

Public Member Functions

 __construct ($options=array())
 
 toString ()
 
- Public Member Functions inherited from Zend_Translate_Adapter
 __construct ($options=array())
 
 addTranslation ($options=array())
 
 setOptions (array $options=array())
 
 getOptions ($optionKey=null)
 
 getLocale ()
 
 setLocale ($locale)
 
 getList ()
 
 getMessageId ($message, $locale=null)
 
 getMessageIds ($locale=null)
 
 getMessages ($locale=null)
 
 isAvailable ($locale)
 
 translate ($messageId, $locale=null)
 
 plural ($singular, $plural, $number, $locale=null)
 
 _ ($messageId, $locale=null)
 
 isTranslated ($messageId, $original=false, $locale=null)
 
 toString ()
 

Protected Member Functions

 _loadTranslationData ($filename, $locale, array $options=array())
 
- Protected Member Functions inherited from Zend_Translate_Adapter
 _loadTranslationData ($data, $locale, array $options=array())
 
 _log ($message, $locale)
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Translate_Adapter
static getCache ()
 
static setCache (Zend_Cache_Core $cache)
 
static hasCache ()
 
static removeCache ()
 
static clearCache ($tag=null)
 
- Data Fields inherited from Zend_Translate_Adapter
const LOCALE_DIRECTORY = 'directory'
 
const LOCALE_FILENAME = 'filename'
 
- Protected Attributes inherited from Zend_Translate_Adapter
 $_options
 
 $_translate = array()
 
- Static Protected Attributes inherited from Zend_Translate_Adapter
static $_cache = null
 

Detailed Description

Definition at line 36 of file Csv.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options = array())

Generates the adapter

Parameters
array | Zend_Config$optionsTranslation content

Definition at line 45 of file Csv.php.

46  {
47  $this->_options['delimiter'] = ";";
48  $this->_options['length'] = 0;
49  $this->_options['enclosure'] = '"';
50 
51  if ($options instanceof Zend_Config) {
52  $options = $options->toArray();
53  } else if (func_num_args() > 1) {
54  $args = func_get_args();
55  $options = array();
56  $options['content'] = array_shift($args);
57 
58  if (!empty($args)) {
59  $options['locale'] = array_shift($args);
60  }
61 
62  if (!empty($args)) {
63  $opt = array_shift($args);
64  $options = array_merge($opt, $options);
65  }
66  } else if (!is_array($options)) {
67  $options = array('content' => $options);
68  }
69 
70  parent::__construct($options);
71  }

Member Function Documentation

◆ _loadTranslationData()

_loadTranslationData (   $filename,
  $locale,
array  $options = array() 
)
protected

Load translation data

Parameters
string | array$filenameFilename and full path to the translation source
string$localeLocale/Language to add data for, identical with locale identifier, see Zend_Locale for more information
array$optionOPTIONAL Options to use
Returns
array

Definition at line 82 of file Csv.php.

83  {
84  $this->_data = array();
86  $this->_file = @fopen($filename, 'rb');
87  if (!$this->_file) {
88  #require_once 'Zend/Translate/Exception.php';
89  throw new Zend_Translate_Exception('Error opening translation file \'' . $filename . '\'.');
90  }
91 
92  while(($data = fgetcsv($this->_file, $options['length'], $options['delimiter'], $options['enclosure'])) !== false) {
93  if (substr($data[0], 0, 1) === '#') {
94  continue;
95  }
96 
97  if (!isset($data[1])) {
98  continue;
99  }
100 
101  if (count($data) == 2) {
102  $this->_data[$locale][$data[0]] = $data[1];
103  } else {
104  $singular = array_shift($data);
105  $this->_data[$locale][$singular] = $data;
106  }
107  }
108 
109  return $this->_data;
110  }

◆ toString()

toString ( )

returns the adapters name

Returns
string

Definition at line 117 of file Csv.php.

118  {
119  return "Csv";
120  }

The documentation for this class was generated from the following file: