Zend_Locale-Migration.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 API 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 API.
  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.fromonesixtooneseven">
  69. <title>Migrating from 1.6 to 1.7 or newer</title>
  70. <sect3 id="zend.locale.migration.fromonesixtooneseven.islocale">
  71. <title>Changes when using isLocale()</title>
  72. <para>
  73. According to the coding standards isLocale() had to be changed to return
  74. a boolean. In previous releases a string was returned on success. For
  75. release 1.7 a compatibility mode has been added which allows to use the
  76. old behaviour of a returned string, but it triggers a user warning to
  77. mention you to change to the new behaviour. The rerouting which the old
  78. behaviour of isLocale() could have done is no longer neccessary as all
  79. I18N will now process a rerouting themself.
  80. </para>
  81. <para>
  82. To migrate your scripts to the new API, simply use the method as shown below.
  83. </para>
  84. <example id="zend.locale.migration.fromonesixtooneseven.example">
  85. <title>How to change isLocale() from 1.6 to 1.7</title>
  86. <programlisting language="php"><![CDATA[
  87. // Example for 1.6
  88. if ($locale = Zend_Locale::isLocale($locale)) {
  89. // do something
  90. }
  91. // Same example for 1.7
  92. // You should change the compatiblity mode to prevent user warnings
  93. // But you can do this in your bootstrap
  94. Zend_Locale::$compatibilityMode = false;
  95. if (Zend_Locale::isLocale($locale)) {
  96. }
  97. ]]></programlisting>
  98. <para>
  99. Note that you can use the second parameter to see if the locale is correct without
  100. processing a rerouting.
  101. </para>
  102. <programlisting language="php"><![CDATA[
  103. // Example for 1.6
  104. if ($locale = Zend_Locale::isLocale($locale, false)) {
  105. // do something
  106. }
  107. // Same example for 1.7
  108. // You should change the compatiblity mode to prevent user warnings
  109. // But you can do this in your bootstrap
  110. Zend_Locale::$compatibilityMode = false;
  111. if (Zend_Locale::isLocale($locale, false)) {
  112. if (Zend_Locale::isLocale($locale, true)) {
  113. // no locale at all
  114. }
  115. // original string is no locale but can be rerouted
  116. }
  117. ]]></programlisting>
  118. </example>
  119. </sect3>
  120. <sect3 id="zend.locale.migration.fromonesixtooneseven.getdefault">
  121. <title>Changes when using getDefault()</title>
  122. <para>
  123. The meaning of the getDefault() method has been change due to the fact that we
  124. integrated a framework locale which can be set with setDefault(). It does no
  125. longer return the locale chain but only the set framework locale.
  126. </para>
  127. <para>
  128. To migrate your scripts to the new API, simply use the method as shown below.
  129. </para>
  130. <example id="zend.locale.migration.fromonesixtooneseven.getdefault.example">
  131. <title>How to change getDefault() from 1.6 to 1.7</title>
  132. <programlisting language="php"><![CDATA[
  133. // Example for 1.6
  134. $locales = $locale->getDefault(Zend_Locale::BROWSER);
  135. // Same example for 1.7
  136. // You should change the compatiblity mode to prevent user warnings
  137. // But you can do this in your bootstrap
  138. Zend_Locale::$compatibilityMode = false;
  139. $locale = Zend_Locale::getOrder(Zend_Locale::BROWSER);
  140. ]]></programlisting>
  141. <para>
  142. Note that the second parameter of the old getDefault() implementation is not
  143. available anymore, but the returned values are the same.
  144. </para>
  145. </example>
  146. <note>
  147. <para>
  148. Per default the old behaviour is still active, but throws a user warning.
  149. When you have changed your code to the new behaviour you should also change
  150. the compatibility mode to false so that no warning is thrown anymore.
  151. </para>
  152. </note>
  153. </sect3>
  154. </sect2>
  155. </sect1>