1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Internationalization (i18n) and Localization (l10n) - Zend Framework Manual</title>
</head>
<body>
<table width="100%">
<tr valign="top">
<td width="85%">
<table width="100%">
<tr>
<td width="25%" style="text-align: left;">
<a href="performance.database.html">Zend_Db Performance</a>
</td>
<td width="50%" style="text-align: center;">
<div class="up"><span class="up"><a href="performance.html">Zend Gdata Performance Guide</a></span><br />
<span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
</td>
<td width="25%" style="text-align: right;">
<div class="next" style="text-align: right; float: right;"><a href="performance.view.html">View Rendering</a></div>
</td>
</tr>
</table>
<hr />
<div id="performance.localization" class="section"><div class="info"><h1 class="title">Internationalization (i18n) and Localization (l10n)</h1></div>
<p class="para">
Internationalizing and localizing a site are fantastic ways to expand
your audience and ensure that all visitors can get to the information
they need. However, it often comes with a performance penalty. Below
are some strategies you can employ to reduce the overhead of i18n and
l10n.
</p>
<div class="section" id="performance.localization.translationadapter" name="performance.localization.translationadapter"><div class="info"><h1 class="title">Which translation adapter should I use?</h1></div>
<p class="para">
Not all translation adapters are made equal. Some have more
features than others, and some perform better than others.
Additionally, you may have business requirements that force you to
use a particular adapter. However, if you have a choice, which
adapters are fastest?
</p>
<div class="section" id="performance.localization.translationadapter.fastest" name="performance.localization.translationadapter.fastest"><div class="info"><h1 class="title">Use non-XML translation adapters for greatest speed</h1></div>
<p class="para">
Zend Framework ships with a variety of translation adapters.
Fully half of them utilize an <acronym class="acronym">XML</acronym> format, incurring memory and
performance overhead. Fortunately, there are several adapters
that utilize other formats that can be parsed much more
quickly. In order of speed, from fastest to slowest, they are:
</p>
<ul class="itemizedlist">
<li class="listitem">
<p class="para">
<em class="emphasis">Array</em>: this is the fastest, as it is, by
definition, parsed into a native <acronym class="acronym">PHP</acronym> format immediately
on inclusion.
</p>
</li>
<li class="listitem">
<p class="para">
<em class="emphasis"><acronym class="acronym">CSV</acronym></em>: uses
<span class="methodname">fgetcsv()</span> to parse a <acronym class="acronym">CSV</acronym> file
and transform it into a native <acronym class="acronym">PHP</acronym> format.
</p>
</li>
<li class="listitem">
<p class="para">
<em class="emphasis"><acronym class="acronym">INI</acronym></em>: uses
<span class="methodname">parse_ini_file()</span> to parse an <acronym class="acronym">INI</acronym>
file and transform it into a native <acronym class="acronym">PHP</acronym> format. This and
the <acronym class="acronym">CSV</acronym> adapter are roughly equivalent performance-wise.
</p>
</li>
<li class="listitem">
<p class="para">
<em class="emphasis">Gettext</em>: The gettext adapter from Zend Framework
does <em class="emphasis">not</em> use the gettext
extension as it is not thread safe and does not allow
specifying more than one locale per server. As a result, it
is slower than using the gettext extension directly, but,
because the gettext format is binary, it's faster to parse
than <acronym class="acronym">XML</acronym>.
</p>
</li>
</ul>
<p class="para">
If high performance is one of your concerns, we suggest
utilizing one of the above adapters.
</p>
</div>
</div>
<div class="section" id="performance.localization.cache" name="performance.localization.cache"><div class="info"><h1 class="title">How can I make translation and localization even faster?</h1></div>
<p class="para">
Maybe, for business reasons, you're limited to an <acronym class="acronym">XML</acronym>-based
translation adapter. Or perhaps you'd like to speed things up even
more. Or perhaps you want to make l10n operations faster. How can
you do this?
</p>
<div class="section" id="performance.localization.cache.usage" name="performance.localization.cache.usage"><div class="info"><h1 class="title">Use translation and localization caches</h1></div>
<p class="para">
Both <span class="classname">Zend_Translate</span> and <span class="classname">Zend_Locale</span>
implement caching functionality that can greatly affect
performance. In the case of each, the major bottleneck is
typically reading the files, not the actual lookups; using a
cache eliminates the need to read the translation and/or
localization files.
</p>
<p class="para">
You can read about caching of translation and localization
strings in the following locations:
</p>
<ul class="itemizedlist">
<li class="listitem">
<p class="para">
<a href="" class="link"><span class="classname">Zend_Translate</span>
adapter caching</a>
</p>
</li>
<li class="listitem">
<p class="para">
<a href="" class="link"><span class="classname">Zend_Locale</span>
caching</a>
</p>
</li>
</ul>
</div>
</div>
</div>
<hr />
<table width="100%">
<tr>
<td width="25%" style="text-align: left;">
<a href="performance.database.html">Zend_Db Performance</a>
</td>
<td width="50%" style="text-align: center;">
<div class="up"><span class="up"><a href="performance.html">Zend Gdata Performance Guide</a></span><br />
<span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
</td>
<td width="25%" style="text-align: right;">
<div class="next" style="text-align: right; float: right;"><a href="performance.view.html">View Rendering</a></div>
</td>
</tr>
</table>
</td>
<td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
float: left;
width: 186px;
padding: 5px;
font-size: smaller;
}
ul.toc {
margin: 0px 5px 5px 5px;
padding: 0px;
}
ul.toc li {
font-size: 85%;
margin: 1px 0 1px 1px;
padding: 1px 0 1px 11px;
list-style-type: none;
background-repeat: no-repeat;
background-position: center left;
}
ul.toc li.header {
font-size: 115%;
padding: 5px 0px 5px 11px;
border-bottom: 1px solid #cccccc;
margin-bottom: 5px;
}
ul.toc li.active {
font-weight: bold;
}
ul.toc li a {
text-decoration: none;
}
ul.toc li a:hover {
text-decoration: underline;
}
</style>
<ul class="toc">
<li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
<li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
<li class="header up"><a href="performance.html">Zend Gdata Performance Guide</a></li>
<li><a href="performance.introduction.html">Introduction</a></li>
<li><a href="performance.classloading.html">Class Loading</a></li>
<li><a href="performance.database.html">Zend_Db Performance</a></li>
<li class="active"><a href="performance.localization.html">Internationalization (i18n) and Localization (l10n)</a></li>
<li><a href="performance.view.html">View Rendering</a></li>
</ul>
</td>
</tr>
</table>
</body>
</html>
|