Zend_Translate-Additional.xml 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 24249 -->
  4. <sect1 id="zend.translate.additional">
  5. <title>翻訳用の追加機能</title>
  6. <para>
  7. <classname>Zend_Translate</classname> がサポートする機能は他にもあります。
  8. ここに、追加情報をまとめました。
  9. </para>
  10. <sect2 id="zend.translate.additional.options">
  11. <title>アダプタのオプション</title>
  12. <para>
  13. すべてのアダプタで、オプションを使用できます。
  14. もちろん、アダプタによってオプションは異なります。
  15. アダプタを作成する際に、オプションを設定できます。
  16. すべてのアダプタで共通のオプションは '<emphasis>clear</emphasis>'
  17. で、これは、翻訳データを既存のものに追記するのかしないのかを指定します。
  18. 標準の動作は、新しい翻訳を既存の翻訳に追記します。
  19. しかし、これを指定すると、既存の翻訳データをいったん消去して
  20. 新しいデータを追加します。消去されるのは選択した言語のみであり、
  21. その他の言語は影響を受けません。
  22. </para>
  23. <para>
  24. <methodname>addTranslation()</methodname>に与えることによって、
  25. 一時的にオプションをセットできます。
  26. そして、オプションを固定で設定するには、メソッド <methodname>setOptions()</methodname>を使えます。
  27. </para>
  28. <example id="zend.translate..additional.options.example">
  29. <title>翻訳オプションの使用</title>
  30. <programlisting language="php"><![CDATA[
  31. // ':' を、翻訳ソースファイルの区切り文字として指定します
  32. $translate = new Zend_Translate(
  33. array(
  34. 'adapter' => 'csv',
  35. 'content' => '/path/to/mytranslation.csv',
  36. 'locale' => 'de',
  37. 'delimiter' => ':'
  38. )
  39. );
  40. ...
  41. // 定義されている言語を消去し、新しい翻訳データを使用します
  42. $translate->addTranslation(
  43. array(
  44. 'content' => '/path/to/new.csv',
  45. 'locale' => 'fr',
  46. 'clear' => true
  47. )
  48. );
  49. ]]></programlisting>
  50. </example>
  51. <para>
  52. 各アダプタで使用できるオプションについて、
  53. その使用法を以下にまとめます。
  54. </para>
  55. <table id="zend.translate.additional.options.alloptions">
  56. <title>翻訳アダプタのオプション</title>
  57. <tgroup cols="4">
  58. <thead>
  59. <row>
  60. <entry>オプション</entry>
  61. <entry>アダプタ</entry>
  62. <entry>説明</entry>
  63. <entry>デフォルト値</entry>
  64. </row>
  65. </thead>
  66. <tbody>
  67. <row>
  68. <entry>adapter</entry>
  69. <entry><classname>Zend_Translate</classname> のみ</entry>
  70. <!-- TODO : to be translated -->
  71. <entry>
  72. Defines the adapter which will be used for the translation. This option
  73. can only be given when a new instance of
  74. <classname>Zend_Translate</classname> is created. When it is set
  75. afterwards, then it will be ignored
  76. </entry>
  77. <entry><emphasis>Must be set as it has no default value</emphasis></entry>
  78. </row>
  79. <row>
  80. <entry>clear</entry>
  81. <entry>すべて</entry>
  82. <entry>
  83. <constant>TRUE</constant> にすると、既に読み込んでいる翻訳を消去します。
  84. 新しい翻訳データを読み込む際に、
  85. 新しいインスタンスを作成する代わりに使用します。
  86. </entry>
  87. <entry><emphasis><constant>FALSE</constant></emphasis></entry>
  88. </row>
  89. <row>
  90. <entry>cache</entry>
  91. <entry>すべて</entry>
  92. <!-- TODO : to be translated -->
  93. <entry>
  94. Sets a cache for the translation adapter. This must be a instance of
  95. <classname>Zend_Cache_Core</classname>
  96. </entry>
  97. <entry>
  98. <emphasis>Per default no cache is set</emphasis>
  99. </entry>
  100. </row>
  101. <row>
  102. <entry>content</entry>
  103. <entry>all</entry>
  104. <entry>
  105. Sets the content for the translation adapter. This could be an array,
  106. a filename or a directory. Which type of content is supported depends
  107. on the used adapter
  108. </entry>
  109. <entry>
  110. <emphasis>The default value depends on the used adapter</emphasis>
  111. </entry>
  112. </row>
  113. <row>
  114. <entry>disableNotices</entry>
  115. <entry>すべて</entry>
  116. <entry>
  117. <constant>TRUE</constant> に設定すると、翻訳が存在しないことについての注意メッセージを無効にします。
  118. 実運用環境ではこのオプションを <constant>TRUE</constant> に設定しなければなりません。
  119. </entry>
  120. <entry><emphasis><constant>FALSE</constant></emphasis></entry>
  121. </row>
  122. <row>
  123. <entry>ignore</entry>
  124. <entry>すべて</entry>
  125. <entry>
  126. このプレフィックスで始まるすべてのディレクトリとファイルが、
  127. ファイルを探す際に無視されます。この値のデフォルトは
  128. <emphasis>'.'</emphasis>
  129. で、すべての隠しファイルを無視するようになります。
  130. この値を <emphasis>'tmp'</emphasis> に設定すると、たとえば 'tmpImages' や 'tmpFiles'
  131. といった名前のファイルやディレクトリ
  132. (とその配下のすべてのディレクトリ) を無視します。
  133. <!-- TODO : to be translated -->
  134. This option also accepts an array which can be used when
  135. you want to ignore more than one prefix.
  136. </entry>
  137. <entry><emphasis>.</emphasis></entry>
  138. </row>
  139. <row>
  140. <entry>log</entry>
  141. <entry>すべて</entry>
  142. <entry>
  143. 未翻訳のメッセージや注意が書き込まれる
  144. <classname>Zend_Log</classname> のインスタンス
  145. </entry>
  146. <entry><emphasis><constant>NULL</constant></emphasis></entry>
  147. </row>
  148. <row>
  149. <entry>logMessage</entry>
  150. <entry>すべて</entry>
  151. <entry>
  152. ログに書き込まれるメッセージ
  153. </entry>
  154. <entry>
  155. <emphasis>'%locale%': %message% 内で翻訳されていないメッセージ</emphasis>
  156. </entry>
  157. </row>
  158. <row>
  159. <entry>logPriority</entry>
  160. <entry>すべて</entry>
  161. <entry>ログにメッセージを書き込むために使用される優先度</entry>
  162. <entry>
  163. <emphasis>5</emphasis>
  164. </entry>
  165. </row>
  166. <row>
  167. <entry>logUntranslated</entry>
  168. <entry>すべて</entry>
  169. <entry>
  170. このオプションを <constant>TRUE</constant> に設定すると、翻訳できなかったすべてのメッセージ ID
  171. が添付のログに書き込まれます。
  172. </entry>
  173. <entry><emphasis><constant>FALSE</constant></emphasis></entry>
  174. </row>
  175. <row>
  176. <entry>reload</entry>
  177. <entry>すべて</entry>
  178. <entry>
  179. このオプションを <constant>TRUE</constant> に設定すると、ファイルはキャッシュに再読み込みされます。
  180. このオプションはキャッシュの再作成や、
  181. キャッシュが既に作成された後で、キャッシュ済みのデータに翻訳を追加するために
  182. 使えます。
  183. </entry>
  184. <entry><emphasis><constant>FALSE</constant></emphasis></entry>
  185. </row>
  186. <row>
  187. <entry>route</entry>
  188. <entry>すべて</entry>
  189. <!-- TODO : to be translated -->
  190. <entry>
  191. This option allows to use reroute from non existing translations to
  192. other languages. See the <link
  193. linkend="zend.translate.additional.rerouting">Rerouting
  194. Section</link> for details about this option.
  195. </entry>
  196. <entry><emphasis><constant>NULL</constant></emphasis></entry>
  197. </row>
  198. <row>
  199. <entry>scan</entry>
  200. <entry>すべて</entry>
  201. <entry>
  202. <constant>NULL</constant> にすると、ディレクトリ構造のスキャンを行いません。
  203. <constant>Zend_Translate::LOCALE_DIRECTORY</constant> にすると、
  204. ディレクトリからロケールを検出します。
  205. <constant>Zend_Translate::LOCALE_FILENAME</constant> にすると、
  206. ファイル名からロケールを検出します。
  207. 詳細は <link linkend="zend.translate.additional.detection">この章</link>
  208. を参照ください。
  209. </entry>
  210. <entry><emphasis><constant>NULL</constant></emphasis></entry>
  211. </row>
  212. <row>
  213. <entry>tag</entry>
  214. <entry>すべて</entry>
  215. <!-- TODO : to be translated -->
  216. <entry>
  217. Sets an individual tag which is used for the attached cache. Using this
  218. option allows to use and clear the cache for single instances. When this
  219. option is not set, the attached cache is used for all instances combined
  220. </entry>
  221. <entry><emphasis><classname>Zend_Translate</classname></emphasis></entry>
  222. </row>
  223. <row>
  224. <entry>delimiter</entry>
  225. <entry>Csv</entry>
  226. <entry>
  227. ソースと翻訳を区切る際に使用する記号を指定します。
  228. </entry>
  229. <entry><emphasis>;</emphasis></entry>
  230. </row>
  231. <row>
  232. <entry>enclosure</entry>
  233. <entry>Csv</entry>
  234. <entry>
  235. 値を囲むための文字を定義します。デフォルトはダブルクォートです。
  236. </entry>
  237. <entry><emphasis>"</emphasis></entry>
  238. </row>
  239. <row>
  240. <entry>length</entry>
  241. <entry>Csv</entry>
  242. <entry>
  243. CSV の行の長さの最大値を定義します。0 にすると、自動的に検出します。
  244. </entry>
  245. <entry><emphasis>0</emphasis></entry>
  246. </row>
  247. <row>
  248. <entry>useId</entry>
  249. <entry>Xliff 及び Tmx</entry>
  250. <entry>
  251. もしこのオプションを <constant>FALSE</constant> に設定すると、
  252. ソースの文字列はメッセージ Id として使われます。
  253. このオプションの既定値は <constant>TRUE</constant> で、
  254. それは, 翻訳単位要素からの Id がメッセージ Id として使われることを意味します。
  255. </entry>
  256. <entry><emphasis><constant>TRUE</constant></emphasis></entry>
  257. </row>
  258. </tbody>
  259. </tgroup>
  260. </table>
  261. <para>
  262. 自分でオプションを定義すれば、それをすべてのアダプタで使用できます。
  263. オプションを定義するには <methodname>setOptions()</methodname>
  264. メソッドを使用します。<methodname>setOptions()</methodname>
  265. には、指定したいオプションの配列を渡します。
  266. 指定したオプションがすでに存在する場合は、上書きされます。
  267. 存在しないオプションを指定した場合はアダプタは何もしないので、
  268. 必要となるであろうオプションはすべて指定しておけます。
  269. アダプタが使用している既存オプションは上書きされないことに注意してください。
  270. </para>
  271. <para>
  272. 現在設定されているオプションを取得するには <methodname>getOptions()</methodname>
  273. メソッドを使用します。<methodname>getOptions()</methodname>
  274. をパラメータなしでコールすると、すべてのオプションを返します。
  275. オプションのパラメータを指定した場合は、
  276. 特定のオプションの内容のみを返します。
  277. </para>
  278. </sect2>
  279. <sect2 id="zend.translate.additional.languages">
  280. <title>言語の処理</title>
  281. <para>
  282. 複数の言語を使用する場合に便利なメソッドを紹介します。
  283. </para>
  284. <para>
  285. <methodname>getLocale()</methodname> メソッドを使用すると、
  286. 実際に設定されている言語を取得できます。
  287. これは、<classname>Zend_Locale</classname>
  288. のインスタンスかロケール ID のいずれかとなります。
  289. </para>
  290. <para>
  291. <methodname>setLocale()</methodname> メソッドは、
  292. 翻訳用の新しい標準言語を設定します。
  293. これを使用すると、<methodname>translate()</methodname>
  294. に毎回オプションの言語パラメータを指定する必要がなくなります。
  295. 指定した言語が存在しない場合やその言語用の翻訳データがない場合、
  296. もし地域指定のない言語があれば <methodname>setLocale()</methodname>
  297. は代わりにそれを使用しようとします。つまり、たとえば
  298. <emphasis>en_US</emphasis> の場合だと代わりに <emphasis>en</emphasis>
  299. を使用するということです。これも見つからない場合は、
  300. 例外をスローします。
  301. </para>
  302. <para>
  303. <methodname>isAvailable()</methodname> メソッドは、
  304. 指定した言語が既に存在するかどうかを調べます。
  305. 指定した言語のデータが存在する場合に <constant>TRUE</constant>
  306. を返します。
  307. </para>
  308. <para>
  309. また、<methodname>getList()</methodname> メソッドを使用すると、
  310. そのアダプタに設定されている言語の一覧を配列で取得できます。
  311. </para>
  312. <example id="zend.translate.additional.languages.example">
  313. <title>アダプタの言語の処理</title>
  314. <programlisting language="php"><![CDATA[
  315. // 現在設定されている言語を返します
  316. $actual = $translate->getLocale();
  317. // 翻訳時にオプションのパラメータで言語を指定できます
  318. echo $translate->_("my_text", "fr");
  319. // あるいは新しい言語を設定することもできます
  320. $translate->setLocale("fr");
  321. echo $translate->_("my_text");
  322. // 基底言語を参照します
  323. // fr_CH は fr となります
  324. $translate->setLocale("fr_CH");
  325. echo $translate->_("my_text");
  326. // この言語が存在するかどうかを調べます
  327. if ($translate->isAvailable("fr")) {
  328. // 存在します
  329. }
  330. ]]></programlisting>
  331. </example>
  332. <sect3 id="zend.translate.additional.languages.automatic">
  333. <title>言語の自動処理</title>
  334. <para>
  335. 新しい翻訳ソースの追加を <methodname>addTranslation()</methodname>
  336. メソッドでのみ行っている場合は、自動ロケール
  337. '<emphasis>auto</emphasis>' あるいは '<emphasis>browser</emphasis>'
  338. を使用していれば <classname>Zend_Translate</classname>
  339. が環境にあわせて適切な言語を自動設定します。
  340. つまり、通常は <methodname>setLocale()</methodname> をコールする必要はありません。
  341. これは、自動ソース検出と組み合わせて使用しなければなりません。
  342. </para>
  343. <para>
  344. ユーザのブラウザやサーバの環境に応じて、最適なロケールを探します。
  345. 詳細は、以下の例を参照ください。
  346. </para>
  347. <example id="zend.translate.additional.languages.automatic.example">
  348. <title>言語の自動検出の動作例</title>
  349. <programlisting language="php"><![CDATA[
  350. // ブラウザから返される言語設定は次のようなものであると仮定します
  351. // HTTP_ACCEPT_LANGUAGE = "de_AT=1;fr=1;en_US=0.8";
  352. // 例 1:
  353. // 適切な言語がみつからないので、メッセージ ID を返します
  354. $translate = new Zend_Translate(
  355. array(
  356. 'adapter' => 'gettext',
  357. 'content' => 'my_it.mo',
  358. 'locale' => 'auto',
  359. 'scan' => Zend_Translate::LOCALE_FILENAME
  360. )
  361. );
  362. // 例 2:
  363. // 適切な言語は 'fr' となります
  364. $translate = new Zend_Translate(
  365. array(
  366. 'adapter' => 'gettext',
  367. 'content' => 'my_fr.mo',
  368. 'locale' => 'auto',
  369. 'scan' => Zend_Translate::LOCALE_FILENAME
  370. )
  371. );
  372. // 例 3:
  373. // 適切な言語は 'de' となります。'de_AT' の代替言語は 'de' だからです
  374. $translate = new Zend_Translate(
  375. array(
  376. 'adapter' => 'gettext',
  377. 'content' => 'my_de.mo',
  378. 'locale' => 'auto',
  379. 'scan' => Zend_Translate::LOCALE_FILENAME
  380. )
  381. );
  382. // 例 4:
  383. // 翻訳ソースとして 'it' を返し、自動設定を上書きします
  384. $translate = new Zend_Translate(
  385. array(
  386. 'adapter' => 'gettext',
  387. 'content' => 'my_it.mo',
  388. 'locale' => 'auto',
  389. 'scan' => Zend_Translate::LOCALE_FILENAME
  390. )
  391. );
  392. $translate->addTranslation(array('content' => 'my_ru.mo', 'locale' => 'ru'));
  393. $translate->setLocale('it_IT');
  394. ]]></programlisting>
  395. </example>
  396. <para>
  397. <methodname>setLocale()</methodname> メソッドで言語を手動設定したら、
  398. 自動設定機能は無効となります。
  399. </para>
  400. <para>
  401. 自動検出を再度有効にしたい場合は、<methodname>setLocale()</methodname>
  402. で言語として <emphasis>auto</emphasis>
  403. を指定します。これにより、<classname>Zend_Translate</classname>
  404. の自動検出機能が再度有効になります。
  405. </para>
  406. <para>
  407. Zend Framework 1.7.0 以降では、<classname>Zend_Translate</classname>
  408. はアプリケーション単位でのロケールの使用にも対応します。
  409. そのためには、<classname>Zend_Locale</classname>
  410. のインスタンスを以下のようにレジストリに登録します。
  411. このようにすれば、同じロケールを何度も使用したいときに
  412. 各インスタンスで毎回ロケールを設定する手間を省けます。
  413. </para>
  414. <programlisting language="php"><![CDATA[
  415. // 起動ファイルで
  416. $locale = new Zend_Locale();
  417. Zend_Registry::set('Zend_Locale', $locale);
  418. // リクエストされた言語が存在しない場合のデフォルト言語
  419. $defaultlanguage = 'en';
  420. // アプリケーションのどこかで
  421. $translate = new Zend_Translate(
  422. array('adapter' => 'gettext', 'content' => 'my_de.mo')
  423. );
  424. if (!$translate->isAvailable($locale->getLanguage())) {
  425. // 存在しない言語をリクエストされた場合はデフォルト設定を使用します
  426. $translate->setLocale($defaultlanguage);
  427. }
  428. $translate->getLocale();
  429. ]]></programlisting>
  430. </sect3>
  431. <sect3 id="zend.translate.additional.languages.territory">
  432. <title>言語として国を使用</title>
  433. <!-- TODO : to be translated -->
  434. <para>
  435. You can also use a country as locale parameter. This could be useful when you
  436. provide your user with flags, which represent the country in which he lives, and
  437. when he selects his flag, he would automatically get the default language for this
  438. country.
  439. </para>
  440. <para>
  441. For example, when the user selected <emphasis>US</emphasis> then you would get
  442. <emphasis>en_US</emphasis> in return as locale which is being used. This leads
  443. automatically to the language <emphasis>en</emphasis> which is the default language
  444. for the country <emphasis>US</emphasis>.
  445. </para>
  446. <programlisting language="php"><![CDATA[
  447. $translate = new Zend_Translate(
  448. array(
  449. 'adapter' => 'gettext',
  450. 'content' => 'my_de.mo',
  451. 'locale' => 'US'
  452. )
  453. );
  454. ]]></programlisting>
  455. <note>
  456. <title>Always uppercase countries</title>
  457. <para>
  458. Using this syntax you should always uppercase the input when you know that it's
  459. a country. The reason is that there are also languages which have the same
  460. letters as a country. Take for example <emphasis>om</emphasis>. You could expect
  461. to get <emphasis>ar_OM</emphasis> when you mean the country "Oman", or you could
  462. expect the language "Oromo" which is spoken in Kenia for example.
  463. </para>
  464. <para>
  465. As <classname>Zend_Translate</classname> is related to languages it will always
  466. use the language in this case. Therefor always uppercase the locale when you
  467. want it to be recognised as country.
  468. </para>
  469. </note>
  470. </sect3>
  471. </sect2>
  472. <sect2 id="zend.translate.additional.detection">
  473. <title>自動的なソース検出</title>
  474. <para>
  475. <classname>Zend_Translate</classname> は、翻訳ソースを自動的に検出できます。
  476. つまり、各ソースファイルを手動で宣言する必要はないということです。
  477. そんな作業は <classname>Zend_Translate</classname> に任せてしまい、
  478. ディレクトリ内からソースファイルを見つけさせることができるのです。
  479. </para>
  480. <note>
  481. <para>
  482. 自動的なソース検出機能は、Zend Framework バージョン 1.5
  483. 以降で使用可能です。
  484. </para>
  485. </note>
  486. <para>
  487. 使用法は、翻訳ソースを個別に登録していくのとほとんど同じですが、
  488. ひとつだけ違う点があります。ファイル名の代わりに、
  489. ソースを探すディレクトリを指定するのです。
  490. </para>
  491. <example id="zend.translate.additional.languages.directory.example">
  492. <title>ディレクトリを指定してソースを探す</title>
  493. <programlisting language="php"><![CDATA[
  494. // 以下のようなディレクトリ構造があることを想定しています
  495. // /language/
  496. // /language/login/login.tmx
  497. // /language/logout/logout.tmx
  498. // /language/error/loginerror.tmx
  499. // /language/error/logouterror.tmx
  500. $translate = new Zend_Translate(
  501. array('adapter' => 'tmx', 'content' => '/language')
  502. );
  503. ]]></programlisting>
  504. </example>
  505. <para>
  506. <classname>Zend_Translate</classname> は、指定したディレクトリだけでなく
  507. そのサブディレクトリすべてから翻訳ソースファイルを探します。
  508. おかげで、非常に簡単に使用できるようになっています。
  509. しかし、<classname>Zend_Translate</classname> では
  510. ソースを含まないファイルは無視します。
  511. また翻訳データの読み込みに失敗した場合もそのファイルを無視します。
  512. つまり、翻訳ソースが正しい形式であることと
  513. 読み込み可能であることを確認しておく必要があります。
  514. ファイルの形式が間違っていたり読み込みに失敗したりした場合でもエラーは発生しないからです。
  515. </para>
  516. <note>
  517. <para>
  518. ディレクトリ階層の深さやその中のファイルの数によっては、
  519. <classname>Zend_Translate</classname> の処理に長い時間がかかることもあります。
  520. </para>
  521. </note>
  522. <para>
  523. この例では <acronym>TMX</acronym> フォーマットを使用しており、言語の情報をソース内に含んでいます。
  524. しかし、他のフォーマットの多くは言語の情報をファイル内に持たせられません。
  525. そんなソースであっても自動検索できます。
  526. ただし、次に示す条件を満たす必要があります。
  527. </para>
  528. <sect3 id="zend.translate.additional.detection.directory">
  529. <title>ディレクトリ名からの言語の取得</title>
  530. <para>
  531. 自動的に言語を検出させる方法のひとつは、
  532. 言語名を表すディレクトリの配下にソースファイルを配置することです。
  533. これはもっとも簡単な方法であり、標準的な gettext
  534. の実装でも用いられています。
  535. </para>
  536. <para>
  537. <classname>Zend_Translate</classname> に '<property>scan</property>' オプションを指定すると、
  538. ディレクトリ名から言語を検出できます。
  539. 詳細は次の例を参照ください。
  540. </para>
  541. <example id="zend.translate.additional.detection.directory.example">
  542. <title>ディレクトリ名による言語の検出</title>
  543. <programlisting language="php"><![CDATA[
  544. // 以下のようなディレクトリ構造があることを想定しています
  545. // /language/
  546. // /language/de/login/login.mo
  547. // /language/de/error/loginerror.mo
  548. // /language/en/login/login.mo
  549. // /language/en/error/loginerror.mo
  550. $translate = new Zend_Translate(
  551. array(
  552. 'adapter' => 'gettext',
  553. 'content' => '/language',
  554. 'scan' => Zend_Translate::LOCALE_DIRECTORY
  555. )
  556. );
  557. ]]></programlisting>
  558. </example>
  559. <note>
  560. <para>
  561. これが動作するのは、
  562. ソースファイル中に言語情報を持たないフォーマットを使用している場合のみです。
  563. たとえば <acronym>TMX</acronym> などでこのオプションを使用しても、無視されます。
  564. また、このオプションを使用した場合は
  565. ファイル名による言語の自動検出は無視されます。
  566. </para>
  567. </note>
  568. <note>
  569. <para>
  570. 同じ構造のもとで複数のサブディレクトリがある場合は注意が必要です。
  571. たとえば <filename>/language/module/de/en/file.mo</filename>
  572. のような構造を考えてみましょう。
  573. このパスには、ロケールと検出されうる文字列が複数含まれています。
  574. <emphasis>de</emphasis> と <emphasis>en</emphasis> です。
  575. このような場合は、ファイル名による検出を用いることを推奨します。
  576. </para>
  577. </note>
  578. </sect3>
  579. <sect3 id="zend.translate.additional.detection.filename">
  580. <title>ファイル名からの言語の取得</title>
  581. <para>
  582. 言語を自動検出するもうひとつの方法は、特別なファイル名を使用することです。
  583. ファイル名を言語名そのものにするか、あるいはその一部に言語名を含めます。
  584. この方式を使用する場合は、初期化時に '<property>scan</property>'
  585. オプションを設定する必要があります。
  586. ファイル名のつけかたには、以下に示すようにいくつかの方法があります。
  587. </para>
  588. <example id="zend.translate.additional.detection.filename.example">
  589. <title>ファイル名からの言語の取得</title>
  590. <programlisting language="php"><![CDATA[
  591. // 以下のようなディレクトリ構造があることを想定しています
  592. // /language/
  593. // /language/login/login_en.mo
  594. // /language/login/login_de.mo
  595. // /language/error/loginerror_en.mo
  596. // /language/error/loginerror_de.mo
  597. $translate = new Zend_Translate(
  598. array(
  599. 'adapter' => 'gettext',
  600. 'content' => '/language',
  601. 'scan' => Zend_Translate::LOCALE_FILENAME
  602. )
  603. );
  604. ]]></programlisting>
  605. </example>
  606. <sect4 id="zend.translate.additional.detection.filename.complete">
  607. <title>ファイル名全体</title>
  608. <para>
  609. 言語名そのものをファイル名にしてしまうのは一番シンプルな方法ですが、
  610. 同一ディレクトリにソースファイルがひとつだけの場合にしか使用できません。
  611. </para>
  612. <programlisting language="txt"><![CDATA[
  613. /languages/
  614. /languages/en.mo
  615. /languages/de.mo
  616. /languages/es.mo
  617. ]]></programlisting>
  618. </sect4>
  619. <sect4 id="zend.translate.additional.detection.filename.extension">
  620. <title>ファイルの拡張子</title>
  621. <para>
  622. もうひとつのシンプルな方法としては、
  623. ファイル名の拡張子を用いて言語を検出させるというものがあります。
  624. しかしこの方法にも問題があり、本来の拡張子が何であったのかがわからなくなります。
  625. </para>
  626. <programlisting language="txt"><![CDATA[
  627. /languages/
  628. /languages/view.en
  629. /languages/view.de
  630. /languages/view.es
  631. ]]></programlisting>
  632. </sect4>
  633. <sect4 id="zend.translate.additional.detection.filename.token">
  634. <title>ファイル名の一部</title>
  635. <para>
  636. <classname>Zend_Translate</classname> は、
  637. ファイル名の一部に言語名が含まれている場合にもそれを検出できます。
  638. しかし、この方式を使用する場合は言語名をトークンで分割する必要があります。
  639. トークンとしてサポートされているのは、小数点 '.' かアンダーライン '_'、
  640. あるいはハイフン '=' のいずれかです。
  641. </para>
  642. <programlisting language="txt"><![CDATA[
  643. /languages/
  644. /languages/view_en.mo -> 英語となります
  645. /languages/view_de.mo -> ドイツ語となります
  646. /languages/view_it.mo -> イタリア語となります
  647. ]]></programlisting>
  648. <para>
  649. ロケールとして判断できる部分が複数あった場合は、
  650. 最初に見つかったものを使用します。詳細は次の例でご確認ください。
  651. </para>
  652. <programlisting language="txt"><![CDATA[
  653. /languages/
  654. /languages/view_en_de.mo -> 英語となります
  655. /languages/view_en_es.mo -> 英語となり、最初のファイルを上書きします
  656. /languages/view_it_it.mo -> イタリア語となります
  657. ]]></programlisting>
  658. <para>
  659. 3 種類のトークンのどれを用いても言語を検出できます。
  660. まず最初に使用するのが小数点 '.'、次に使用するのがアンダーライン
  661. '_'、そして最後に使用するのがハイフン '-' となります。
  662. ひとつのファイル名の中に複数のトークンが用いられている場合、
  663. トークンの優先順位の順に調べて最初に見つかったものを使用します。
  664. 詳細は次の例でご確認ください。
  665. </para>
  666. <programlisting language="txt"><![CDATA[
  667. /languages/
  668. /languages/view_en-it.mo -> 英語となります。'_' のほうが '-' より優先されるからです
  669. /languages/view-en_it.mo -> イタリア語となります。'_' のほうが '-' より優先されるからです
  670. /languages/view_en.it.mo -> イタリア語となります。'.' のほうが '_' より優先されるからです
  671. ]]></programlisting>
  672. </sect4>
  673. </sect3>
  674. <sect3 id="zend.translate.additional.detection.ignore">
  675. <title>特定のファイルやディレクトリを無視</title>
  676. <!-- TODO : to be translated -->
  677. <para>
  678. Sometimes it is useful to exclude files or even directories from being added
  679. automatically. Therefor you can use the <property>ignore</property> option which
  680. accepts 3 possible usages.
  681. </para>
  682. <sect4 id="zend.translate.additional.detection.ignore.string">
  683. <title>Ignore a special directory or file</title>
  684. <para>
  685. Per default <classname>Zend_Translate</classname> is set to ignore all
  686. files and directories beginning with
  687. <emphasis>'<filename>/.</filename>'</emphasis>. This means that
  688. all <acronym>SVN</acronym> files will be ignored.
  689. </para>
  690. <para>
  691. You can set your own syntax by giving a string for the
  692. <property>ignore</property> option. The directory separator will be attached
  693. automatically and has to be omitted.
  694. </para>
  695. <programlisting language="php"><![CDATA[
  696. $options = array('ignore' => 'test');
  697. $translate = new Zend_Translate(
  698. array(
  699. 'adapter' => $adapter,
  700. 'content' => $content,
  701. 'locale' => $locale,
  702. 'ignore' => 'test'
  703. )
  704. );
  705. ]]></programlisting>
  706. <para>
  707. The above example will ignore all files and directories beginning with
  708. <emphasis>test</emphasis>. This means for example
  709. <filename>/test/en.mo</filename>, <filename>/testing/en.mo</filename> and
  710. <filename>/dir/test_en.mo</filename>. But it would still add
  711. <filename>/mytest/en.mo</filename> or <filename>/dir/atest.mo</filename>.
  712. </para>
  713. <note>
  714. <title>Prevent SVN files from being searched</title>
  715. <para>
  716. When you set this option, then the default
  717. <emphasis>'<filename>/.</filename>'</emphasis> will
  718. be erased. This means that <classname>Zend_Translate</classname> will then
  719. add all files from the hidden <acronym>SVN</acronym> directories. When you
  720. are working with <acronym>SVN</acronym>, then you should use the array
  721. syntax described in the next section.
  722. </para>
  723. </note>
  724. </sect4>
  725. <sect4 id="zend.translate.additional.detection.ignore.array.files">
  726. <title>Ignore several directories or files</title>
  727. <para>
  728. You can also ignore several files and directories. Instead of a string,
  729. you can simply give an array with all wished names which will be ignored.
  730. </para>
  731. <programlisting language="php"><![CDATA[
  732. $options = array('ignore' => array('.', 'test', 'old'));
  733. $translate = new Zend_Translate(
  734. array(
  735. 'adapter' => $adapter,
  736. 'content' => $content,
  737. 'locale' => $locale,
  738. 'ignore' => array('.', 'test', 'old')
  739. )
  740. );
  741. ]]></programlisting>
  742. <para>
  743. In the above case all 3 syntax will be ignored. But still they have to
  744. begin with the syntax to be detected and ignored.
  745. </para>
  746. </sect4>
  747. <sect4 id="zend.translate.additional.detection.ignore.array.names">
  748. <title>Ignore specific names</title>
  749. <para>
  750. To ignore files and directories which are not beginning with a defined syntax
  751. but have a special syntax anywhere within their name you can use a regular
  752. expression.
  753. </para>
  754. <para>
  755. To use a regular expression the array key of the <property>ignore</property>
  756. option has to begin with <emphasis>regex</emphasis>.
  757. </para>
  758. <programlisting language="php"><![CDATA[
  759. $options = array(
  760. 'ignore' => array(
  761. 'regex' => '/test/u',
  762. 'regex_2' => '/deleted$/u'
  763. )
  764. );
  765. $translate = new Zend_Translate(
  766. array(
  767. 'adapter' => $adapter,
  768. 'content' => $content,
  769. 'locale' => $locale,
  770. 'ignore' => array('regex' => '/test/u', 'regex_2' => '/deleted$/u')
  771. )
  772. );
  773. ]]></programlisting>
  774. <para>
  775. In the above case we defined 2 regular expressions. The files and directories
  776. will always being searched with all given regular expressions. In our example
  777. this means that any files which contains <emphasis>test</emphasis> anywhere in
  778. their name will be ignored. Additionally all files and directories which end
  779. with <emphasis>deleted</emphasis> will not be added as translation.
  780. </para>
  781. </sect4>
  782. </sect3>
  783. </sect2>
  784. <sect2 id="zend.translate.additional.rerouting">
  785. <title>Routing for translations</title>
  786. <para>
  787. Not every message ID can be translated. But sometimes is can be useful to output the
  788. translation from another language instead of returning the message ID itself. You can
  789. archive this by using the <property>route</property> option.
  790. </para>
  791. <para>
  792. You can add one route for every language. See the following example:
  793. </para>
  794. <programlisting language="php"><![CDATA[
  795. $translate = new Zend_Translate(
  796. array(
  797. 'adapter' => $adapter,
  798. 'content' => $content,
  799. 'locale' => $locale,
  800. 'route' => array('fr' => 'en', 'de' => 'fr')
  801. )
  802. );
  803. ]]></programlisting>
  804. <para>
  805. The above returns a english translation for all messages which can not be translated to
  806. french. And it returns a french translation for all messages which can not be translated
  807. to german. It will even return an english translation for all messages which can wether
  808. be translated to german nor to french. So you can even define a complete translation
  809. chain.
  810. </para>
  811. <para>
  812. This feature seems ot be interesting for anyone. But be aware that returning
  813. translations for wrong or other languages can be problematic when the user does not
  814. understand this language. So you should always use this feature sparingly.
  815. </para>
  816. </sect2>
  817. <sect2 id="zend.translate.additional.combination">
  818. <title>Combining multiple translation sources</title>
  819. <para>
  820. When you are working with multiple translations you may come into a situation where you
  821. want to use different source types. For example the resource files which are provided
  822. by the framework and your own translations which are available by using the gettext
  823. adapter.
  824. </para>
  825. <para>
  826. By combining multiple translation adapters you can use them within one instance. See
  827. the following example:
  828. </para>
  829. <programlisting language="php"><![CDATA[
  830. $translate = new Zend_Translate(
  831. array(
  832. 'adapter' => 'gettext',
  833. 'content' => '\path\to\translation.mo',
  834. 'locale' => 'en'
  835. )
  836. );
  837. $translate_second = new Zend_Translate(
  838. array(
  839. 'adapter' => 'array',
  840. 'content' => '\resources\languages\en\Zend_Validate.php',
  841. 'locale' => 'en'
  842. )
  843. );
  844. $translate->addTranslation(array('content' => $translate_second));
  845. ]]></programlisting>
  846. <para>
  847. Now the first instance holds all translations from the second instance and you can use
  848. it within the application even if you used different source types.
  849. </para>
  850. <note>
  851. <title>Memory savings</title>
  852. <para>
  853. As you may have noted the second instance is no longer used as soon as it has been
  854. added to the first instance. To save some memory you may want to unset it.
  855. </para>
  856. </note>
  857. <para>
  858. When you are scanning for directories you may additionally want to use only one defined
  859. language. The predefined resources for example are available in more than 10 languages.
  860. But your application is not available in all of those language. Therefor you can also
  861. add only one language from the second adapter.
  862. </para>
  863. <programlisting language="php"><![CDATA[
  864. $translate->addTranslation(
  865. array(
  866. 'content' => $translate_second,
  867. 'locale' => 'en'
  868. )
  869. );
  870. ]]></programlisting>
  871. <para>
  872. This allows you still to scan through the directories and still add only those languages
  873. which are relevant for your application.
  874. </para>
  875. </sect2>
  876. <sect2 id="zend.translate.additional.istranslated">
  877. <title>翻訳の確認</title>
  878. <para>
  879. 通常は、テキストが翻訳されているかどうかを気にすることはありません。
  880. しかし、そのテキストが翻訳されているかどうかを、ソースコードから調べたいこともあるでしょう。
  881. そんな場合に使用するメソッドが <methodname>isTranslated()</methodname> です。
  882. </para>
  883. <para>
  884. <methodname>isTranslated($messageId, $original = false, $locale = null)</methodname>
  885. の最初のパラメータには、翻訳されているかどうかを調べたいテキストを指定します。
  886. また、オプションの三番目のパラメータには、翻訳を調べたいロケールを指定します。
  887. オプションの二番目のパラメータで指定するのは、
  888. その言語に完全に一致した翻訳があるのか、あるいはもう少し広い範囲の翻訳を使用するのかという内容です。
  889. たとえば、あるテキストについて 'en' の翻訳はあるが 'en_US' の翻訳はないといった場合、
  890. 通常は 'en' の翻訳を取得することになるでしょう。しかし <varname>$original</varname>
  891. を <constant>TRUE</constant> にしておくと、このような場合は <methodname>isTranslated()</methodname> は <constant>FALSE</constant> を返すようになります。
  892. </para>
  893. <example id="zend.translate.additional.istranslated.example">
  894. <title>テキストの翻訳が存在するかどうかの確認</title>
  895. <programlisting language="php"><![CDATA[
  896. $english = array(
  897. 'message1' => 'Nachricht 1',
  898. 'message2' => 'Nachricht 2',
  899. 'message3' => 'Nachricht 3');
  900. $translate = new Zend_Translate(
  901. array(
  902. 'adapter' => 'array',
  903. 'content' => $english,
  904. 'locale' => 'de_AT'
  905. )
  906. );
  907. if ($translate->isTranslated('message1')) {
  908. print "'message1' の翻訳が存在します";
  909. }
  910. if (!($translate->isTranslated('message1', true, 'de'))) {
  911. print "'message1' は 'de' に翻訳することはできません。"
  912. . "'de_AT' 用の翻訳しかありません";
  913. }
  914. if ($translate->isTranslated('message1', false, 'de')) {
  915. print "'message1' は 'de_AT' に翻訳できます。もし存在しない場合は代替として 'de' を使用できます";
  916. }
  917. ]]></programlisting>
  918. </example>
  919. </sect2>
  920. <sect2 id="zend.translate.additional.logging">
  921. <title>見つからなかった翻訳をログに記録する方法</title>
  922. <para>
  923. 大規模なサイトを管理していたり翻訳ファイルを手作業で作ったりしている場合に、
  924. うまく翻訳ができないメッセージに悩まされることがよくあるでしょう。
  925. <classname>Zend_Translate</classname> を使っていれば、こんなときにも簡単な解決方法があります。
  926. </para>
  927. <para>
  928. そのためには、次の 2、3 のステップに従う必要があります。
  929. まず <classname>Zend_Log</classname> のインスタンスを作成します。
  930. そして、そのインスタンスを <classname>Zend_Translate</classname> にアタッチします。
  931. 次の例を参照ください。
  932. </para>
  933. <example id="zend.translate.additional.logging.example">
  934. <title>翻訳のログ出力</title>
  935. <programlisting language="php"><![CDATA[
  936. $translate = new Zend_Translate(
  937. array(
  938. 'adapter' => 'gettext',
  939. 'content' => $path,
  940. 'locale' => 'de'
  941. )
  942. );
  943. // log のインスタンスを作成します
  944. $writer = new Zend_Log_Writer_Stream('/path/to/file.log');
  945. $log = new Zend_Log($writer);
  946. // それを translation インスタンスにアタッチします
  947. $translate->setOptions(
  948. array(
  949. 'log' => $log,
  950. 'logUntranslated' => true
  951. )
  952. );
  953. $translate->translate('unknown string');
  954. ]]></programlisting>
  955. </example>
  956. <para>
  957. これで、<emphasis>Untranslated message within 'de': unknown string</emphasis>
  958. のような注意メッセージがログに記録されるようになるでしょう。
  959. </para>
  960. <note>
  961. <para>
  962. 翻訳が見つからなかったものがすべてログに記録されることに注意しましょう。
  963. つまり、サポートしていない言語でのリクエストがユーザからあった場合は、
  964. すべての翻訳がログに記録されるということです。また、
  965. 翻訳不能なメッセージへのリクエストは毎回ログに記録されます。
  966. つまり、100 人の人が同じ翻訳をリクエストしたら、
  967. 100 件のログが記録されるというわけです。
  968. </para>
  969. </note>
  970. <para>
  971. この機能はメッセージのログ出力だけに使うことはできず、
  972. 同時にこの「未翻訳」メッセージを空の翻訳ファイルにアタッチします。
  973. これを記録するには、好みの書式で書き出して先頭の "Untranslated message"
  974. を除去するログライターを自作しなければなりません。
  975. </para>
  976. <para>
  977. '<property>logMessage</property>' オプションを設定すると、
  978. 独自のログメッセージを使用できます。
  979. '<emphasis>%message%</emphasis>' トークンはログメッセージ内で messageId
  980. に置き換えられ、'<emphasis>%locale%</emphasis>' トークンは
  981. 要求されたロケールに置き換えられます。
  982. ログメッセージを自分で定義する方法については次の例を参照ください。
  983. </para>
  984. <example id="zend.translate.additional.logging.example2">
  985. <title>自分で定義したログメッセージ</title>
  986. <programlisting language="php"><![CDATA[
  987. $translate = new Zend_Translate(
  988. array(
  989. 'adapter' => 'gettext',
  990. 'content' => $path,
  991. 'locale' => 'de'
  992. )
  993. );
  994. // log のインスタンスを作成します
  995. $writer = new Zend_Log_Writer_Stream('/path/to/file.log');
  996. $log = new Zend_Log($writer);
  997. // それを translation インスタンスにアタッチします
  998. $translate->setOptions(
  999. array(
  1000. 'log' => $log,
  1001. 'logMessage' => "Missing '%message%' within locale '%locale%'",
  1002. 'logUntranslated' => true
  1003. )
  1004. );
  1005. $translate->translate('unknown string');
  1006. ]]></programlisting>
  1007. </example>
  1008. <!-- TODO : to be translated -->
  1009. <para>
  1010. Additionally you are also able to change the priority which is used to write the message
  1011. into the log. Per default the priority <emphasis>Zend_Log::NOTICE</emphasis> is used.
  1012. It equals with <emphasis>5</emphasis>. When you want to change the priority you can use
  1013. any of <classname>Zend_Log</classname>'s priorities. See the following example:
  1014. </para>
  1015. <example id="zend.translate.additional.logging.example3">
  1016. <title>Self defined log priority</title>
  1017. <programlisting language="php"><![CDATA[
  1018. // Create a log instance
  1019. $writer = new Zend_Log_Writer_Stream('/path/to/file.log');
  1020. $log = new Zend_Log($writer);
  1021. $translate = new Zend_Translate(
  1022. array(
  1023. 'adapter' => 'gettext',
  1024. 'content' => $path,
  1025. 'locale' => 'de',
  1026. 'log' => $log,
  1027. 'logMessage' => "Missing '%message%' within locale '%locale%'",
  1028. 'logPriority' => Zend_Log::ALERT,
  1029. 'logUntranslated' => true
  1030. )
  1031. );
  1032. $translate->translate('unknown string');
  1033. ]]></programlisting>
  1034. </example>
  1035. </sect2>
  1036. <sect2 id="zend.translate.additional.sourcedata">
  1037. <title>ソースデータへのアクセス</title>
  1038. <para>
  1039. 時には、翻訳前のソースデータにアクセスしたいこともあるでしょう。
  1040. そんなときのために2つのメソッドを用意しています。
  1041. </para>
  1042. <para>
  1043. <methodname>getMessageIds($locale = null)</methodname> メソッドは、
  1044. すべてのメッセージの ID を配列で返します。
  1045. </para>
  1046. <!-- TODO : to be translated -->
  1047. <para>
  1048. When you want to know the message ID for a given translation then you can use the
  1049. <methodname>getMessageId()</methodname> method.
  1050. </para>
  1051. <para>
  1052. そして、<methodname>getMessages($locale = null)</methodname> メソッドは
  1053. 翻訳前のソースを配列で返します。メッセージ ID がキー、
  1054. それに対応するデータが値となります。
  1055. </para>
  1056. <para>
  1057. どちらのメソッドについても、オプションのパラメータ <varname>$locale</varname>
  1058. を指定できます。これを指定すると、
  1059. 指定した言語についての翻訳情報を返します。
  1060. このパラメータを省略した場合は、実際に設定されている言語を対象とします。
  1061. 注意してほしいのは、普通はすべての言語ですべての翻訳が存在すべきであるということです。
  1062. つまり、通常はこのパラメータを指定する必要はないはずです。
  1063. </para>
  1064. <para>
  1065. さらに、<methodname>getMessages()</methodname> メソッドで翻訳辞書全体を返すこともできます。
  1066. その際には、疑似ロケール 'all' を指定します。
  1067. これを指定すると、追加された各ロケールについてのすべての翻訳データを返します。
  1068. </para>
  1069. <note>
  1070. <para>
  1071. 注意: 追加されているロケールの数や翻訳データの量によっては、
  1072. 返される配列は <emphasis>非常に大きな</emphasis>
  1073. ものとなります。
  1074. </para>
  1075. </note>
  1076. <example id="zend.translate.additional.sourcedata.example">
  1077. <title>アダプタでの言語の処理</title>
  1078. <programlisting language="php"><![CDATA[
  1079. // すべてのメッセージ ID を返します
  1080. $messageIds = $translate->getMessageIds();
  1081. print_r($messageIds);
  1082. // あるいは指定した言語の ID を返します
  1083. $messageIds = $translate->getMessageIds('en_US');
  1084. print_r($messageIds);
  1085. // すべての翻訳データを返します
  1086. $source = $translate->getMessages();
  1087. print_r($source);
  1088. ]]></programlisting>
  1089. </example>
  1090. </sect2>
  1091. </sect1>
  1092. <!--
  1093. vim:se ts=4 sw=4 et:
  1094. -->