Definition at line 41 of file Tmx.php.
◆ _contentElement()
_contentElement |
( |
|
$file, |
|
|
|
$data |
|
) |
| |
|
protected |
Internal method, called by xml element handler for content
- Parameters
-
resource | $file | File handler |
string | $data | Elements content |
Definition at line 214 of file Tmx.php.
216 if (($this->_seg !==
null) and ($this->_tu !==
null) and ($this->_tuv !==
null)) {
217 $this->_content .=
$data;
◆ _endElement()
_endElement |
( |
|
$file, |
|
|
|
$name |
|
) |
| |
|
protected |
Internal method, called by xml element handler at end
- Parameters
-
resource | $file | File handler |
string | $name | Elements name |
Definition at line 180 of file Tmx.php.
182 if (($this->_seg !==
null) and (
$name !==
'seg')) {
183 $this->_content .=
"</".$name.
">";
185 switch (strtolower(
$name)) {
194 if (!empty($this->_srclang) && ($this->_srclang == $this->_tuv)) {
195 $this->_tu = $this->_content;
198 if (!empty($this->_content) or (!isset($this->_data[$this->_tuv][$this->_tu]))) {
199 $this->_data[$this->_tuv][$this->_tu] = $this->_content;
if(!isset($_GET['name'])) $name
◆ _findEncoding()
_findEncoding |
( |
|
$filename | ) |
|
|
protected |
Internal method, detects the encoding of the xml file
- Parameters
-
- Returns
- string Encoding
Definition at line 228 of file Tmx.php.
231 if (strpos($file,
"encoding") !==
false) {
232 $encoding = substr($file, strpos($file,
"encoding") + 9);
233 $encoding = substr($encoding, 1, strpos($encoding, $encoding[0], 1) - 1);
◆ _loadTranslationData()
_loadTranslationData |
( |
|
$filename, |
|
|
|
$locale, |
|
|
array |
$options = array() |
|
) |
| |
|
protected |
Load translation data (TMX file reader)
- Parameters
-
string | $filename | TMX file to add, full path must be given for access |
string | $locale | Locale has no effect for TMX because TMX defines all languages within the source file |
array | $option | OPTIONAL Options to use |
- Exceptions
-
Zend_Translation_Exception | |
- Returns
- array
Definition at line 62 of file Tmx.php.
64 $this->_data = array();
66 #require_once 'Zend/Translate/Exception.php'; 70 if (isset($options['useId
'])) { 71 $this->_useId = (boolean) $options['useId
']; 74 $encoding = $this->_findEncoding($filename); 75 $this->_file = xml_parser_create($encoding); 76 xml_set_object($this->_file, $this); 77 xml_parser_set_option($this->_file, XML_OPTION_CASE_FOLDING, 0); 78 xml_set_element_handler($this->_file, "_startElement", "_endElement"); 79 xml_set_character_data_handler($this->_file, "_contentElement"); 82 Zend_Xml_Security::scanFile($filename); 83 } catch (Zend_Xml_Exception $e) { 84 #require_once 'Zend/Translate/Exception.php
'; 85 throw new Zend_Translate_Exception( 90 if (!xml_parse($this->_file, file_get_contents($filename))) { 91 $ex = sprintf('XML error: %s at line %d of file %s
', 92 xml_error_string(xml_get_error_code($this->_file)), 93 xml_get_current_line_number($this->_file), 95 xml_parser_free($this->_file); 96 #require_once 'Zend/Translate/Exception.php
'; 97 throw new Zend_Translate_Exception($ex);
◆ _startElement()
_startElement |
( |
|
$file, |
|
|
|
$name, |
|
|
|
$attrib |
|
) |
| |
|
protected |
Internal method, called by xml element handler at start
- Parameters
-
resource | $file | File handler |
string | $name | Elements name |
array | $attrib | Attributes for this element |
Definition at line 110 of file Tmx.php.
112 if ($this->_seg !==
null) {
113 $this->_content .=
"<".$name;
114 foreach($attrib as $key =>
$value) {
115 $this->_content .=
" $key=\"$value\"";
117 $this->_content .=
">";
119 switch(strtolower(
$name)) {
121 if (empty($this->_useId) && isset($attrib[
'srclang'])) {
125 if (!$this->_options[
'disableNotices']) {
126 if ($this->_options[
'log']) {
127 $this->_options[
'log']->notice(
"The language '{$attrib['srclang']}' can not be set because it does not exist.");
129 trigger_error(
"The language '{$attrib['srclang']}' can not be set because it does not exist.", E_USER_NOTICE);
133 $this->_srclang = $attrib[
'srclang'];
138 if (isset($attrib[
'tuid'])) {
139 $this->_tu = $attrib[
'tuid'];
143 if (isset($attrib[
'xml:lang'])) {
147 if (!$this->_options[
'disableNotices']) {
148 if ($this->_options[
'log']) {
149 $this->_options[
'log']->notice(
"The language '{$attrib['xml:lang']}' can not be set because it does not exist.");
151 trigger_error(
"The language '{$attrib['xml:lang']}' can not be set because it does not exist.", E_USER_NOTICE);
155 $this->_tuv = $attrib[
'xml:lang'];
158 if (!isset($this->_data[$this->_tuv])) {
159 $this->_data[$this->_tuv] = array();
165 $this->_content =
null;
static isLocale($locale, $strict=false, $compatible=true)
static findLocale($locale=null)
if(!isset($_GET['name'])) $name
◆ toString()
Returns the adapter name
- Returns
- string
Definition at line 244 of file Tmx.php.
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Translate/Adapter/Tmx.php