Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
zendframework1
library
Zend
Translate
Adapter
Gettext.php
Go to the documentation of this file.
1
<?php
23
#require_once 'Zend/Locale.php';
24
26
#require_once 'Zend/Translate/Adapter.php';
27
34
class
Zend_Translate_Adapter_Gettext
extends
Zend_Translate_Adapter
{
35
// Internal variables
36
private
$_bigEndian =
false
;
37
private
$_file =
false
;
38
private
$_adapterInfo = array();
39
private
$_data = array();
40
46
private
function
_readMOData($bytes)
47
{
48
if
($this->_bigEndian ===
false
) {
49
return
unpack(
'V'
. $bytes, fread($this->_file, 4 * $bytes));
50
}
else
{
51
return
unpack(
'N'
. $bytes, fread($this->_file, 4 * $bytes));
52
}
53
}
54
65
protected
function
_loadTranslationData
($filename, $locale, array
$options
= array())
66
{
67
$this->_data = array();
68
$this->_bigEndian =
false
;
69
$this->_file = @
fopen
($filename,
'rb'
);
70
if
(!$this->_file) {
71
#require_once 'Zend/Translate/Exception.php';
72
throw
new
Zend_Translate_Exception
(
'Error opening translation file \''
. $filename .
'\'
.
');
73
}
74
if (@filesize($filename) < 10) {
75
@fclose($this->_file);
76
#require_once '
Zend
/Translate/Exception.php
';
77
throw new Zend_Translate_Exception('
\
''
. $filename .
'\'
is not a gettext file
');
78
}
79
80
// get Endian
81
$input = $this->_readMOData(1);
82
if (strtolower(substr(dechex($input[1]), -8)) == "950412de") {
83
$this->_bigEndian = false;
84
} else if (strtolower(substr(dechex($input[1]), -8)) == "de120495") {
85
$this->_bigEndian = true;
86
} else {
87
@fclose($this->_file);
88
#require_once '
Zend
/Translate/Exception.php
';
89
throw new Zend_Translate_Exception('
\
''
. $filename .
'\'
is not a gettext file
');
90
}
91
// read revision - not supported for now
92
$input = $this->_readMOData(1);
93
94
// number of bytes
95
$input = $this->_readMOData(1);
96
$total = $input[1];
97
98
// number of original strings
99
$input = $this->_readMOData(1);
100
$OOffset = $input[1];
101
102
// number of translation strings
103
$input = $this->_readMOData(1);
104
$TOffset = $input[1];
105
106
// fill the original table
107
fseek($this->_file, $OOffset);
108
$origtemp = $this->_readMOData(2 * $total);
109
fseek($this->_file, $TOffset);
110
$transtemp = $this->_readMOData(2 * $total);
111
112
for($count = 0; $count < $total; ++$count) {
113
if ($origtemp[$count * 2 + 1] != 0) {
114
fseek($this->_file, $origtemp[$count * 2 + 2]);
115
$original = @fread($this->_file, $origtemp[$count * 2 + 1]);
116
$original = explode("\0", $original);
117
} else {
118
$original[0] = '
';
119
}
120
121
if ($transtemp[$count * 2 + 1] != 0) {
122
fseek($this->_file, $transtemp[$count * 2 + 2]);
123
$translate = fread($this->_file, $transtemp[$count * 2 + 1]);
124
$translate = explode("\0", $translate);
125
if ((count($original) > 1)) {
126
$this->_data[$locale][$original[0]] = $translate;
127
array_shift($original);
128
foreach ($original as $orig) {
129
$this->_data[$locale][$orig] = '
';
130
}
131
} else {
132
$this->_data[$locale][$original[0]] = $translate[0];
133
}
134
}
135
}
136
137
@fclose($this->_file);
138
139
$this->_data[$locale]['
'] = trim($this->_data[$locale]['
']);
140
if (empty($this->_data[$locale]['
'])) {
141
$this->_adapterInfo[$filename] = '
No adapter information available
';
142
} else {
143
$this->_adapterInfo[$filename] = $this->_data[$locale]['
'];
144
}
145
146
unset($this->_data[$locale]['
']);
147
return $this->_data;
148
}
149
155
public function getAdapterInfo()
156
{
157
return $this->_adapterInfo;
158
}
159
165
public function toString()
166
{
167
return "Gettext";
168
}
169
}
Zend_Translate_Adapter_Gettext
Definition:
Gettext.php:34
Magento\Setup\Model\Cron\fopen
fopen()
Definition:
JobFactoryTest.php:212
Zend_Translate_Adapter_Gettext\_loadTranslationData
_loadTranslationData($filename, $locale, array $options=array())
Definition:
Gettext.php:65
Zend_Translate_Exception
Definition:
Exception.php:35
Zend_Translate_Adapter
Definition:
Adapter.php:42
Zend
$options
$options
Definition:
multiple_mixed_products.php:29