Zend_Locale-Functions.xml 74 KB

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