Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Data Fields
Zend_Translate Class Reference

Public Member Functions

 __construct ($options=array())
 
 setAdapter ($options=array())
 
 getAdapter ()
 
 __call ($method, array $options)
 

Static Public Member Functions

static getCache ()
 
static setCache (Zend_Cache_Core $cache)
 
static hasCache ()
 
static removeCache ()
 
static clearCache ($tag=null)
 

Data Fields

const AN_ARRAY = 'Array'
 
const AN_CSV = 'Csv'
 
const AN_GETTEXT = 'Gettext'
 
const AN_INI = 'Ini'
 
const AN_QT = 'Qt'
 
const AN_TBX = 'Tbx'
 
const AN_TMX = 'Tmx'
 
const AN_XLIFF = 'Xliff'
 
const AN_XMLTM = 'XmlTm'
 
const LOCALE_DIRECTORY = 'directory'
 
const LOCALE_FILENAME = 'filename'
 

Detailed Description

Definition at line 39 of file Translate.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options = array())

Generates the standard translation object

Parameters
array | Zend_Config | Zend_Translate_Adapter$optionsOptions to use
string|array[$content] Path to content, or content itself
string|Zend_Locale[$locale]
Exceptions
Zend_Translate_Exception

Definition at line 71 of file Translate.php.

72  {
73  if ($options instanceof Zend_Config) {
74  $options = $options->toArray();
75  } else if (func_num_args() > 1) {
76  $args = func_get_args();
77  $options = array();
78  $options['adapter'] = array_shift($args);
79  if (!empty($args)) {
80  $options['content'] = array_shift($args);
81  }
82 
83  if (!empty($args)) {
84  $options['locale'] = array_shift($args);
85  }
86 
87  if (!empty($args)) {
88  $opt = array_shift($args);
89  $options = array_merge($opt, $options);
90  }
91  } else if (!is_array($options)) {
92  $options = array('adapter' => $options);
93  }
94 
95  $this->setAdapter($options);
96  }
setAdapter($options=array())
Definition: Translate.php:106

Member Function Documentation

◆ __call()

__call (   $method,
array  $options 
)

Calls all methods from the adapter

Definition at line 216 of file Translate.php.

217  {
218  if (method_exists($this->_adapter, $method)) {
219  return call_user_func_array(array($this->_adapter, $method), $options);
220  }
221  #require_once 'Zend/Translate/Exception.php';
222  throw new Zend_Translate_Exception("Unknown method '" . $method . "' called!");
223  }
$method
Definition: info.phtml:13

◆ clearCache()

static clearCache (   $tag = null)
static

Clears all set cache data

Parameters
string$tagTag to clear when the default tag name is not used
Returns
void

Definition at line 208 of file Translate.php.

209  {
211  }
static clearCache($tag=null)
Definition: Adapter.php:959

◆ getAdapter()

getAdapter ( )

Returns the adapters name and it's options

Returns
Zend_Translate_Adapter

Definition at line 156 of file Translate.php.

157  {
158  return $this->_adapter;
159  }

◆ getCache()

static getCache ( )
static

Returns the set cache

Returns
Zend_Cache_Core The set cache

Definition at line 166 of file Translate.php.

167  {
169  }

◆ hasCache()

static hasCache ( )
static

Returns true when a cache is set

Returns
boolean

Definition at line 187 of file Translate.php.

188  {
190  }

◆ removeCache()

static removeCache ( )
static

Removes any set cache

Returns
void

Definition at line 197 of file Translate.php.

198  {
200  }

◆ setAdapter()

setAdapter (   $options = array())

Sets a new adapter

Parameters
array | Zend_Config | Zend_Translate_Adapter$optionsOptions to use
string|array[$content] Path to content, or content itself
string|Zend_Locale[$locale]
Exceptions
Zend_Translate_Exception

Definition at line 106 of file Translate.php.

107  {
108  if ($options instanceof Zend_Config) {
109  $options = $options->toArray();
110  } else if (func_num_args() > 1) {
111  $args = func_get_args();
112  $options = array();
113  $options['adapter'] = array_shift($args);
114  if (!empty($args)) {
115  $options['content'] = array_shift($args);
116  }
117 
118  if (!empty($args)) {
119  $options['locale'] = array_shift($args);
120  }
121 
122  if (!empty($args)) {
123  $opt = array_shift($args);
124  $options = array_merge($opt, $options);
125  }
126  } else if (!is_array($options)) {
127  $options = array('adapter' => $options);
128  }
129 
130  if (Zend_Loader::isReadable('Zend/Translate/Adapter/' . ucfirst($options['adapter']). '.php')) {
131  $options['adapter'] = 'Zend_Translate_Adapter_' . ucfirst($options['adapter']);
132  }
133 
134  if (!class_exists($options['adapter'])) {
135  Zend_Loader::loadClass($options['adapter']);
136  }
137 
138  if (array_key_exists('cache', $options)) {
140  }
141 
142  $adapter = $options['adapter'];
143  unset($options['adapter']);
144  $this->_adapter = new $adapter($options);
145  if (!$this->_adapter instanceof Zend_Translate_Adapter) {
146  #require_once 'Zend/Translate/Exception.php';
147  throw new Zend_Translate_Exception("Adapter " . $adapter . " does not extend Zend_Translate_Adapter");
148  }
149  }
static loadClass($class, $dirs=null)
Definition: Loader.php:52
$adapter
Definition: webapi_user.php:16
static isReadable($filename)
Definition: Loader.php:162
static setCache(Zend_Cache_Core $cache)
Definition: Adapter.php:923

◆ setCache()

static setCache ( Zend_Cache_Core  $cache)
static

Sets a cache for all instances of Zend_Translate

Parameters
Zend_Cache_Core$cacheCache to store to
Returns
void

Definition at line 177 of file Translate.php.

178  {
180  }
static setCache(Zend_Cache_Core $cache)
Definition: Adapter.php:923

Field Documentation

◆ AN_ARRAY

const AN_ARRAY = 'Array'

Adapter names constants

Definition at line 43 of file Translate.php.

◆ AN_CSV

const AN_CSV = 'Csv'

Definition at line 44 of file Translate.php.

◆ AN_GETTEXT

const AN_GETTEXT = 'Gettext'

Definition at line 45 of file Translate.php.

◆ AN_INI

const AN_INI = 'Ini'

Definition at line 46 of file Translate.php.

◆ AN_QT

const AN_QT = 'Qt'

Definition at line 47 of file Translate.php.

◆ AN_TBX

const AN_TBX = 'Tbx'

Definition at line 48 of file Translate.php.

◆ AN_TMX

const AN_TMX = 'Tmx'

Definition at line 49 of file Translate.php.

◆ AN_XLIFF

const AN_XLIFF = 'Xliff'

Definition at line 50 of file Translate.php.

◆ AN_XMLTM

const AN_XMLTM = 'XmlTm'

Definition at line 51 of file Translate.php.

◆ LOCALE_DIRECTORY

const LOCALE_DIRECTORY = 'directory'

Definition at line 53 of file Translate.php.

◆ LOCALE_FILENAME

const LOCALE_FILENAME = 'filename'

Definition at line 54 of file Translate.php.


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