| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <?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:
- -->
|