Zend_Locale-Migration.xml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.locale.migration">
  4. <title>Migrating from previous versions</title>
  5. <para>
  6. The <acronym>API</acronym> of <classname>Zend_Locale</classname> has changed from time to time.
  7. If you started to use <classname>Zend_Locale</classname> and its subcomponents
  8. in earlier versions follow the guidelines below to migrate your scripts to
  9. use the new <acronym>API</acronym>.
  10. </para>
  11. <sect2 id="zend.locale.migration.fromoneeighttoonenine">
  12. <title>Migrating from 1.8 to 1.9 or newer</title>
  13. <sect3 id="zend.locale.migration.fromoneeighttoonenine.depreciated">
  14. <title>Depreciated methods</title>
  15. <para>
  16. Some specialized translation methods have been depreciated because they duplicate
  17. existing behaviour. Note that the old methods will still work, but a user notice is
  18. triggered which describes the new call. The methods will be erased with 2.0.
  19. See the following list for old and new method call.
  20. </para>
  21. <table id="zend.locale.migration.fromoneeighttoonenine.depreciated.table-1">
  22. <title>List of measurement types</title>
  23. <tgroup cols="2">
  24. <thead>
  25. <row>
  26. <entry>Old call</entry>
  27. <entry>New call</entry>
  28. </row>
  29. </thead>
  30. <tbody>
  31. <row>
  32. <entry>getLanguageTranslationList($locale)</entry>
  33. <entry>getTranslationList('language', $locale)</entry>
  34. </row>
  35. <row>
  36. <entry>getScriptTranslationList($locale)</entry>
  37. <entry>getTranslationList('script', $locale)</entry>
  38. </row>
  39. <row>
  40. <entry>getCountryTranslationList($locale)</entry>
  41. <entry>getTranslationList('territory', $locale, 2)</entry>
  42. </row>
  43. <row>
  44. <entry>getTerritoryTranslationList($locale)</entry>
  45. <entry>getTranslationList('territory', $locale, 1)</entry>
  46. </row>
  47. <row>
  48. <entry>getLanguageTranslation($value, $locale)</entry>
  49. <entry>getTranslation($value, 'language', $locale)</entry>
  50. </row>
  51. <row>
  52. <entry>getScriptTranslation($value, $locale)</entry>
  53. <entry>getTranslation($value, 'script', $locale)</entry>
  54. </row>
  55. <row>
  56. <entry>getCountryTranslation($value, $locale)</entry>
  57. <entry>getTranslation($value, 'country', $locale)</entry>
  58. </row>
  59. <row>
  60. <entry>getTerritoryTranslation($value, $locale)</entry>
  61. <entry>getTranslation($value, 'territory', $locale)</entry>
  62. </row>
  63. </tbody>
  64. </tgroup>
  65. </table>
  66. </sect3>
  67. </sect2>
  68. <sect2 id="zend.locale.migration.fromoneseventooneeight">
  69. <title>Migrating from 1.7 to 1.8 or newer</title>
  70. <sect3 id="zend.locale.migration.fromoneseventooneeight.defaultcaching">
  71. <title>Default caching</title>
  72. <para>
  73. As with Zend Framework 1.8 a default caching was added. The reason behind this
  74. change was, that most users had performance problems but did not add caching at
  75. all. As the I18n core is a bottleneck when no caching is used we decided to add
  76. a default caching when no cache has been set to <classname>Zend_Locale</classname>.
  77. </para>
  78. <para>
  79. Sometimes it is still wanted to prevent caching at all even if this decreases
  80. performance. To do so you can simply disable caching by using the
  81. <methodname>disableCache()</methodname> method.
  82. </para>
  83. <example id="zend.locale.migration.fromoneseventooneeight.example">
  84. <title>Disabling default caching</title>
  85. <programlisting language="php"><![CDATA[
  86. Zend_Locale::disableCache(true);
  87. ]]></programlisting>
  88. </example>
  89. </sect3>
  90. </sect2>
  91. <sect2 id="zend.locale.migration.fromonesixtooneseven">
  92. <title>Migrating from 1.6 to 1.7 or newer</title>
  93. <sect3 id="zend.locale.migration.fromonesixtooneseven.islocale">
  94. <title>Changes when using isLocale()</title>
  95. <para>
  96. According to the coding standards isLocale() had to be changed to return
  97. a boolean. In previous releases a string was returned on success. For
  98. release 1.7 a compatibility mode has been added which allows to use the
  99. old behaviour of a returned string, but it triggers a user warning to
  100. mention you to change to the new behaviour. The rerouting which the old
  101. behaviour of isLocale() could have done is no longer neccessary as all
  102. I18N will now process a rerouting themself.
  103. </para>
  104. <para>
  105. To migrate your scripts to the new <acronym>API</acronym>, simply use the method as shown below.
  106. </para>
  107. <example id="zend.locale.migration.fromonesixtooneseven.example">
  108. <title>How to change isLocale() from 1.6 to 1.7</title>
  109. <programlisting language="php"><![CDATA[
  110. // Example for 1.6
  111. if ($locale = Zend_Locale::isLocale($locale)) {
  112. // do something
  113. }
  114. // Same example for 1.7
  115. // You should change the compatiblity mode to prevent user warnings
  116. // But you can do this in your bootstrap
  117. Zend_Locale::$compatibilityMode = false;
  118. if (Zend_Locale::isLocale($locale)) {
  119. }
  120. ]]></programlisting>
  121. <para>
  122. Note that you can use the second parameter to see if the locale is correct without
  123. processing a rerouting.
  124. </para>
  125. <programlisting language="php"><![CDATA[
  126. // Example for 1.6
  127. if ($locale = Zend_Locale::isLocale($locale, false)) {
  128. // do something
  129. }
  130. // Same example for 1.7
  131. // You should change the compatiblity mode to prevent user warnings
  132. // But you can do this in your bootstrap
  133. Zend_Locale::$compatibilityMode = false;
  134. if (Zend_Locale::isLocale($locale, false)) {
  135. if (Zend_Locale::isLocale($locale, true)) {
  136. // no locale at all
  137. }
  138. // original string is no locale but can be rerouted
  139. }
  140. ]]></programlisting>
  141. </example>
  142. </sect3>
  143. <sect3 id="zend.locale.migration.fromonesixtooneseven.getdefault">
  144. <title>Changes when using getDefault()</title>
  145. <para>
  146. The meaning of the getDefault() method has been change due to the fact that we
  147. integrated a framework locale which can be set with setDefault(). It does no
  148. longer return the locale chain but only the set framework locale.
  149. </para>
  150. <para>
  151. To migrate your scripts to the new <acronym>API</acronym>, simply use the method as shown below.
  152. </para>
  153. <example id="zend.locale.migration.fromonesixtooneseven.getdefault.example">
  154. <title>How to change getDefault() from 1.6 to 1.7</title>
  155. <programlisting language="php"><![CDATA[
  156. // Example for 1.6
  157. $locales = $locale->getDefault(Zend_Locale::BROWSER);
  158. // Same example for 1.7
  159. // You should change the compatiblity mode to prevent user warnings
  160. // But you can do this in your bootstrap
  161. Zend_Locale::$compatibilityMode = false;
  162. $locale = Zend_Locale::getOrder(Zend_Locale::BROWSER);
  163. ]]></programlisting>
  164. <para>
  165. Note that the second parameter of the old getDefault() implementation is not
  166. available anymore, but the returned values are the same.
  167. </para>
  168. </example>
  169. <note>
  170. <para>
  171. Per default the old behaviour is still active, but throws a user warning.
  172. When you have changed your code to the new behaviour you should also change
  173. the compatibility mode to false so that no warning is thrown anymore.
  174. </para>
  175. </note>
  176. </sect3>
  177. </sect2>
  178. </sect1>