Zend_Locale-Functions.xml 87 KB

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