Now that we know the basics of using Zend_Locale to help our international visitors feel at home, let??™s
have a look at Zend_Translate??™s ability to help us present our site in different languages.
14.2.2 Zend_Translate
As we have already seen, the basics of website translation is to take a every string and provide a translated
version. The most common way to do this is gettext(), which is powerful but fairly complicated.
Zend_Translate supports the gettext() format, but also supports other popular formats such as CSV, TBX, Qt
and Xliff. Zend_Translate is also thread-safe which can be very helpful if you are running a multi-threaded
webserver such as IIS.
Zend Translate supports multiple input formats using an adapter system. This approach is very common in
the Zend Framework and allows for easy additions of further adapters as required. We will look at the CSV
adapter first as that is a very simple format and hence very quick to use. Possibly the biggest benefit to CSV
input files is that it is easy for the client to provide such a file using a text editor or a spreadsheet program like
Excel. One downside is that support for UTF8 is quite patchy with text editors
Using Zend_Translate is simple enough. In Listing 14.4, we output some text using pretty ordinary PHP
and then repeat the exercise in Listing 14.
Pages:
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348