Zend_Locale-Functions.xml 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014
  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>.
  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.setlocale.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 informations
  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 informations for all languages. But not all of the informations are
  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 informations.
  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. negotation ('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 countries which are using a language. The country code
  582. is used as array key and the language code as array value. When a
  583. language is used in several countries these countries are separated with
  584. 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 spoken within these
  591. countries. The country code is used as array key and the language code
  592. as array value. When a territory is using several languages these
  593. 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 returns always 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:
  842. <code>array( 'calendar', 'context', 'format', 'month number')</code>. If
  843. you give only an integer then the default values are the 'gregorian'
  844. calendar, the context 'format' and the format 'wide'. Use
  845. <link 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 a translation for 'AM' in a expected locale. If you want to
  897. receive data for other calendars an string with the expected calendar.
  898. If you omit the value then the 'gregorian' calendar will be used. Use
  899. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity
  900. </entry>
  901. </row>
  902. <row>
  903. <entry><emphasis>Pm</emphasis></entry>
  904. <entry>
  905. Returns a translation for 'PM' in a expected locale. If you want to
  906. receive data for other calendars an string with the expected calendar.
  907. If you omit the value then the 'gregorian' calendar will be used. Use
  908. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity
  909. </entry>
  910. </row>
  911. <row>
  912. <entry><emphasis>Era</emphasis></entry>
  913. <entry>
  914. Returns a translation for an era within a locale. You have to give the
  915. era number as string or integer. If you want to receive data for other
  916. calendars or formats, then you must give an array instead of the era
  917. number with the expected values. The array has to look like this:
  918. <methodname>array('calendar', 'format', 'era number')</methodname>. If
  919. you give only an string then the default values are the 'gregorian'
  920. calendar and the 'abbr' format
  921. </entry>
  922. </row>
  923. <row>
  924. <entry><emphasis>DefaultDate</emphasis></entry>
  925. <entry>
  926. Returns the default date format which is used within the given
  927. calendar. If you omit the value the 'gregorian' calendar will be used.
  928. Use <link linkend="zend.date.introduction">Zend_Date</link> for
  929. simplicity
  930. </entry>
  931. </row>
  932. <row>
  933. <entry><emphasis>Date</emphasis></entry>
  934. <entry>
  935. Returns the date format for an given calendar or format within a locale.
  936. If you omit the value then the 'gregorian' calendar will be used with
  937. the 'medium' format. If you give a string then the 'gregorian' calendar
  938. will be used with the given format. Or you can also give an array which
  939. will have to look like this: <methodname>array('calendar',
  940. 'format')</methodname>. Use <link
  941. linkend="zend.date.introduction">Zend_Date</link> for simplicity
  942. </entry>
  943. </row>
  944. <row>
  945. <entry><emphasis>DefaultTime</emphasis></entry>
  946. <entry>
  947. Returns the default time format which is used within the given calendar.
  948. If you omit the value the 'gregorian' calendar will be used. Use
  949. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity
  950. </entry>
  951. </row>
  952. <row>
  953. <entry><emphasis>Time</emphasis></entry>
  954. <entry>
  955. Returns the time format for an given calendar or format within a locale.
  956. If you omit the value then the 'gregorian' calendar will be used with
  957. the 'medium' format. If you give a string then the 'gregorian' calendar
  958. will be used with the given format. Or you can also give an array which
  959. will have to look like this:
  960. <methodname>array('calendar', 'format')</methodname>. Use <link
  961. linkend="zend.date.introduction">Zend_Date</link> for simplicity
  962. </entry>
  963. </row>
  964. <row>
  965. <entry><emphasis>DateTime</emphasis></entry>
  966. <entry>
  967. Returns the datetime format for the given locale which indicates how to
  968. display date with times in the same string within the given calendar. If
  969. you omit the value the 'gregorian' calendar will be used. Use
  970. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity
  971. </entry>
  972. </row>
  973. <row>
  974. <entry><emphasis>DateItem</emphasis></entry>
  975. <entry>Returns the default format for a given date or time item</entry>
  976. </row>
  977. <row>
  978. <entry><emphasis>DateInterval</emphasis></entry>
  979. <entry>
  980. Returns the interval format for a given date or time format. The first
  981. value is the calendar format, normally 'gregorian'. The second value is
  982. the interval format and the third value the token with the greatest
  983. difference. For example: array('gregorian', 'yMMMM', 'y') returns the
  984. interval format for the date format 'yMMMM' where 'y' has the greatest
  985. difference.
  986. </entry>
  987. </row>
  988. <row>
  989. <entry><emphasis>Field</emphasis></entry>
  990. <entry>
  991. Returns a translated date field which can be used to display calendars
  992. or date strings like 'month' or 'year' in a wished language. You must
  993. give the field which has to be returned as string. In this case the
  994. 'gregorian' calendar will be used. You can get the field for other
  995. calendar formats if you give an array which has to look like this:
  996. <methodname>array('calendar', 'date field')</methodname>
  997. </entry>
  998. </row>
  999. <row>
  1000. <entry><emphasis>Relative</emphasis></entry>
  1001. <entry>
  1002. Returns a translated date which is relative to today which can include
  1003. date strings like 'yesterday' or 'tomorrow' in a wished language. You
  1004. have to give the number of days relative to tomorrow to receive the
  1005. expected string. Yesterday would be '-1', tomorrow '1' and so on. This
  1006. will use the 'gregorian' calendar. if you want to get relative dates for
  1007. other calendars you will have to give an array which has to look like
  1008. this: <methodname>array('calendar', 'relative days')</methodname>. Use
  1009. <link linkend="zend.date.introduction">Zend_Date</link> for simplicity
  1010. </entry>
  1011. </row>
  1012. <row>
  1013. <entry><emphasis>DecimalNumber</emphasis></entry>
  1014. <entry>
  1015. Returns the format for decimal numbers within a given locale. Use <link
  1016. linkend="zend.locale.parsing">Zend_Locale_Format</link> for
  1017. simplicity
  1018. </entry>
  1019. </row>
  1020. <row>
  1021. <entry><emphasis>ScientificNumber</emphasis></entry>
  1022. <entry>
  1023. Returns the format for scientific numbers within a given locale
  1024. </entry>
  1025. </row>
  1026. <row>
  1027. <entry><emphasis>PercentNumber</emphasis></entry>
  1028. <entry>
  1029. Returns the format for percentage numbers within a given locale
  1030. </entry>
  1031. </row>
  1032. <row>
  1033. <entry><emphasis>CurrencyNumber</emphasis></entry>
  1034. <entry>
  1035. Returns the format for displaying currency numbers within a given
  1036. locale. Use <link
  1037. linkend="zend.currency.introduction">Zend_Currency</link> for
  1038. simplicity
  1039. </entry>
  1040. </row>
  1041. <row>
  1042. <entry><emphasis>NameToCurrency</emphasis></entry>
  1043. <entry>
  1044. Returns the translated name for a given currency. The currency has to be
  1045. given in <acronym>ISO</acronym> format which is for example 'EUR' for
  1046. the currency 'euro'. Use <link
  1047. linkend="zend.currency.introduction">Zend_Currency</link> for
  1048. simplicity
  1049. </entry>
  1050. </row>
  1051. <row>
  1052. <entry><emphasis>CurrencyToName</emphasis></entry>
  1053. <entry>
  1054. Returns a currency for a given localized name. Use <link
  1055. linkend="zend.currency.introduction">Zend_Currency</link> for
  1056. simplicity
  1057. </entry>
  1058. </row>
  1059. <row>
  1060. <entry><emphasis>CurrencySymbol</emphasis></entry>
  1061. <entry>
  1062. Returns the used symbol for a currency within a given locale. Not for
  1063. all currencies exists a symbol. Use
  1064. <link linkend="zend.currency.introduction">Zend_Currency</link> for
  1065. simplicity
  1066. </entry>
  1067. </row>
  1068. <row>
  1069. <entry><emphasis>Question</emphasis></entry>
  1070. <entry>
  1071. Returns a localized string for acceptance ('yes') and negotation ('no').
  1072. You have to give either 'yes' or 'no' as value to receive the expected
  1073. string. Use <link linkend="zend.locale.getquestion">Zend_Locale's
  1074. getQuestion method</link> for simplicity
  1075. </entry>
  1076. </row>
  1077. <row>
  1078. <entry><emphasis>CurrencyFraction</emphasis></entry>
  1079. <entry>
  1080. Returns the fraction to use for a given currency. You must give the
  1081. currency as <acronym>ISO</acronym> value. Use <link
  1082. linkend="zend.currency.introduction">Zend_Currency</link>
  1083. for simplicity
  1084. </entry>
  1085. </row>
  1086. <row>
  1087. <entry><emphasis>CurrencyRounding</emphasis></entry>
  1088. <entry>
  1089. Returns how to round a given currency. You must give the currency as
  1090. <acronym>ISO</acronym> value. If you omit the currency then the
  1091. 'DEFAULT' rounding will be returned. Use <link
  1092. linkend="zend.currency.introduction">Zend_Currency</link>
  1093. for simplicity
  1094. </entry>
  1095. </row>
  1096. <row>
  1097. <entry><emphasis>CurrencyToRegion</emphasis></entry>
  1098. <entry>
  1099. Returns the currency for a given region. The region code has to be given
  1100. as <constant>ISO3166</constant> string for example 'AT' for austria. Use
  1101. <link linkend="zend.currency.introduction">Zend_Currency</link> for
  1102. simplicity
  1103. </entry>
  1104. </row>
  1105. <row>
  1106. <entry><emphasis>RegionToCurrency</emphasis></entry>
  1107. <entry>
  1108. Returns the regions where a currency is used. The currency has to be
  1109. given as <constant>ISO4217</constant> code for example 'EUR' for euro.
  1110. When a currency is used in multiple regions, these regions are separated
  1111. with a whitespace character. Use <link
  1112. linkend="zend.currency.introduction">Zend_Currency</link> for
  1113. simplicity
  1114. </entry>
  1115. </row>
  1116. <row>
  1117. <entry><emphasis>RegionToTerritory</emphasis></entry>
  1118. <entry>
  1119. Returns the regions for a given territory. The territory has to be given
  1120. as <constant>ISO4217</constant> string for example '001' for world. The
  1121. regions within this territory are separated with a whitespace character
  1122. </entry>
  1123. </row>
  1124. <row>
  1125. <entry><emphasis>TerritoryToRegion</emphasis></entry>
  1126. <entry>
  1127. Returns the territories where a given region is located. The region has
  1128. to be given in <constant>ISO3166</constant> string for example 'AT' for
  1129. austria. When a region is located in multiple territories then these
  1130. territories are separated with a whitespace character
  1131. </entry>
  1132. </row>
  1133. <row>
  1134. <entry><emphasis>ScriptToLanguage</emphasis></entry>
  1135. <entry>
  1136. Returns the scripts which are used within a given language. The language
  1137. has to be given as <acronym>ISO</acronym> language code for example 'en'
  1138. for english. When multiple scripts are used within a language then these
  1139. scripts are separated with a whitespace character
  1140. </entry>
  1141. </row>
  1142. <row>
  1143. <entry><emphasis>LanguageToScript</emphasis></entry>
  1144. <entry>
  1145. Returns the languages which are used within a given script. The script
  1146. has to be given as <acronym>ISO</acronym> script code for example 'Latn'
  1147. for latin. When a script is used in multiple languages then these
  1148. languages are separated with a whitespace character
  1149. </entry>
  1150. </row>
  1151. <row>
  1152. <entry><emphasis>TerritoryToLanguage</emphasis></entry>
  1153. <entry>
  1154. Returns the territories where a given language is used. The language has
  1155. to be given as <acronym>ISO</acronym> language code for example 'en' for
  1156. english. When multiple territories exist where this language is used
  1157. then these territories are separated with a whitespace character
  1158. </entry>
  1159. </row>
  1160. <row>
  1161. <entry><emphasis>LanguageToTerritory</emphasis></entry>
  1162. <entry>
  1163. Returns the languages which are used within a given territory. The
  1164. territory has to be given as <constant>ISO3166</constant> code for
  1165. example 'IT' for italia. When a language is used in multiple territories
  1166. then these territories are separated with a whitespace character
  1167. </entry>
  1168. </row>
  1169. <row>
  1170. <entry><emphasis>TimezoneToWindows</emphasis></entry>
  1171. <entry>
  1172. Returns a <acronym>ISO</acronym> timezone for a given windows timezone
  1173. </entry>
  1174. </row>
  1175. <row>
  1176. <entry><emphasis>WindowsToTimezone</emphasis></entry>
  1177. <entry>
  1178. Returns a windows timezone for a given <acronym>ISO</acronym> timezone
  1179. </entry>
  1180. </row>
  1181. <row>
  1182. <entry><emphasis>TerritoryToTimezone</emphasis></entry>
  1183. <entry>
  1184. Returns the territory for a given <acronym>ISO</acronym> timezone
  1185. </entry>
  1186. </row>
  1187. <row>
  1188. <entry><emphasis>TimezoneToTerritory</emphasis></entry>
  1189. <entry>
  1190. Returns the <acronym>ISO</acronym> timezone for a given territory
  1191. </entry>
  1192. </row>
  1193. <row>
  1194. <entry><emphasis>CityToTimezone</emphasis></entry>
  1195. <entry>
  1196. Returns the localized city for a given <acronym>ISO</acronym> timezone.
  1197. Not for all timezones does a city translation exist
  1198. </entry>
  1199. </row>
  1200. <row>
  1201. <entry><emphasis>TimezoneToCity</emphasis></entry>
  1202. <entry>
  1203. Returns the <acronym>ISO</acronym> timezone for a given localized city
  1204. name. Not for all cities does a timezone exist
  1205. </entry>
  1206. </row>
  1207. <row>
  1208. <entry><emphasis>PhoneToTerritory</emphasis></entry>
  1209. <entry>
  1210. Returns the telephone code for a given territory (region). The territory
  1211. code has to be given as <constant>ISO3166</constant> string for example
  1212. 'AT' for austria
  1213. </entry>
  1214. </row>
  1215. <row>
  1216. <entry><emphasis>TerritoryToPhone</emphasis></entry>
  1217. <entry>
  1218. Returns the territory (region) where a telephone code is used. The
  1219. telephone code has to be given as plain integer code for example '43'
  1220. for +43. When a telephone code is used in multiple territories
  1221. (regions), these territories are separated with a whitespace character
  1222. </entry>
  1223. </row>
  1224. <row>
  1225. <entry><emphasis>NumericToTerritory</emphasis></entry>
  1226. <entry>
  1227. Returns the 3 digit number code for a given territory (region). The
  1228. territory code has to be given as <constant>ISO3166</constant> string
  1229. for example 'AT' for austria
  1230. </entry>
  1231. </row>
  1232. <row>
  1233. <entry><emphasis>TerritoryToNumeric</emphasis></entry>
  1234. <entry>
  1235. Returns the territory (region) for a 3 digit number code. The 3 digit
  1236. number code has to be given as plain integer code for example '43'
  1237. </entry>
  1238. </row>
  1239. <row>
  1240. <entry><emphasis>Alpha3ToTerritory</emphasis></entry>
  1241. <entry>
  1242. Returns the 3 sign character code for a given territory (region). The
  1243. territory code has to be given as <constant>ISO3166</constant> string
  1244. for example 'AT' for austria
  1245. </entry>
  1246. </row>
  1247. <row>
  1248. <entry><emphasis>TerritoryToAlpha3</emphasis></entry>
  1249. <entry>Returns the territory (region) for a 3 sign character code</entry>
  1250. </row>
  1251. <row>
  1252. <entry><emphasis>PostalToTerritory</emphasis></entry>
  1253. <entry>
  1254. Returns the a regex for postal codes for a given territory. The
  1255. territory has to be given as <constant>ISO4217</constant> string for
  1256. example '001' for world
  1257. </entry>
  1258. </row>
  1259. <row>
  1260. <entry><emphasis>NumberingSystem</emphasis></entry>
  1261. <entry>
  1262. Returns a scripts with the notation for digits used within this script
  1263. </entry>
  1264. </row>
  1265. <row>
  1266. <entry><emphasis>FallbackToChar</emphasis></entry>
  1267. <entry>
  1268. Returns a replacement character for a often used unicode character.
  1269. This can be used to replace "©" with "(C)" for example
  1270. </entry>
  1271. </row>
  1272. <row>
  1273. <entry><emphasis>CharToFallback</emphasis></entry>
  1274. <entry>
  1275. Returns a unicode character for a often used replacement character.
  1276. This can be used to replace "(C)" with "©" for example
  1277. </entry>
  1278. </row>
  1279. <row>
  1280. <entry><emphasis>LocaleUpgrade</emphasis></entry>
  1281. <entry>
  1282. Returns a locale dependencies for a given language which can be used to
  1283. upgrade this language to a full qualified locale
  1284. </entry>
  1285. </row>
  1286. <row>
  1287. <entry><emphasis>Unit</emphasis></entry>
  1288. <entry>
  1289. Returns a localized calendar unit. This can be used to translate
  1290. the strings "day", "month" and so on automatically. The first parameter
  1291. has to be the type, and the second parameter has to be the count
  1292. </entry>
  1293. </row>
  1294. </tbody>
  1295. </tgroup>
  1296. </table>
  1297. <note>
  1298. <para>
  1299. With Zend Framework 1.5 several old types have been renamed. This has to be done
  1300. because of several new types, some misspelling and to increase the usability. See
  1301. this table for a list of old to new types:
  1302. </para>
  1303. </note>
  1304. <table id="zend.locale.getdata.table-3">
  1305. <title>Differences between Zend Framework 1.0 and 1.5</title>
  1306. <tgroup cols="2">
  1307. <thead>
  1308. <row>
  1309. <entry>Old type</entry>
  1310. <entry>New type</entry>
  1311. </row>
  1312. </thead>
  1313. <tbody>
  1314. <row>
  1315. <entry>Country</entry>
  1316. <entry>Territory (with value '2')</entry>
  1317. </row>
  1318. <row>
  1319. <entry>Calendar</entry>
  1320. <entry>Type (with value 'calendar')</entry>
  1321. </row>
  1322. <row>
  1323. <entry>Month_Short</entry>
  1324. <entry>Month (with array('gregorian', 'format', 'abbreviated')</entry>
  1325. </row>
  1326. <row>
  1327. <entry>Month_Narrow</entry>
  1328. <entry>Month (with array('gregorian', 'stand-alone', 'narrow')</entry>
  1329. </row>
  1330. <row>
  1331. <entry>Month_Complete</entry>
  1332. <entry>Months</entry>
  1333. </row>
  1334. <row>
  1335. <entry>Day_Short</entry>
  1336. <entry>Day (with array('gregorian', 'format', 'abbreviated')</entry>
  1337. </row>
  1338. <row>
  1339. <entry>Day_Narrow</entry>
  1340. <entry>Day (with array('gregorian', 'stand-alone', 'narrow')</entry>
  1341. </row>
  1342. <row>
  1343. <entry>DateFormat</entry>
  1344. <entry>Date</entry>
  1345. </row>
  1346. <row>
  1347. <entry>TimeFormat</entry>
  1348. <entry>Time</entry>
  1349. </row>
  1350. <row>
  1351. <entry>Timezones</entry>
  1352. <entry>CityToTimezone</entry>
  1353. </row>
  1354. <row>
  1355. <entry>Currency</entry>
  1356. <entry>NameToCurrency</entry>
  1357. </row>
  1358. <row>
  1359. <entry>Currency_Sign</entry>
  1360. <entry>CurrencySymbol</entry>
  1361. </row>
  1362. <row>
  1363. <entry>Currency_Detail</entry>
  1364. <entry>CurrencyToRegion</entry>
  1365. </row>
  1366. <row>
  1367. <entry>Territory_Detail</entry>
  1368. <entry>TerritoryToRegion</entry>
  1369. </row>
  1370. <row>
  1371. <entry>Language_Detail</entry>
  1372. <entry>LanguageToTerritory</entry>
  1373. </row>
  1374. </tbody>
  1375. </tgroup>
  1376. </table>
  1377. <para>
  1378. The example below demonstrates how to obtain the names of things in different languages.
  1379. </para>
  1380. <example id="zend.locale.getdata.example-3">
  1381. <title>getTranslationList</title>
  1382. <programlisting language="php"><![CDATA[
  1383. // prints the names of all countries in German language
  1384. print_r(Zend_Locale::getTranslationList('country', 'de'));
  1385. ]]></programlisting>
  1386. </example>
  1387. <para>
  1388. The next example shows how to find the name of a language in another language, when the
  1389. two letter iso country code is not known.
  1390. </para>
  1391. <example id="zend.locale.getdata.example-4">
  1392. <title>Converting country name in one language to another</title>
  1393. <programlisting language="php"><![CDATA[
  1394. $code2name = Zend_Locale::getLanguageTranslationList('en_US');
  1395. $name2code = array_flip($code2name);
  1396. $frenchCode = $name2code['French'];
  1397. echo Zend_Locale::getLanguageTranslation($frenchCode, 'de_AT');
  1398. // output is the German name of the French language
  1399. ]]></programlisting>
  1400. </example>
  1401. <para>
  1402. To generate a list of all languages known by <classname>Zend_Locale</classname>, with
  1403. each language name shown in its own language, try the example below in a web page.
  1404. Similarly, <methodname>getCountryTranslationList()</methodname> and
  1405. <methodname>getCountryTranslation()</methodname> could be used to create a table mapping
  1406. your native language names for regions to the names of the regions shown in another
  1407. language. Use a <code>try .. catch</code> block to handle exceptions that occur when
  1408. using a locale that does not exist. Not all languages are also locales. In the example,
  1409. below exceptions are ignored to prevent early termination.
  1410. </para>
  1411. <example id="zend.locale.getdata.example-6">
  1412. <title>All Languages written in their native language</title>
  1413. <programlisting language="php"><![CDATA[
  1414. $list = Zend_Locale::getLanguageTranslationList('auto');
  1415. foreach($list as $language => $content) {
  1416. try {
  1417. $output = Zend_Locale::getLanguageTranslation($language, $language);
  1418. if (is_string($output)) {
  1419. print "\n<br>[".$language."] ".$output;
  1420. }
  1421. } catch (Exception $e) {
  1422. continue;
  1423. }
  1424. }
  1425. ]]></programlisting>
  1426. </example>
  1427. </sect2>
  1428. <sect2 id="zend.locale.getquestion">
  1429. <title>Obtaining translations for "yes" and "no"</title>
  1430. <para>
  1431. Frequently, programs need to solicit a "yes" or "no" response from the user. Use
  1432. <methodname>getQuestion()</methodname> to obtain an array containing the correct word(s)
  1433. or regex strings to use for prompting the user in a particular $locale (defaults to the
  1434. current object's locale). The returned array will contain the following informations :
  1435. </para>
  1436. <itemizedlist>
  1437. <listitem>
  1438. <para>
  1439. <emphasis>yes and no</emphasis>: A generic string representation for yes and no
  1440. responses. This will contain the first and most generic response from yesarray
  1441. and noarray.
  1442. </para>
  1443. <para>
  1444. <emphasis>yesarray and noarray</emphasis>: An array with all known yes and
  1445. no responses. Several languages have more than just two responses. In general
  1446. this is the full string and its abbreviation.
  1447. </para>
  1448. <para>
  1449. <emphasis>yesexpr and noexpr</emphasis>: An generated regex which allows you
  1450. to handle user response, and search for yes or no.
  1451. </para>
  1452. </listitem>
  1453. </itemizedlist>
  1454. <para>
  1455. All of this informations are of course localized and depend on the set locale. See the
  1456. following example for the informations you can receive:
  1457. </para>
  1458. <example id="zend.locale.getquestion.example-1">
  1459. <title>getQuestion()</title>
  1460. <programlisting language="php"><![CDATA[
  1461. $locale = new Zend_Locale();
  1462. // Question strings
  1463. print_r($locale->getQuestion('de'));
  1464. - - - Output - - -
  1465. Array
  1466. (
  1467. [yes] => ja
  1468. [no] => nein
  1469. [yesarray] => Array
  1470. (
  1471. [0] => ja
  1472. [1] => j
  1473. )
  1474. [noarray] => Array
  1475. (
  1476. [0] => nein
  1477. [1] => n
  1478. )
  1479. [yesexpr] => ^([jJ][aA]?)|([jJ]?)
  1480. [noexpr] => ^([nN]([eE][iI][nN])?)|([nN]?)
  1481. )
  1482. ]]></programlisting>
  1483. </example>
  1484. <note>
  1485. <para>
  1486. Until 1.0.3 <emphasis>yesabbr</emphasis> from the underlaying locale data was also
  1487. available. Since 1.5 this information is no longer standalone available, but you
  1488. will find the information from it within <emphasis>yesarray</emphasis>.
  1489. </para>
  1490. </note>
  1491. </sect2>
  1492. <sect2 id="zend.locale.getlocalelist">
  1493. <title>Get a list of all known locales</title>
  1494. <para>
  1495. Sometimes you will want to get a list of all known locales. This can be used for several
  1496. tasks like the creation of a selectbox. For this purpose you can use the static
  1497. <methodname>getLocaleList()</methodname> method which will return a list of all known
  1498. locales.
  1499. </para>
  1500. <example id="zend.locale.getlocalelist.example-1">
  1501. <title>getLocaleList()</title>
  1502. <programlisting language="php"><![CDATA[
  1503. $localelist = Zend_Locale::getLocaleList();
  1504. ]]></programlisting>
  1505. </example>
  1506. <note>
  1507. <para>
  1508. Note that the locales are returned as key of the array you will receive. The value
  1509. is always a boolean <constant>TRUE</constant>.
  1510. </para>
  1511. </note>
  1512. </sect2>
  1513. <sect2 id="zend.locale.detection">
  1514. <title>Detecting locales</title>
  1515. <para>
  1516. When you want to detect if a given input, regardless of its source, is a locale you
  1517. should use the static <methodname>isLocale()</methodname> method. The first parameter of
  1518. this method is the string which you want to check.
  1519. </para>
  1520. <example id="zend.locale.detection.example-1">
  1521. <title>Simple locale detection</title>
  1522. <programlisting language="php"><![CDATA[
  1523. $input = 'to_RU';
  1524. if (Zend_Locale::isLocale($input)) {
  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. As you can see, the output of this method is always a boolean. There is only one reason
  1533. you could get an exception when calling this method. When your system does not provide
  1534. any locale and Zend Framework is not able to detect it automatically. Normally this
  1535. shows that there is a problem with your OS in combination with <acronym>PHP</acronym>'s
  1536. <methodname>setlocale()</methodname>.
  1537. </para>
  1538. <para>
  1539. You should also note that any given locale string will automatically be degraded if the
  1540. region part does not exist for this locale. In our previous example the language
  1541. <code>'to'</code> does not exist in the region <code>'RU'</code>, but you will still get
  1542. <constant>TRUE</constant> returned as <classname>Zend_Locale</classname> can work with
  1543. the given input.
  1544. </para>
  1545. <para>
  1546. Still it's sometimes useful to prevent this automatic degrading, and this is where the
  1547. second parameter of <methodname>isLocale()</methodname> comes in place. The
  1548. <code>strict</code> parameter defaults to <constant>FALSE</constant> and can be used to
  1549. prevent degrading when set to <constant>TRUE</constant>.
  1550. </para>
  1551. <example id="zend.locale.detection.example-2">
  1552. <title>Strict locale detection</title>
  1553. <programlisting language="php"><![CDATA[
  1554. $input = 'to_RU';
  1555. if (Zend_Locale::isLocale($input, true)) {
  1556. print "'{$input}' is a locale";
  1557. } else {
  1558. print "Sorry... the given input is no locale";
  1559. }
  1560. ]]></programlisting>
  1561. </example>
  1562. <para>
  1563. Now that you are able to detect if a given string is a locale you could add locale aware
  1564. behaviour to your own classes. But you will soon detect that this will always leads to
  1565. the same 15 lines of code. Something like the following example:
  1566. </para>
  1567. <example id="zend.locale.detection.example-3">
  1568. <title>Implement locale aware behaviour</title>
  1569. <programlisting language="php"><![CDATA[
  1570. if ($locale === null) {
  1571. $locale = new Zend_Locale();
  1572. }
  1573. if (!Zend_Locale::isLocale($locale, true, false)) {
  1574. if (!Zend_Locale::isLocale($locale, false, false)) {
  1575. throw new Zend_Locale_Exception(
  1576. "The locale '$locale' is no known locale");
  1577. }
  1578. $locale = new Zend_Locale($locale);
  1579. }
  1580. if ($locale instanceof Zend_Locale) {
  1581. $locale = $locale->toString();
  1582. }
  1583. ]]></programlisting>
  1584. </example>
  1585. <para>
  1586. With Zend Framework 1.8 we added a static <methodname>findLocale()</methodname> method
  1587. which returns you a locale string which you can work with. It processes the following
  1588. tasks:
  1589. </para>
  1590. <itemizedlist>
  1591. <listitem>
  1592. <para>
  1593. Detects if a given string is a locale
  1594. </para>
  1595. </listitem>
  1596. <listitem>
  1597. <para>
  1598. Degrades the locale if it does not exist in the given region
  1599. </para>
  1600. </listitem>
  1601. <listitem>
  1602. <para>
  1603. Upgrades the locale when it is detected as region without language
  1604. </para>
  1605. </listitem>
  1606. <listitem>
  1607. <para>
  1608. Returns a previous set application wide locale if no input is given
  1609. </para>
  1610. </listitem>
  1611. <listitem>
  1612. <para>
  1613. Detects the locale from browser when the previous detections failed
  1614. </para>
  1615. </listitem>
  1616. <listitem>
  1617. <para>
  1618. Detects the locale from environment when the previous detections failed
  1619. </para>
  1620. </listitem>
  1621. <listitem>
  1622. <para>
  1623. Detects the locale from framework when the previous detections failed
  1624. </para>
  1625. </listitem>
  1626. <listitem>
  1627. <para>
  1628. Returns always a string which represents the found locale.
  1629. </para>
  1630. </listitem>
  1631. </itemizedlist>
  1632. <para>
  1633. The following example shows how these checks and the above code can be simplified with
  1634. one single call:
  1635. </para>
  1636. <example id="zend.locale.detection.example-4">
  1637. <title>Locale aware behaviour as with Zend Framework 1.8</title>
  1638. <programlisting language="php"><![CDATA[
  1639. $locale = Zend_Locale::findLocale($inputstring);
  1640. ]]></programlisting>
  1641. </example>
  1642. </sect2>
  1643. </sect1>
  1644. <!--
  1645. vim:se ts=4 sw=4 et:
  1646. -->