Zend_Locale-Functions.xml 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.locale.functions">
  4. <title>Using Zend_Locale</title>
  5. <para>
  6. <classname>Zend_Locale</classname> also provides localized information about locales for each locale,
  7. including localized names for other locales, days of the week, month names, etc.
  8. </para>
  9. <sect2 id="zend.locale.copying">
  10. <title>Copying, Cloning, and Serializing Locale Objects</title>
  11. <para>
  12. Use
  13. <ulink url="http://php.net/language.oop5.cloning">object cloning</ulink>
  14. to duplicate a locale object exactly and efficiently. Most locale-aware methods also accept string
  15. representations of locales, such as the result of <code>$locale->toString()</code>.
  16. </para>
  17. <example id="zend.locale.copying.example-1">
  18. <title>clone</title>
  19. <programlisting language="php"><![CDATA[
  20. $locale = new Zend_Locale('ar');
  21. // Save the $locale object as a serialization
  22. $serializedLocale = $locale->serialize();
  23. // re-create the original object
  24. $localeObject = unserialize($serializedLocale);
  25. // Obtain a string identification of the locale
  26. $stringLocale = $locale->toString();
  27. // Make a cloned copy of the $local object
  28. $copiedLocale = clone $locale;
  29. print "copied: ", $copiedLocale->toString();
  30. // PHP automatically calls toString() via __toString()
  31. print "copied: ", $copiedLocale;
  32. ]]></programlisting>
  33. </example>
  34. </sect2>
  35. <sect2 id="zend.locale.equals">
  36. <title>Equality</title>
  37. <para>
  38. <classname>Zend_Locale</classname> also provides a convenience function to compare two locales. All locale-aware
  39. classes should provide a similar equality check.
  40. </para>
  41. <example id="zend.locale.equals.example-1">
  42. <title>Check for equal locales</title>
  43. <programlisting language="php"><![CDATA[
  44. $locale = new Zend_Locale();
  45. $mylocale = new Zend_Locale('en_US');
  46. // Check if locales are equal
  47. if ($locale->equals($mylocale)) {
  48. print "Locales are equal";
  49. }
  50. ]]></programlisting>
  51. </example>
  52. </sect2>
  53. <sect2 id="zend.locale.getdefault">
  54. <title>Default locales</title>
  55. <para>
  56. The method <methodname>getDefault()</methodname> returns an array of relevant locales using
  57. information from the user's web browser (if available), information from the
  58. environment of the host server, and Zend Framework settings. As with the constructor
  59. for <classname>Zend_Locale</classname>, the first parameter selects a preference of
  60. which information to consider <link
  61. linkend="zend.locale.selection">(<constant>BROWSER</constant>, <constant>ENVIRONMENT</constant>, or
  62. <code>FRAMEWORK)</code></link> first. The second parameter toggles between
  63. returning all matching locales or only the first/best match. Locale-aware components
  64. normally use only the first locale. A quality rating is included, when available.
  65. </para>
  66. <example id="zend.locale.getdefault.example-1">
  67. <title>Get default locales</title>
  68. <programlisting language="php"><![CDATA[
  69. $locale = new Zend_Locale();
  70. // Return all default locales
  71. $found = $locale->getDefault();
  72. print_r($found);
  73. // Return only browser locales
  74. $found2 = $locale->getDefault(Zend_Locale::BROWSER,TRUE);
  75. print_r($found2);
  76. ]]></programlisting>
  77. </example>
  78. <para>
  79. To obtain only the default locales relevant to the
  80. <link linkend="zend.locale.selection"><constant>BROWSER</constant>, <constant>ENVIRONMENT</constant>, or <constant>FRAMEWORK</constant>
  81. </link>
  82. , use the corresponding method:
  83. <itemizedlist>
  84. <listitem>
  85. <para>
  86. <methodname>getEnvironment()</methodname>
  87. </para>
  88. </listitem>
  89. <listitem>
  90. <para>
  91. <methodname>getBrowser()</methodname>
  92. </para>
  93. </listitem>
  94. <listitem>
  95. <para>
  96. <methodname>getLocale()</methodname>
  97. </para>
  98. </listitem>
  99. </itemizedlist>
  100. </para>
  101. </sect2>
  102. <sect2 id="zend.locale.setlocale">
  103. <title>Set a new locale</title>
  104. <para>
  105. A new locale can be set with the function <methodname>setLocale()</methodname>. This function takes a locale string as
  106. parameter. If no locale is given, a locale is
  107. <link linkend="zend.locale.selection">automatically selected</link>.
  108. Since <classname>Zend_Locale</classname> objects are "light", this method exists primarily to cause side-effects for code that
  109. have references to the existing instance object.
  110. </para>
  111. <example id="zend.locale.setlocale.example-1">
  112. <title>setLocale</title>
  113. <programlisting language="php"><![CDATA[
  114. $locale = new Zend_Locale();
  115. // Actual locale
  116. print $locale->toString();
  117. // new locale
  118. $locale->setLocale('aa_DJ');
  119. print $locale->toString();
  120. ]]></programlisting>
  121. </example>
  122. </sect2>
  123. <sect2 id="zend.locale.getlocale">
  124. <title>Getting the language and region</title>
  125. <para>
  126. Use <methodname>getLanguage()</methodname> to obtain a string containing the two character language code from the string
  127. locale identifier. Use <methodname>getRegion()</methodname> to obtain a string containing the two character region code
  128. from the string locale identifier.
  129. </para>
  130. <example id="zend.locale.getlocale.example-1">
  131. <title>getLanguage and getRegion</title>
  132. <programlisting language="php"><![CDATA[
  133. $locale = new Zend_Locale();
  134. // if locale is 'de_AT' then 'de' will be returned as language
  135. print $locale->getLanguage();
  136. // if locale is 'de_AT' then 'AT' will be returned as region
  137. print $locale->getRegion();
  138. ]]></programlisting>
  139. </example>
  140. </sect2>
  141. <sect2 id="zend.locale.getdata">
  142. <title>Obtaining localized strings</title>
  143. <para>
  144. <methodname>getTranslationList()</methodname> gives you access to localized informations of several types. These
  145. information are useful if you want to display localized data to a customer without the need
  146. of translating it. They are already available for your usage.
  147. </para>
  148. <para>
  149. The requested list of information is always returned as named array. If you want to give more than
  150. one value to a explicit type where you wish to receive values from, you have to give an array
  151. instead of multiple values.
  152. </para>
  153. <example id="zend.locale.getdata.example-1">
  154. <title>getTranslationList</title>
  155. <programlisting language="php"><![CDATA[
  156. $list = Zend_Locale::getTranslationList('language', 'de_AT');
  157. print_r ($list);
  158. // example key -> value pairs...
  159. // [de] -> Deutsch
  160. // [en] -> Englisch
  161. // use one of the returned key as value for the getTranslation() method
  162. // of another language
  163. print Zend_Locale::getTranslation('de', 'language', 'zh');
  164. // returns the translation for the language 'de' in chinese
  165. ]]></programlisting>
  166. </example>
  167. <para>
  168. You can receive this informations for all languages. But not all of the informations are completely
  169. available for all languages. Some of these types are also available through an own function for
  170. simplicity. See this list for detailed informations.
  171. </para>
  172. <table id="zend.locale.getdata.table-1">
  173. <title>Details for getTranslationList($type = null, $locale = null, $value = null)</title>
  174. <tgroup cols="2">
  175. <thead>
  176. <row>
  177. <entry>Type</entry>
  178. <entry>Description</entry>
  179. </row>
  180. </thead>
  181. <tbody>
  182. <row>
  183. <entry><emphasis>Language</emphasis></entry>
  184. <entry>Returns a localized list of all languages. The language part of the locale
  185. is returned as key and the translation as value</entry>
  186. </row>
  187. <row>
  188. <entry><emphasis>Script</emphasis></entry>
  189. <entry>Returns a localized list of all scripts. The script is returned as key and the
  190. translation as value</entry>
  191. </row>
  192. <row>
  193. <entry><emphasis>Territory</emphasis></entry>
  194. <entry>Returns a localized list of all territories. This contains countries,
  195. continents and territories. To get only territories and continents
  196. use '1' as value. To get only countries use '2' as value. The country part of
  197. the locale is used as key where applicable. In the other case the official <acronym>ISO</acronym>
  198. code for this territory is used. The translated territory is returned as value.
  199. When you omit the value you will get a list with both.</entry>
  200. </row>
  201. <row>
  202. <entry><emphasis>Variant</emphasis></entry>
  203. <entry>Returns a localized list of known variants of scripts. The variant is
  204. returned as key and the translation as value</entry>
  205. </row>
  206. <row>
  207. <entry><emphasis>Key</emphasis></entry>
  208. <entry>Returns a localized list of known keys. This keys are generic values used
  209. in translation. These are normally calendar, collation and currency. The key
  210. is returned as array key and the translation as value</entry>
  211. </row>
  212. <row>
  213. <entry><emphasis>Type</emphasis></entry>
  214. <entry>Returns a localized list of known types of keys. These are variants of types
  215. of calendar representations and types of collations. When you use 'collation' as
  216. value you will get all types of collations returned. When you use 'calendar' as
  217. value you will get all types of calendars returned. When you omit the value you
  218. will get a list all both returned. The type is used as key and the translation as
  219. value</entry>
  220. </row>
  221. <row>
  222. <entry><emphasis>Layout</emphasis></entry>
  223. <entry>Returns a list of rules which describes how to format special text parts</entry>
  224. </row>
  225. <row>
  226. <entry><emphasis>Characters</emphasis></entry>
  227. <entry>Returns a list of allowed characters within this locale</entry>
  228. </row>
  229. <row>
  230. <entry><emphasis>Delimiters</emphasis></entry>
  231. <entry>Returns a list of allowed quoting characters for this locale</entry>
  232. </row>
  233. <row>
  234. <entry><emphasis>Measurement</emphasis></entry>
  235. <entry>Returns a list of known measurement values. This list is depreciated</entry>
  236. </row>
  237. <row>
  238. <entry><emphasis>Months</emphasis></entry>
  239. <entry>Returns a list of all month representations within this locale. There are
  240. several different representations which are all returned as sub array. If you omit
  241. the value you will get a list of all months from the 'gregorian' calendar returned.
  242. You can give any known calendar as value to get a list of months from this calendar
  243. returned. Use <link linkend="zend.date.introduction">Zend_Date</link> for
  244. simplicity</entry>
  245. </row>
  246. <row>
  247. <entry><emphasis>Month</emphasis></entry>
  248. <entry>Returns a localized list of all month names for this locale. If you omit the
  249. value you will get the normally used gregorian full name of the months where each
  250. month number is used as key and the translated month is returned as value. You
  251. can get the months for different calendars and formats if you give an array as value.
  252. The first array entry has to be the calendar, the second the used context and the
  253. third the width to return. Use <link linkend="zend.date.introduction">Zend_Date</link>
  254. for simplicity</entry>
  255. </row>
  256. <row>
  257. <entry><emphasis>Days</emphasis></entry>
  258. <entry>Returns a list of all day representations within this locale. There are
  259. several different representations which are all returned as sub array. If you omit
  260. the value you will get a list of all days from the 'gregorian' calendar returned.
  261. You can give any known calendar as value to get a list of days from this calendar
  262. returned. Use <link linkend="zend.date.introduction">Zend_Date</link> for
  263. simplicity</entry>
  264. </row>
  265. <row>
  266. <entry><emphasis>Day</emphasis></entry>
  267. <entry>Returns a localized list of all day names for this locale. If you omit the
  268. value you will get the normally used gregorian full name of the days where the
  269. english day abbreviation is used as key and the translated day is returned as
  270. value. You can get the days for different calendars and formats if you give an
  271. array as value. The first array entry has to be the calendar, the second the used
  272. context and the third the width to return. Use
  273. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  274. </row>
  275. <row>
  276. <entry><emphasis>Week</emphasis></entry>
  277. <entry>Returns a list of values used for proper week calculations within a locale.
  278. Use <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  279. </row>
  280. <row>
  281. <entry><emphasis>Quarters</emphasis></entry>
  282. <entry>Returns a list of all quarter representations within this locale. There are
  283. several different representations which are all returned as sub array. If you omit
  284. the value you will get a list of all quarters from the 'gregorian' calendar returned.
  285. You can give any known calendar as value to get a list of quarters from this calendar
  286. returned</entry>
  287. </row>
  288. <row>
  289. <entry><emphasis>Quarter</emphasis></entry>
  290. <entry>Returns a localized list of all quarter names for this locale. If you omit the
  291. value you will get the normally used gregorian full name of the quarters where each
  292. quarter number is used as key and the translated quarter is returned as value. You
  293. can get the quarters for different calendars and formats if you give an array as
  294. value. The first array entry has to be the calendar, the second the used context
  295. and the third the width to return</entry>
  296. </row>
  297. <row>
  298. <entry><emphasis>Eras</emphasis></entry>
  299. <entry>Returns a list of all era representations within this locale. If you omit
  300. the value you will get a list of all eras from the 'gregorian' calendar returned.
  301. You can give any known calendar as value to get a list of eras from this calendar
  302. returned</entry>
  303. </row>
  304. <row>
  305. <entry><emphasis>Era</emphasis></entry>
  306. <entry>Returns a localized list of all era names for this locale. If you omit the
  307. value you will get the normally used gregorian full name of the eras where each
  308. era number is used as key and the translated era is returned as value. You
  309. can get the eras for different calendars and formats if you give an array as
  310. value. The first array entry has to be the calendar and the second the width to
  311. return</entry>
  312. </row>
  313. <row>
  314. <entry><emphasis>Date</emphasis></entry>
  315. <entry>Returns a localized list of all date formats for this locale. The name of the
  316. dateformat is used as key and the format itself as value.If you omit the value you
  317. will get the date formats for the gregorian calendar returned. You can get the
  318. date formats for different calendars if you give the wished calendar as string.
  319. Use <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  320. </row>
  321. <row>
  322. <entry><emphasis>Time</emphasis></entry>
  323. <entry>Returns a localized list of all time formats for this locale. The name of the
  324. timeformat is used as key and the format itself as value. If you omit the value you
  325. will get the time formats for the gregorian calendar returned. You can get the
  326. time formats for different calendars if you give the wished calendar as string.
  327. Use <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  328. </row>
  329. <row>
  330. <entry><emphasis>DateTime</emphasis></entry>
  331. <entry>Returns a localized list of all known date-time formats for this locale. The name
  332. of the date-time format is used as key and the format itself as value. If you
  333. omit the value you will get the date-time formats for the gregorian calendar returned.
  334. You can get the date-time formats for different calendars if you give the wished
  335. calendar as string. Use <link linkend="zend.date.introduction">Zend_Date</link>
  336. for simplicity</entry>
  337. </row>
  338. <row>
  339. <entry><emphasis>DateItem</emphasis></entry>
  340. <entry>Returns a list of default formats for given date or time items</entry>
  341. </row>
  342. <row>
  343. <entry><emphasis>DateInterval</emphasis></entry>
  344. <entry>
  345. Returns a list of date or time formats which are used when you want to
  346. display intervals. The list is a multidimentional array where the first
  347. dimension is the interval format, and the second dimension is the token
  348. with the greatest difference.
  349. </entry>
  350. </row>
  351. <row>
  352. <entry><emphasis>Field</emphasis></entry>
  353. <entry>Returns a localized list of date fields which can be used to display calendars
  354. or date strings like 'month' or 'year' in a wished language. If you omit the value
  355. you will get this list for the gregorian calendar returned. You can get the
  356. list for different calendars if you give the wished calendar as string</entry>
  357. </row>
  358. <row>
  359. <entry><emphasis>Relative</emphasis></entry>
  360. <entry>Returns a localized list of relative dates which can be used to display
  361. textual relative dates like 'yesterday' or 'tomorrow' in a wished language.
  362. If you omit the value you will get this list for the gregorian calendar
  363. returned. You can get the list for different calendars if you give the wished
  364. calendar as string</entry>
  365. </row>
  366. <row>
  367. <entry><emphasis>Symbols</emphasis></entry>
  368. <entry>Returns a localized list of characters used for number representations</entry>
  369. </row>
  370. <row>
  371. <entry><emphasis>NameToCurrency</emphasis></entry>
  372. <entry>Returns a localized list of names for currencies. The currency is used as key
  373. and the translated name as value. Use
  374. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  375. </row>
  376. <row>
  377. <entry><emphasis>CurrencyToName</emphasis></entry>
  378. <entry>Returns a list of currencies for localized names. The translated name is used
  379. as key and the currency as value. Use
  380. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  381. </row>
  382. <row>
  383. <entry><emphasis>CurrencySymbol</emphasis></entry>
  384. <entry>Returns a list of known localized currency symbols for currencies. The
  385. currency is used as key and the symbol as value. Use
  386. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  387. </row>
  388. <row>
  389. <entry><emphasis>Question</emphasis></entry>
  390. <entry>Returns a list of localized strings for acceptance ('yes') and
  391. negotation ('no'). Use
  392. <link linkend="zend.locale.getquestion">Zend_Locale's getQuestion method</link>
  393. for simplicity</entry>
  394. </row>
  395. <row>
  396. <entry><emphasis>CurrencyFraction</emphasis></entry>
  397. <entry>Returns a list of fractions for currency values. The currency is used as key and
  398. the fraction as integer value. Use
  399. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  400. </row>
  401. <row>
  402. <entry><emphasis>CurrencyRounding</emphasis></entry>
  403. <entry>Returns a list of how to round which currency. The currency is used as key and
  404. the rounding as integer value. Use
  405. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  406. </row>
  407. <row>
  408. <entry><emphasis>CurrencyToRegion</emphasis></entry>
  409. <entry>Returns a list of currencies which are known to be used within a region.
  410. The <constant>ISO3166</constant> value ('region') is used as array key and the <constant>ISO4217</constant> value
  411. ('currency') as array value. Use
  412. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  413. </row>
  414. <row>
  415. <entry><emphasis>RegionToCurrency</emphasis></entry>
  416. <entry>Returns a list of regions where a currency is used . The <constant>ISO4217</constant> value ('currency')
  417. is used as array key and the <constant>ISO3166</constant> value ('region') as array value. When a currency
  418. is used in several regions these regions are separated with a whitespace. Use
  419. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  420. </row>
  421. <row>
  422. <entry><emphasis>RegionToTerritory</emphasis></entry>
  423. <entry>Returns a list of territories with the countries or sub territories which are
  424. included within that territory. The <acronym>ISO</acronym> territory code ('territory') is used as
  425. array key and the <constant>ISO3166</constant> value ('region') as array value. When a territory contains
  426. several regions these regions are separated with a whitespace</entry>
  427. </row>
  428. <row>
  429. <entry><emphasis>TerritoryToRegion</emphasis></entry>
  430. <entry>Returns a list of regions and the territories where these regions are located.
  431. The <constant>ISO3166</constant> code ('region') is used as array key and the <acronym>ISO</acronym> territory code
  432. ('territory') as array value. When a region is located in several territories
  433. these territories are separated with a whitespace</entry>
  434. </row>
  435. <row>
  436. <entry><emphasis>ScriptToLanguage</emphasis></entry>
  437. <entry>Returns a list of scripts which are used within a language. The language code
  438. is used as array key and the script code as array value. When a language contains
  439. several scripts these scripts are separated with a whitespace</entry>
  440. </row>
  441. <row>
  442. <entry><emphasis>LanguageToScript</emphasis></entry>
  443. <entry>Returns a list of languages which are using a script. The script code
  444. is used as array key and the language code as array value. When a script is used
  445. in several languages these languages are separated with a whitespace</entry>
  446. </row>
  447. <row>
  448. <entry><emphasis>TerritoryToLanguage</emphasis></entry>
  449. <entry>Returns a list of countries which are using a language. The country code
  450. is used as array key and the language code as array value. When a language is used in
  451. several countries these countries are separated with a whitespace</entry>
  452. </row>
  453. <row>
  454. <entry><emphasis>LanguageToTerritory</emphasis></entry>
  455. <entry>Returns a list of countries and the languages spoken within these countries.
  456. The country code is used as array key and the language code as array value. When
  457. a territory is using several languages these languages are separated with a
  458. whitespace</entry>
  459. </row>
  460. <row>
  461. <entry><emphasis>TimezoneToWindows</emphasis></entry>
  462. <entry>Returns a list of windows timezones and the related <acronym>ISO</acronym> timezone. The windows
  463. timezone is used as array key and the <acronym>ISO</acronym> timezone as array value</entry>
  464. </row>
  465. <row>
  466. <entry><emphasis>WindowsToTimezone</emphasis></entry>
  467. <entry>Returns a list of <acronym>ISO</acronym> timezones and the related windows timezone. The <acronym>ISO</acronym>
  468. timezone is used as array key and the windows timezone as array value</entry>
  469. </row>
  470. <row>
  471. <entry><emphasis>TerritoryToTimezone</emphasis></entry>
  472. <entry>Returns a list of regions or territories and the related <acronym>ISO</acronym> timezone. The
  473. <acronym>ISO</acronym> timezone is used as array key and the territory code as array value</entry>
  474. </row>
  475. <row>
  476. <entry><emphasis>TimezoneToTerritory</emphasis></entry>
  477. <entry>Returns a list of timezones and the related region or territory code. The
  478. region or territory code is used as array key and the <acronym>ISO</acronym> timezone as array
  479. value</entry>
  480. </row>
  481. <row>
  482. <entry><emphasis>CityToTimezone</emphasis></entry>
  483. <entry>Returns a localized list of cities which can be used as translation for a
  484. related timezone. Not for all timezones is a translation available, but for a
  485. user is the real city written in his languages more accurate than the <acronym>ISO</acronym> name
  486. of this timezone. The <acronym>ISO</acronym> timezone is used as array key and the translated
  487. city as array value</entry>
  488. </row>
  489. <row>
  490. <entry><emphasis>TimezoneToCity</emphasis></entry>
  491. <entry>Returns a list of timezones for localized city names. The localized city is
  492. used as array key and the <acronym>ISO</acronym> timezone name as array value</entry>
  493. </row>
  494. <row>
  495. <entry><emphasis>PhoneToTerritory</emphasis></entry>
  496. <entry>Returns a list of phone codes which are known to be used within a territory.
  497. The territory (region) is used as array key and the telephone code
  498. as array value</entry>
  499. </row>
  500. <row>
  501. <entry><emphasis>TerritoryToPhone</emphasis></entry>
  502. <entry>Returns a list of territories where a phone is used . The phone code
  503. is used as array key and the territory (region) as array value. When a
  504. phone code is used in several territories these territories are separated with a
  505. whitespace</entry>
  506. </row>
  507. <row>
  508. <entry><emphasis>NumericToTerritory</emphasis></entry>
  509. <entry>Returns a list of 3 digit number codes for territories.
  510. The territory (region) is used as array key and the 3 digit number code
  511. as array value</entry>
  512. </row>
  513. <row>
  514. <entry><emphasis>TerritoryToNumeric</emphasis></entry>
  515. <entry>Returns a list of territories with their 3 digit number code. The 3 digit
  516. number code is used as array key and the territory (region) as array value
  517. </entry>
  518. </row>
  519. <row>
  520. <entry><emphasis>Alpha3ToTerritory</emphasis></entry>
  521. <entry>Returns a list of 3 sign character codes for territories.
  522. The territory (region) is used as array key and the 3 sign character code
  523. as array value</entry>
  524. </row>
  525. <row>
  526. <entry><emphasis>TerritoryToAlpha3</emphasis></entry>
  527. <entry>Returns a list of territories with their 3 sign character code. The 3 sign
  528. character code is used as array key and the territory (region) as array value
  529. </entry>
  530. </row>
  531. <row>
  532. <entry><emphasis>PostalToTerritory</emphasis></entry>
  533. <entry>Returns a list of territories with a regex for postal codes which are
  534. included within that territory. The <acronym>ISO</acronym> territory code ('territory') is used as
  535. array key and the regex as array value.</entry>
  536. </row>
  537. <row>
  538. <entry><emphasis>NumberingSystem</emphasis></entry>
  539. <entry>
  540. Returns a list of scripts with the notation for digits used within the
  541. script
  542. </entry>
  543. </row>
  544. <row>
  545. <entry><emphasis>FallbackToChar</emphasis></entry>
  546. <entry>
  547. Returns a list of replacement characters for often used unicode characters.
  548. This can be used to replace "©" with "(C)" for example
  549. </entry>
  550. </row>
  551. <row>
  552. <entry><emphasis>CharToFallback</emphasis></entry>
  553. <entry>
  554. Returns a list of unicode characters for often used replacement characters.
  555. This can be used to replace "(C)" with "©" for example
  556. </entry>
  557. </row>
  558. <row>
  559. <entry><emphasis>LocaleUpgrade</emphasis></entry>
  560. <entry>
  561. Returns a list of locale dependencies which can be used to upgrade a
  562. language to a full qualified locale
  563. </entry>
  564. </row>
  565. <row>
  566. <entry><emphasis>Unit</emphasis></entry>
  567. <entry>
  568. Returns a list of localized calendar units. This can be used to translate
  569. the strings "day", "month" and so on automatically
  570. </entry>
  571. </row>
  572. </tbody>
  573. </tgroup>
  574. </table>
  575. <para>
  576. If you are in need of a single translated value, you can use the <methodname>getTranslation()</methodname>
  577. method. It returns always a string but it accepts some different types than the
  578. <methodname>getTranslationList()</methodname> method. Also value is the same as before with one difference.
  579. You have to give the detail you want to get returned as additional value.
  580. </para>
  581. <note>
  582. <para>
  583. Because you have almost always give a value as detail this parameter has to be given
  584. as first parameter. This differs from the <methodname>getTranslationList()</methodname> method.
  585. </para>
  586. </note>
  587. <para>
  588. See the following table for detailed information:
  589. </para>
  590. <table id="zend.locale.getdata.table-2">
  591. <title>Details for getTranslation($value = null, $type = null, $locale = null)</title>
  592. <tgroup cols="2">
  593. <thead>
  594. <row>
  595. <entry>Type</entry>
  596. <entry>Description</entry>
  597. </row>
  598. </thead>
  599. <tbody>
  600. <row>
  601. <entry><emphasis>Language</emphasis></entry>
  602. <entry>Returns a translation for a language. To select the wished translation
  603. you must give the language code as value</entry>
  604. </row>
  605. <row>
  606. <entry><emphasis>Script</emphasis></entry>
  607. <entry>Returns a translation for a script. To select the wished translation you
  608. must give the script code as value</entry>
  609. </row>
  610. <row>
  611. <entry><emphasis>Territory</emphasis> or
  612. <emphasis>Country</emphasis></entry>
  613. <entry>Returns a translation for a territory. This can be countries, continents
  614. and territories. To select the wished variant you must give the territory
  615. code as value</entry>
  616. </row>
  617. <row>
  618. <entry><emphasis>Variant</emphasis></entry>
  619. <entry>Returns a translation for a script variant. To select the wished variant
  620. you must give the variant code as value</entry>
  621. </row>
  622. <row>
  623. <entry><emphasis>Key</emphasis></entry>
  624. <entry>Returns translation for a known keys. This keys are generic values used
  625. in translation. These are normally calendar, collation and currency. To
  626. select the wished key you must give the key code as value</entry>
  627. </row>
  628. <row>
  629. <entry><emphasis>DefaultCalendar</emphasis></entry>
  630. <entry>Returns the default calendar for the given locale. For most locales this
  631. will be 'gregorian'. Use
  632. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  633. </row>
  634. <row>
  635. <entry><emphasis>MonthContext</emphasis></entry>
  636. <entry>Returns the default context for months which is used within the given
  637. calendar. If you omit the value the 'gregorian' calendar will be used. Use
  638. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  639. </row>
  640. <row>
  641. <entry><emphasis>DefaultMonth</emphasis></entry>
  642. <entry>Returns the default format for months which is used within the given
  643. calendar. If you omit the value the 'gregorian' calendar will be used. Use
  644. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  645. </row>
  646. <row>
  647. <entry><emphasis>Month</emphasis></entry>
  648. <entry>Returns a translation for a month. You have to give the number of the month
  649. as integer value. It has to be between 1 and 12. If you want to receive data for
  650. other calendars, contexts or formats, then you must give an array instead of an
  651. integer with the expected values. The array has to look like this: <code>array(
  652. 'calendar', 'context', 'format', 'month number')</code>. If you give only an
  653. integer then the default values are the 'gregorian' calendar, the context
  654. 'format' and the format 'wide'. Use
  655. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  656. </row>
  657. <row>
  658. <entry><emphasis>DayContext</emphasis></entry>
  659. <entry>Returns the default context for ´days which is used within the given
  660. calendar. If you omit the value the 'gregorian' calendar will be used. Use
  661. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  662. </row>
  663. <row>
  664. <entry><emphasis>DefaultDay</emphasis></entry>
  665. <entry>Returns the default format for days which is used within the given
  666. calendar. If you omit the value the 'gregorian' calendar will be used. Use
  667. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  668. </row>
  669. <row>
  670. <entry><emphasis>Day</emphasis></entry>
  671. <entry>Returns a translation for a day. You have to give the english abbreviation
  672. of the day as string value ('sun', 'mon', etc.). If you want to receive data
  673. for other calendars, contexts or format, then you must give an array instead of
  674. an integer with the expected values. The array has to look like this:
  675. <methodname>array('calendar', 'context', 'format', 'day abbreviation')</methodname>. If you
  676. give only an string then the default values are the 'gregorian' calendar,
  677. the context 'format' and the format 'wide'. Use
  678. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  679. </row>
  680. <row>
  681. <entry><emphasis>Quarter</emphasis></entry>
  682. <entry>Returns a translation for a quarter. You have to give the number of the
  683. quarter as integer and it has to be between 1 and 4. If you want to receive
  684. data for other calendars, contexts or formats, then you must give an array
  685. instead of an integer with the expected values. The array has to look like this:
  686. <methodname>array('calendar', 'context', 'format', 'quarter number')</methodname>. If you
  687. give only an string then the default values are the 'gregorian' calendar,
  688. the context 'format' and the format 'wide'</entry>
  689. </row>
  690. <row>
  691. <entry><emphasis>Am</emphasis></entry>
  692. <entry>Returns a translation for 'AM' in a expected locale. If you want to receive
  693. data for other calendars an string with the expected calendar. If you omit the
  694. value then the 'gregorian' calendar will be used. Use
  695. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  696. </row>
  697. <row>
  698. <entry><emphasis>Pm</emphasis></entry>
  699. <entry>Returns a translation for 'PM' in a expected locale. If you want to receive
  700. data for other calendars an string with the expected calendar. If you omit the
  701. value then the 'gregorian' calendar will be used. Use
  702. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  703. </row>
  704. <row>
  705. <entry><emphasis>Era</emphasis></entry>
  706. <entry>Returns a translation for an era within a locale. You have to give the era
  707. number as string or integer. If you want to receive data for other calendars or
  708. formats, then you must give an array instead of the era number with the expected
  709. values. The array has to look like this:
  710. <methodname>array('calendar', 'format', 'era number')</methodname>. If you give only an
  711. string then the default values are the 'gregorian' calendar and the 'abbr'
  712. format</entry>
  713. </row>
  714. <row>
  715. <entry><emphasis>DefaultDate</emphasis></entry>
  716. <entry>Returns the default date format which is used within the given
  717. calendar. If you omit the value the 'gregorian' calendar will be used. Use
  718. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  719. </row>
  720. <row>
  721. <entry><emphasis>Date</emphasis></entry>
  722. <entry>Returns the date format for an given calendar or format within a locale.
  723. If you omit the value then the 'gregorian' calendar will be used with the
  724. 'medium' format. If you give a string then the 'gregorian' calendar will be
  725. used with the given format. Or you can also give an array which will have to
  726. look like this: <methodname>array('calendar', 'format')</methodname>. Use
  727. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  728. </row>
  729. <row>
  730. <entry><emphasis>DefaultTime</emphasis></entry>
  731. <entry>Returns the default time format which is used within the given
  732. calendar. If you omit the value the 'gregorian' calendar will be used. Use
  733. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  734. </row>
  735. <row>
  736. <entry><emphasis>Time</emphasis></entry>
  737. <entry>Returns the time format for an given calendar or format within a locale.
  738. If you omit the value then the 'gregorian' calendar will be used with the
  739. 'medium' format. If you give a string then the 'gregorian' calendar will be
  740. used with the given format. Or you can also give an array which will have to
  741. look like this: <methodname>array('calendar', 'format')</methodname>. Use
  742. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  743. </row>
  744. <row>
  745. <entry><emphasis>DateTime</emphasis></entry>
  746. <entry>Returns the datetime format for the given locale which indicates how to
  747. display date with times in the same string within the given calendar. If you
  748. omit the value the 'gregorian' calendar will be used. Use
  749. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  750. </row>
  751. <row>
  752. <entry><emphasis>DateItem</emphasis></entry>
  753. <entry>Returns the default format for a given date or time item</entry>
  754. </row>
  755. <row>
  756. <entry><emphasis>DateInterval</emphasis></entry>
  757. <entry>
  758. Returns the interval format for a given date or time format. The first
  759. value is the calendar format, normally 'gregorian'. The second value is
  760. the interval format and the third value the token with the greatest
  761. difference. For example: array('gregorian', 'yMMMM', 'y') returns the
  762. interval format for the date format 'yMMMM' where 'y' has the greatest
  763. difference.
  764. </entry>
  765. </row>
  766. <row>
  767. <entry><emphasis>Field</emphasis></entry>
  768. <entry>Returns a translated date field which can be used to display calendars or
  769. date strings like 'month' or 'year' in a wished language. You must give the
  770. field which has to be returned as string. In this case the 'gregorian'
  771. calendar will be used. You can get the field for other calendar formats if you
  772. give an array which has to look like this:
  773. <methodname>array('calendar', 'date field')</methodname></entry>
  774. </row>
  775. <row>
  776. <entry><emphasis>Relative</emphasis></entry>
  777. <entry>Returns a translated date which is relative to today which can include date
  778. strings like 'yesterday' or 'tomorrow' in a wished language. You have to give
  779. the number of days relative to tomorrow to receive the expected string. Yesterday
  780. would be '-1', tomorrow '1' and so on. This will use the 'gregorian' calendar. If
  781. you want to get relative dates for other calendars you will have to give an array
  782. which has to look like this: <methodname>array('calendar', 'relative days')</methodname>. Use
  783. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity</entry>
  784. </row>
  785. <row>
  786. <entry><emphasis>DecimalNumber</emphasis></entry>
  787. <entry>Returns the format for decimal numbers within a given locale. Use
  788. <link linkend="zend.locale.parsing">Zend_Locale_Format</link> for simplicity</entry>
  789. </row>
  790. <row>
  791. <entry><emphasis>ScientificNumber</emphasis></entry>
  792. <entry>Returns the format for scientific numbers within a given locale</entry>
  793. </row>
  794. <row>
  795. <entry><emphasis>PercentNumber</emphasis></entry>
  796. <entry>Returns the format for percentage numbers within a given locale</entry>
  797. </row>
  798. <row>
  799. <entry><emphasis>CurrencyNumber</emphasis></entry>
  800. <entry>Returns the format for displaying currency numbers within a given locale. Use
  801. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  802. </row>
  803. <row>
  804. <entry><emphasis>NameToCurrency</emphasis></entry>
  805. <entry>Returns the translated name for a given currency. The currency has to be
  806. given in <acronym>ISO</acronym> format which is for example 'EUR' for the currency 'euro'. Use
  807. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  808. </row>
  809. <row>
  810. <entry><emphasis>CurrencyToName</emphasis></entry>
  811. <entry>Returns a currency for a given localized name. Use
  812. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  813. </row>
  814. <row>
  815. <entry><emphasis>CurrencySymbol</emphasis></entry>
  816. <entry>Returns the used symbol for a currency within a given locale. Not for all
  817. currencies exists a symbol. Use
  818. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  819. </row>
  820. <row>
  821. <entry><emphasis>Question</emphasis></entry>
  822. <entry>Returns a localized string for acceptance ('yes') and
  823. negotation ('no'). You have to give either 'yes' or 'no' as value to receive the
  824. expected string. Use
  825. <link linkend="zend.locale.getquestion">Zend_Locale's getQuestion method</link>
  826. for simplicity</entry>
  827. </row>
  828. <row>
  829. <entry><emphasis>CurrencyFraction</emphasis></entry>
  830. <entry>Returns the fraction to use for a given currency. You must give the currency
  831. as <acronym>ISO</acronym> value. Use <link linkend="zend.currency.introduction">Zend_Currency</link>
  832. for simplicity</entry>
  833. </row>
  834. <row>
  835. <entry><emphasis>CurrencyRounding</emphasis></entry>
  836. <entry>Returns how to round a given currency. You must give the currency
  837. as <acronym>ISO</acronym> value. If you omit the currency then the 'DEFAULT' rounding will be
  838. returned. Use <link linkend="zend.currency.introduction">Zend_Currency</link>
  839. for simplicity</entry>
  840. </row>
  841. <row>
  842. <entry><emphasis>CurrencyToRegion</emphasis></entry>
  843. <entry>Returns the currency for a given region. The region code has to be given
  844. as <constant>ISO3166</constant> string for example 'AT' for austria. Use
  845. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  846. </row>
  847. <row>
  848. <entry><emphasis>RegionToCurrency</emphasis></entry>
  849. <entry>Returns the regions where a currency is used. The currency has to be given
  850. as <constant>ISO4217</constant> code for example 'EUR' for euro. When a currency is used in multiple
  851. regions, these regions are separated with a whitespace character. Use
  852. <link linkend="zend.currency.introduction">Zend_Currency</link> for simplicity</entry>
  853. </row>
  854. <row>
  855. <entry><emphasis>RegionToTerritory</emphasis></entry>
  856. <entry>Returns the regions for a given territory. The territory has to be given as
  857. <constant>ISO4217</constant> string for example '001' for world. The regions within this territory
  858. are separated with a whitespace character</entry>
  859. </row>
  860. <row>
  861. <entry><emphasis>TerritoryToRegion</emphasis></entry>
  862. <entry>Returns the territories where a given region is located. The region has to be
  863. given in <constant>ISO3166</constant> string for example 'AT' for austria. When a region is located in
  864. multiple territories then these territories are separated with a whitespace
  865. character</entry>
  866. </row>
  867. <row>
  868. <entry><emphasis>ScriptToLanguage</emphasis></entry>
  869. <entry>Returns the scripts which are used within a given language. The language has
  870. to be given as <acronym>ISO</acronym> language code for example 'en' for english. When multiple
  871. scripts are used within a language then these scripts are separated with a
  872. whitespace character</entry>
  873. </row>
  874. <row>
  875. <entry><emphasis>LanguageToScript</emphasis></entry>
  876. <entry>Returns the languages which are used within a given script. The script has to be
  877. given as <acronym>ISO</acronym> script code for example 'Latn' for latin. When a script is used in
  878. multiple languages then these languages are separated with a whitespace
  879. character</entry>
  880. </row>
  881. <row>
  882. <entry><emphasis>TerritoryToLanguage</emphasis></entry>
  883. <entry>Returns the territories where a given language is used. The language has
  884. to be given as <acronym>ISO</acronym> language code for example 'en' for english. When multiple
  885. territories exist where this language is used then these territories are
  886. separated with a whitespace character</entry>
  887. </row>
  888. <row>
  889. <entry><emphasis>LanguageToTerritory</emphasis></entry>
  890. <entry>Returns the languages which are used within a given territory. The territory
  891. has to be given as <constant>ISO3166</constant> code for example 'IT' for italia. When a language
  892. is used in multiple territories then these territories are separated with a
  893. whitespace character</entry>
  894. </row>
  895. <row>
  896. <entry><emphasis>TimezoneToWindows</emphasis></entry>
  897. <entry>Returns a <acronym>ISO</acronym> timezone for a given windows timezone</entry>
  898. </row>
  899. <row>
  900. <entry><emphasis>WindowsToTimezone</emphasis></entry>
  901. <entry>Returns a windows timezone for a given <acronym>ISO</acronym> timezone</entry>
  902. </row>
  903. <row>
  904. <entry><emphasis>TerritoryToTimezone</emphasis></entry>
  905. <entry>Returns the territory for a given <acronym>ISO</acronym> timezone</entry>
  906. </row>
  907. <row>
  908. <entry><emphasis>TimezoneToTerritory</emphasis></entry>
  909. <entry>Returns the <acronym>ISO</acronym> timezone for a given territory</entry>
  910. </row>
  911. <row>
  912. <entry><emphasis>CityToTimezone</emphasis></entry>
  913. <entry>Returns the localized city for a given <acronym>ISO</acronym> timezone. Not for all timezones
  914. does a city translation exist</entry>
  915. </row>
  916. <row>
  917. <entry><emphasis>TimezoneToCity</emphasis></entry>
  918. <entry>Returns the <acronym>ISO</acronym> timezone for a given localized city name. Not for all cities
  919. does a timezone exist</entry>
  920. </row>
  921. <row>
  922. <entry><emphasis>PhoneToTerritory</emphasis></entry>
  923. <entry>Returns the telephone code for a given territory (region). The territory code
  924. has to be given as <constant>ISO3166</constant> string for example 'AT' for austria</entry>
  925. </row>
  926. <row>
  927. <entry><emphasis>TerritoryToPhone</emphasis></entry>
  928. <entry>Returns the territory (region) where a telephone code is used. The telephone
  929. code has to be given as plain integer code for example '43' for +43. When a
  930. telephone code is used in multiple territories (regions), these territories are
  931. separated with a whitespace character</entry>
  932. </row>
  933. <row>
  934. <entry><emphasis>NumericToTerritory</emphasis></entry>
  935. <entry>Returns the 3 digit number code for a given territory (region). The territory
  936. code has to be given as <constant>ISO3166</constant> string for example 'AT' for austria</entry>
  937. </row>
  938. <row>
  939. <entry><emphasis>TerritoryToNumeric</emphasis></entry>
  940. <entry>Returns the territory (region) for a 3 digit number code. The 3 digit number
  941. code has to be given as plain integer code for example '43'
  942. </entry>
  943. </row>
  944. <row>
  945. <entry><emphasis>Alpha3ToTerritory</emphasis></entry>
  946. <entry>Returns the 3 sign character code for a given territory (region). The territory
  947. code has to be given as <constant>ISO3166</constant> string for example 'AT' for austria</entry>
  948. </row>
  949. <row>
  950. <entry><emphasis>TerritoryToAlpha3</emphasis></entry>
  951. <entry>Returns the territory (region) for a 3 sign character code</entry>
  952. </row>
  953. <row>
  954. <entry><emphasis>PostalToTerritory</emphasis></entry>
  955. <entry>
  956. Returns the a regex for postal codes for a given territory. The
  957. territory has to be given as <constant>ISO4217</constant> string for example '001' for
  958. world</entry>
  959. </row>
  960. <row>
  961. <entry><emphasis>NumberingSystem</emphasis></entry>
  962. <entry>
  963. Returns a scripts with the notation for digits used within this script
  964. </entry>
  965. </row>
  966. <row>
  967. <entry><emphasis>FallbackToChar</emphasis></entry>
  968. <entry>
  969. Returns a replacement character for a often used unicode character.
  970. This can be used to replace "©" with "(C)" for example
  971. </entry>
  972. </row>
  973. <row>
  974. <entry><emphasis>CharToFallback</emphasis></entry>
  975. <entry>
  976. Returns a unicode character for a often used replacement character.
  977. This can be used to replace "(C)" with "©" for example
  978. </entry>
  979. </row>
  980. <row>
  981. <entry><emphasis>LocaleUpgrade</emphasis></entry>
  982. <entry>
  983. Returns a locale dependencies for a given language which can be used to
  984. upgrade this language to a full qualified locale
  985. </entry>
  986. </row>
  987. <row>
  988. <entry><emphasis>Unit</emphasis></entry>
  989. <entry>
  990. Returns a localized calendar unit. This can be used to translate
  991. the strings "day", "month" and so on automatically. The first parameter
  992. has to be the type, and the second parameter has to be the count
  993. </entry>
  994. </row>
  995. </tbody>
  996. </tgroup>
  997. </table>
  998. <note>
  999. <para>
  1000. With Zend Framework 1.5 several old types have been renamed. This has to be done because
  1001. of several new types, some misspelling and to increase the usability. See this table for
  1002. a list of old to new types:
  1003. </para>
  1004. </note>
  1005. <table id="zend.locale.getdata.table-3">
  1006. <title>Differences between Zend Framework 1.0 and 1.5</title>
  1007. <tgroup cols="2">
  1008. <thead>
  1009. <row>
  1010. <entry>Old type</entry>
  1011. <entry>New type</entry>
  1012. </row>
  1013. </thead>
  1014. <tbody>
  1015. <row>
  1016. <entry>Country</entry>
  1017. <entry>Territory (with value '2')</entry>
  1018. </row>
  1019. <row>
  1020. <entry>Calendar</entry>
  1021. <entry>Type (with value 'calendar')</entry>
  1022. </row>
  1023. <row>
  1024. <entry>Month_Short</entry>
  1025. <entry>Month (with array('gregorian', 'format', 'abbreviated')</entry>
  1026. </row>
  1027. <row>
  1028. <entry>Month_Narrow</entry>
  1029. <entry>Month (with array('gregorian', 'stand-alone', 'narrow')</entry>
  1030. </row>
  1031. <row>
  1032. <entry>Month_Complete</entry>
  1033. <entry>Months</entry>
  1034. </row>
  1035. <row>
  1036. <entry>Day_Short</entry>
  1037. <entry>Day (with array('gregorian', 'format', 'abbreviated')</entry>
  1038. </row>
  1039. <row>
  1040. <entry>Day_Narrow</entry>
  1041. <entry>Day (with array('gregorian', 'stand-alone', 'narrow')</entry>
  1042. </row>
  1043. <row>
  1044. <entry>DateFormat</entry>
  1045. <entry>Date</entry>
  1046. </row>
  1047. <row>
  1048. <entry>TimeFormat</entry>
  1049. <entry>Time</entry>
  1050. </row>
  1051. <row>
  1052. <entry>Timezones</entry>
  1053. <entry>CityToTimezone</entry>
  1054. </row>
  1055. <row>
  1056. <entry>Currency</entry>
  1057. <entry>NameToCurrency</entry>
  1058. </row>
  1059. <row>
  1060. <entry>Currency_Sign</entry>
  1061. <entry>CurrencySymbol</entry>
  1062. </row>
  1063. <row>
  1064. <entry>Currency_Detail</entry>
  1065. <entry>CurrencyToRegion</entry>
  1066. </row>
  1067. <row>
  1068. <entry>Territory_Detail</entry>
  1069. <entry>TerritoryToRegion</entry>
  1070. </row>
  1071. <row>
  1072. <entry>Language_Detail</entry>
  1073. <entry>LanguageToTerritory</entry>
  1074. </row>
  1075. </tbody>
  1076. </tgroup>
  1077. </table>
  1078. <para>
  1079. The example below demonstrates how to obtain the names of things in different languages.
  1080. </para>
  1081. <example id="zend.locale.getdata.example-3">
  1082. <title>getTranslationList</title>
  1083. <programlisting language="php"><![CDATA[
  1084. // prints the names of all countries in German language
  1085. print_r(Zend_Locale::getTranslationList('country', 'de'));
  1086. ]]></programlisting>
  1087. </example>
  1088. <para>
  1089. The next example shows how to find the name of a language in another language, when the two letter
  1090. iso country code is not known.
  1091. </para>
  1092. <example id="zend.locale.getdata.example-4">
  1093. <title>Converting country name in one language to another</title>
  1094. <programlisting language="php"><![CDATA[
  1095. $code2name = Zend_Locale::getLanguageTranslationList('en_US');
  1096. $name2code = array_flip($code2name);
  1097. $frenchCode = $name2code['French'];
  1098. echo Zend_Locale::getLanguageTranslation($frenchCode, 'de_AT');
  1099. // output is the German name of the French language
  1100. ]]></programlisting>
  1101. </example>
  1102. <para>
  1103. To generate a list of all languages known by <classname>Zend_Locale</classname>, with each language name shown in its own language,
  1104. try the example below in a web page. Similarly, <methodname>getCountryTranslationList()</methodname> and
  1105. <methodname>getCountryTranslation()</methodname> could be used to create a table mapping your native language names for
  1106. regions to the names of the regions shown in another language. Use a
  1107. <code>try .. catch</code> block to handle exceptions that occur when using a locale that does not exist. Not
  1108. all languages are also locales. In the example, below exceptions are ignored to prevent early termination.
  1109. </para>
  1110. <example id="zend.locale.getdata.example-6">
  1111. <title>All Languages written in their native language</title>
  1112. <programlisting language="php"><![CDATA[
  1113. $list = Zend_Locale::getLanguageTranslationList('auto');
  1114. foreach($list as $language => $content) {
  1115. try {
  1116. $output = Zend_Locale::getLanguageTranslation($language, $language);
  1117. if (is_string($output)) {
  1118. print "\n<br>[".$language."] ".$output;
  1119. }
  1120. } catch (Exception $e) {
  1121. continue;
  1122. }
  1123. }
  1124. ]]></programlisting>
  1125. </example>
  1126. </sect2>
  1127. <sect2 id="zend.locale.getquestion">
  1128. <title>Obtaining translations for "yes" and "no"</title>
  1129. <para>
  1130. Frequently, programs need to solicit a "yes" or "no" response from the user. Use <methodname>getQuestion()</methodname>
  1131. to obtain an array containing the correct word(s) or regex strings to use for prompting the user in a
  1132. particular $locale (defaults to the current object's locale). The returned array will contain the
  1133. following informations :
  1134. </para>
  1135. <itemizedlist>
  1136. <listitem>
  1137. <para>
  1138. <emphasis>yes and no</emphasis>: A generic string representation for yes
  1139. and no responses. This will contain the first and most generic response from yesarray and
  1140. noarray.
  1141. </para>
  1142. <para>
  1143. <emphasis>yesarray and noarray</emphasis>: An array with all known yes and
  1144. no responses. Several languages have more than just two responses. In general this is the
  1145. full string and its abbreviation.
  1146. </para>
  1147. <para>
  1148. <emphasis>yesexpr and noexpr</emphasis>: An generated regex which allows you
  1149. to handle user response, and search for yes or no.
  1150. </para>
  1151. </listitem>
  1152. </itemizedlist>
  1153. <para>
  1154. All of this informations are of course localized and depend on the set locale. See the following
  1155. example for the informations you can receive:
  1156. </para>
  1157. <example id="zend.locale.getquestion.example-1">
  1158. <title>getQuestion()</title>
  1159. <programlisting language="php"><![CDATA[
  1160. $locale = new Zend_Locale();
  1161. // Question strings
  1162. print_r($locale->getQuestion('de'));
  1163. - - - Output - - -
  1164. Array
  1165. (
  1166. [yes] => ja
  1167. [no] => nein
  1168. [yesarray] => Array
  1169. (
  1170. [0] => ja
  1171. [1] => j
  1172. )
  1173. [noarray] => Array
  1174. (
  1175. [0] => nein
  1176. [1] => n
  1177. )
  1178. [yesexpr] => ^([jJ][aA]?)|([jJ]?)
  1179. [noexpr] => ^([nN]([eE][iI][nN])?)|([nN]?)
  1180. )
  1181. ]]></programlisting>
  1182. </example>
  1183. <note>
  1184. <para>
  1185. Until 1.0.3 <emphasis>yesabbr</emphasis> from the underlaying locale data was also
  1186. available. Since 1.5 this information is no longer standalone available, but you will find the
  1187. information from it within <emphasis>yesarray</emphasis>.
  1188. </para>
  1189. </note>
  1190. </sect2>
  1191. <sect2 id="zend.locale.getlocalelist">
  1192. <title>Get a list of all known locales</title>
  1193. <para>
  1194. Sometimes you will want to get a list of all known locales. This can be used for several tasks
  1195. like the creation of a selectbox. For this purpose you can use the static
  1196. <methodname>getLocaleList()</methodname> method which will return a list of all known locales.
  1197. </para>
  1198. <example id="zend.locale.getlocalelist.example-1">
  1199. <title>getLocaleList()</title>
  1200. <programlisting language="php"><![CDATA[
  1201. $localelist = Zend_Locale::getLocaleList();
  1202. ]]></programlisting>
  1203. </example>
  1204. <note>
  1205. <para>
  1206. Note that the locales are returned as key of the array you will receive. The value is always
  1207. a boolean <constant>TRUE</constant>.
  1208. </para>
  1209. </note>
  1210. </sect2>
  1211. <sect2 id="zend.locale.detection">
  1212. <title>Detecting locales</title>
  1213. <para>
  1214. When you want to detect if a given input, regardless of its source, is a locale you should use
  1215. the static <methodname>isLocale()</methodname> method. The first parameter of this method is the string which
  1216. you want to check.
  1217. </para>
  1218. <example id="zend.locale.detection.example-1">
  1219. <title>Simple locale detection</title>
  1220. <programlisting language="php"><![CDATA[
  1221. $input = 'to_RU';
  1222. if (Zend_Locale::isLocale($input)) {
  1223. print "'{$input}' is a locale";
  1224. } else {
  1225. print "Sorry... the given input is no locale";
  1226. }
  1227. ]]></programlisting>
  1228. </example>
  1229. <para>
  1230. As you can see, the output of this method is always a boolean. There is only one reason you could
  1231. get an exception when calling this method. When your system does not provide any locale and
  1232. Zend Framework is not able to detect it automatically. Normally this shows that there is a problem
  1233. with your OS in combination with <acronym>PHP</acronym>'s <methodname>setlocale()</methodname>.
  1234. </para>
  1235. <para>
  1236. You should also note that any given locale string will automatically be degraded if the
  1237. region part does not exist for this locale. In our previous example the language
  1238. <code>'to'</code> does not exist in the region <code>'RU'</code>, but you will still get
  1239. <constant>TRUE</constant> returned as <classname>Zend_Locale</classname> can work with
  1240. the given input.
  1241. </para>
  1242. <para>
  1243. Still it's sometimes useful to prevent this automatic degrading, and this is where the second
  1244. parameter of <methodname>isLocale()</methodname> comes in place. The <code>strict</code> parameter defaults to
  1245. <constant>FALSE</constant> and can be used to prevent degrading when set to <constant>TRUE</constant>.
  1246. </para>
  1247. <example id="zend.locale.detection.example-2">
  1248. <title>Strict locale detection</title>
  1249. <programlisting language="php"><![CDATA[
  1250. $input = 'to_RU';
  1251. if (Zend_Locale::isLocale($input, true)) {
  1252. print "'{$input}' is a locale";
  1253. } else {
  1254. print "Sorry... the given input is no locale";
  1255. }
  1256. ]]></programlisting>
  1257. </example>
  1258. <para>
  1259. Now that you are able to detect if a given string is a locale you could add locale aware behaviour
  1260. to your own classes. But you will soon detect that this will always leads to the same 15 lines of
  1261. code. Something like the following example:
  1262. </para>
  1263. <example id="zend.locale.detection.example-3">
  1264. <title>Implement locale aware behaviour</title>
  1265. <programlisting language="php"><![CDATA[
  1266. if ($locale === null) {
  1267. $locale = new Zend_Locale();
  1268. }
  1269. if (!Zend_Locale::isLocale($locale, true, false)) {
  1270. if (!Zend_Locale::isLocale($locale, false, false)) {
  1271. throw new Zend_Locale_Exception(
  1272. "The locale '$locale' is no known locale");
  1273. }
  1274. $locale = new Zend_Locale($locale);
  1275. }
  1276. if ($locale instanceof Zend_Locale) {
  1277. $locale = $locale->toString();
  1278. }
  1279. ]]></programlisting>
  1280. </example>
  1281. <para>
  1282. With Zend Framework 1.8 we added a static <methodname>findLocale()</methodname> method which returns you a locale
  1283. string which you can work with. It processes the following tasks:
  1284. </para>
  1285. <itemizedlist>
  1286. <listitem>
  1287. <para>
  1288. Detects if a given string is a locale
  1289. </para>
  1290. </listitem>
  1291. <listitem>
  1292. <para>
  1293. Degrades the locale if it does not exist in the given region
  1294. </para>
  1295. </listitem>
  1296. <listitem>
  1297. <para>
  1298. Returns a previous set application wide locale if no input is given
  1299. </para>
  1300. </listitem>
  1301. <listitem>
  1302. <para>
  1303. Detects the locale from browser when the previous detections failed
  1304. </para>
  1305. </listitem>
  1306. <listitem>
  1307. <para>
  1308. Detects the locale from environment when the previous detections failed
  1309. </para>
  1310. </listitem>
  1311. <listitem>
  1312. <para>
  1313. Detects the locale from framework when the previous detections failed
  1314. </para>
  1315. </listitem>
  1316. <listitem>
  1317. <para>
  1318. Returns always a string which represents the found locale.
  1319. </para>
  1320. </listitem>
  1321. </itemizedlist>
  1322. <para>
  1323. The following example shows how these checks and the above code can be simplified with one single call:
  1324. </para>
  1325. <example id="zend.locale.detection.example-4">
  1326. <title>Locale aware behaviour as with Zend Framework 1.8</title>
  1327. <programlisting language="php"><![CDATA[
  1328. $locale = Zend_Locale::findLocale($inputstring);
  1329. ]]></programlisting>
  1330. </example>
  1331. </sect2>
  1332. </sect1>
  1333. <!--
  1334. vim:se ts=4 sw=4 et:
  1335. -->