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
|
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.translate.introduction">
<title>Introduction</title>
<para>
<classname>Zend_Translate</classname> is Zend Framework's solution for multilingual
applications.
</para>
<para>
In multilingual applications, the content must be translated into
several languages and display content depending on the user's language.
<acronym>PHP</acronym> offers already several ways to handle such problems, however
the <acronym>PHP</acronym> solution has some problems:
</para>
<itemizedlist>
<listitem>
<para>
<emphasis>Inconsistent <acronym>API</acronym>:</emphasis>
There is no single <acronym>API</acronym> for the different source formats.
The usage of gettext for example is very complicated.
</para>
</listitem>
<listitem>
<para>
<emphasis>PHP supports only gettext and native array:</emphasis>
<acronym>PHP</acronym> itself offers only support for array or gettext.
All other source formats have to be coded manually,
because there is no native support.
</para>
</listitem>
<listitem>
<para>
<emphasis>No detection of the default language:</emphasis>
The default language of the user cannot be detected without
deeper knowledge of the backgrounds for
the different web browsers.
</para>
</listitem>
<listitem>
<para>
<emphasis>Gettext is not thread-safe:</emphasis>
<acronym>PHP</acronym>'s gettext library is not thread safe, and it
should not be used in a multithreaded environment.
This is due to problems with gettext itself, not <acronym>PHP</acronym>,
but it is an existing problem.
</para>
</listitem>
</itemizedlist>
<para>
<classname>Zend_Translate</classname> does not have the above problems. This is why we
recommend using <classname>Zend_Translate</classname> instead of <acronym>PHP</acronym>'s
native functions. The benefits of <classname>Zend_Translate</classname> are:
</para>
<itemizedlist>
<listitem>
<para>
<emphasis>Supports multiple source formats:</emphasis>
<classname>Zend_Translate</classname> supports several source formats, including
those supported by <acronym>PHP</acronym>, and other formats including TMX
and CSV files.
</para>
</listitem>
<listitem>
<para>
<emphasis>Thread-safe gettext:</emphasis>
The gettext reader of <classname>Zend_Translate</classname> is thread-safe.
There are no problems using it in multi-threaded environments.
</para>
</listitem>
<listitem>
<para>
<emphasis>Easy and generic <acronym>API</acronym>:</emphasis>
The <acronym>API</acronym> of <classname>Zend_Translate</classname> is very simple
and requires only a handful of functions.
So it's easy to learn and easy to maintain.
All source formats are handled the same way, so if the format
of your source files change from Gettext to TMX,
you only need to change one line of code to specify the
storage adapter.
</para>
</listitem>
<listitem>
<para>
<emphasis>Detection of the user's standard language:</emphasis>
The preferred language of the user accessing the site can be
detected and used by <classname>Zend_Translate</classname>.
</para>
</listitem>
<listitem>
<para>
<emphasis>Automatic source detection:</emphasis>
<classname>Zend_Translate</classname> is capable of detecting and integrating
multiple source files and additionally detect the locale to be used depending on
directory or filenames.
</para>
</listitem>
</itemizedlist>
<sect2 id="zend.translate.introduction.adapters">
<title>Starting multi-lingual</title>
<para>
So let's get started with multi-lingual business.
What we want to do is translate our string
output so the view produces the translated output.
Otherwise we would have to write one view
for each language, and no one would like to do this.
Generally, multi-lingual sites are very simple in their design.
There are only four steps you would have to do:
</para>
<orderedlist numeration='arabic'>
<listitem>
<para>
Decide which adapter you want to use;
</para>
</listitem>
<listitem>
<para>
Create your view and integrate <classname>Zend_Translate</classname> in your
code;
</para>
</listitem>
<listitem>
<para>
Create the source file from your code;
</para>
</listitem>
<listitem>
<para>
Translate your source file to the desired language.
</para>
</listitem>
</orderedlist>
<para>
The following sections guide you through all four steps.
Read through the next few pages to create your own
multi-lingual web application.
</para>
</sect2>
</sect1>
<!--
vim:se ts=4 sw=4 et:
-->
|