Zend_Locale-Functions.xml 85 KB

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