Zend_Translate-Introduction.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.translate.introduction">
  4. <title>Introduction</title>
  5. <para>
  6. <classname>Zend_Translate</classname> is Zend Framework's solution for multilingual
  7. applications.
  8. </para>
  9. <para>
  10. In multilingual applications, the content must be translated into
  11. several languages and display content depending on the user's language.
  12. <acronym>PHP</acronym> offers already several ways to handle such problems, however
  13. the <acronym>PHP</acronym> solution has some problems:
  14. </para>
  15. <itemizedlist>
  16. <listitem>
  17. <para>
  18. <emphasis>Inconsistent <acronym>API</acronym>:</emphasis>
  19. There is no single <acronym>API</acronym> for the different source formats.
  20. The usage of gettext for example is very complicated.
  21. </para>
  22. </listitem>
  23. <listitem>
  24. <para>
  25. <emphasis>PHP supports only gettext and native array:</emphasis>
  26. <acronym>PHP</acronym> itself offers only support for array or gettext.
  27. All other source formats have to be coded manually,
  28. because there is no native support.
  29. </para>
  30. </listitem>
  31. <listitem>
  32. <para>
  33. <emphasis>No detection of the default language:</emphasis>
  34. The default language of the user cannot be detected without
  35. deeper knowledge of the backgrounds for
  36. the different web browsers.
  37. </para>
  38. </listitem>
  39. <listitem>
  40. <para>
  41. <emphasis>Gettext is not thread-safe:</emphasis>
  42. <acronym>PHP</acronym>'s gettext library is not thread safe, and it
  43. should not be used in a multithreaded environment.
  44. This is due to problems with gettext itself, not <acronym>PHP</acronym>,
  45. but it is an existing problem.
  46. </para>
  47. </listitem>
  48. </itemizedlist>
  49. <para>
  50. <classname>Zend_Translate</classname> does not have the above problems. This is why we
  51. recommend using <classname>Zend_Translate</classname> instead of <acronym>PHP</acronym>'s
  52. native functions. The benefits of <classname>Zend_Translate</classname> are:
  53. </para>
  54. <itemizedlist>
  55. <listitem>
  56. <para>
  57. <emphasis>Supports multiple source formats:</emphasis>
  58. <classname>Zend_Translate</classname> supports several source formats, including
  59. those supported by <acronym>PHP</acronym>, and other formats including TMX
  60. and CSV files.
  61. </para>
  62. </listitem>
  63. <listitem>
  64. <para>
  65. <emphasis>Thread-safe gettext:</emphasis>
  66. The gettext reader of <classname>Zend_Translate</classname> is thread-safe.
  67. There are no problems using it in multi-threaded environments.
  68. </para>
  69. </listitem>
  70. <listitem>
  71. <para>
  72. <emphasis>Easy and generic <acronym>API</acronym>:</emphasis>
  73. The <acronym>API</acronym> of <classname>Zend_Translate</classname> is very simple
  74. and requires only a handful of functions.
  75. So it's easy to learn and easy to maintain.
  76. All source formats are handled the same way, so if the format
  77. of your source files change from Gettext to TMX,
  78. you only need to change one line of code to specify the
  79. storage adapter.
  80. </para>
  81. </listitem>
  82. <listitem>
  83. <para>
  84. <emphasis>Detection of the user's standard language:</emphasis>
  85. The preferred language of the user accessing the site can be
  86. detected and used by <classname>Zend_Translate</classname>.
  87. </para>
  88. </listitem>
  89. <listitem>
  90. <para>
  91. <emphasis>Automatic source detection:</emphasis>
  92. <classname>Zend_Translate</classname> is capable of detecting and integrating
  93. multiple source files and additionally detect the locale to be used depending on
  94. directory or filenames.
  95. </para>
  96. </listitem>
  97. </itemizedlist>
  98. <sect2 id="zend.translate.introduction.adapters">
  99. <title>Starting multi-lingual</title>
  100. <para>
  101. So let's get started with multi-lingual business.
  102. What we want to do is translate our string
  103. output so the view produces the translated output.
  104. Otherwise we would have to write one view
  105. for each language, and no one would like to do this.
  106. Generally, multi-lingual sites are very simple in their design.
  107. There are only four steps you would have to do:
  108. </para>
  109. <orderedlist numeration='arabic'>
  110. <listitem>
  111. <para>
  112. Decide which adapter you want to use;
  113. </para>
  114. </listitem>
  115. <listitem>
  116. <para>
  117. Create your view and integrate <classname>Zend_Translate</classname> in your
  118. code;
  119. </para>
  120. </listitem>
  121. <listitem>
  122. <para>
  123. Create the source file from your code;
  124. </para>
  125. </listitem>
  126. <listitem>
  127. <para>
  128. Translate your source file to the desired language.
  129. </para>
  130. </listitem>
  131. </orderedlist>
  132. <para>
  133. The following sections guide you through all four steps.
  134. Read through the next few pages to create your own
  135. multi-lingual web application.
  136. </para>
  137. </sect2>
  138. </sect1>
  139. <!--
  140. vim:se ts=4 sw=4 et:
  141. -->