1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.translate.introduction">
4 <title>Introduction</title>
7 <classname>Zend_Translate</classname> is Zend Framework's solution for multilingual
12 In multilingual applications, the content must be translated into
13 several languages and display content depending on the user's language.
14 <acronym>PHP</acronym> offers already several ways to handle such problems, however
15 the <acronym>PHP</acronym> solution has some problems:
21 <emphasis>Inconsistent <acronym>API</acronym>:</emphasis>
22 There is no single <acronym>API</acronym> for the different source formats.
23 The usage of gettext for example is very complicated.
29 <emphasis>PHP supports only gettext and native array:</emphasis>
30 <acronym>PHP</acronym> itself offers only support for array or gettext.
31 All other source formats have to be coded manually,
32 because there is no native support.
38 <emphasis>No detection of the default language:</emphasis>
39 The default language of the user cannot be detected without
40 deeper knowledge of the backgrounds for
41 the different web browsers.
47 <emphasis>Gettext is not thread-safe:</emphasis>
48 <acronym>PHP</acronym>'s gettext library is not thread safe, and it
49 should not be used in a multithreaded environment.
50 This is due to problems with gettext itself, not <acronym>PHP</acronym>,
51 but it is an existing problem.
57 <classname>Zend_Translate</classname> does not have the above problems. This is why we
58 recommend using <classname>Zend_Translate</classname> instead of <acronym>PHP</acronym>'s
59 native functions. The benefits of <classname>Zend_Translate</classname> are:
65 <emphasis>Supports multiple source formats:</emphasis>
66 <classname>Zend_Translate</classname> supports several source formats, including
67 those supported by <acronym>PHP</acronym>, and other formats including TMX
74 <emphasis>Thread-safe gettext:</emphasis>
75 The gettext reader of <classname>Zend_Translate</classname> is thread-safe.
76 There are no problems using it in multi-threaded environments.
82 <emphasis>Easy and generic <acronym>API</acronym>:</emphasis>
83 The <acronym>API</acronym> of <classname>Zend_Translate</classname> is very simple
84 and requires only a handful of functions.
85 So it's easy to learn and easy to maintain.
86 All source formats are handled the same way, so if the format
87 of your source files change from Gettext to TMX,
88 you only need to change one line of code to specify the
95 <emphasis>Detection of the user's standard language:</emphasis>
96 The preferred language of the user accessing the site can be
97 detected and used by <classname>Zend_Translate</classname>.
103 <emphasis>Automatic source detection:</emphasis>
104 <classname>Zend_Translate</classname> is capable of detecting and integrating
105 multiple source files and additionally detect the locale to be used depending on
106 directory or filenames.
111 <sect2 id="zend.translate.introduction.adapters">
112 <title>Starting multi-lingual</title>
115 So let's get started with multi-lingual business.
116 What we want to do is translate our string
117 output so the view produces the translated output.
118 Otherwise we would have to write one view
119 for each language, and no one would like to do this.
120 Generally, multi-lingual sites are very simple in their design.
121 There are only four steps you would have to do:
124 <orderedlist numeration='arabic'>
127 Decide which adapter you want to use;
133 Create your view and integrate <classname>Zend_Translate</classname> in your
140 Create the source file from your code;
146 Translate your source file to the desired language.
152 The following sections guide you through all four steps.
153 Read through the next few pages to create your own
154 multi-lingual web application.