Zend_Locale-Functions.xml 85 KB

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