<?xml version="1.0" encoding="Shift_JIS"?>
<!--
  Copyright 2003-2004 The Apache Software Foundation.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

  $Id: MessageTool.xml,v 1.6 2005/03/19 07:58:22 nekop Exp $
-->
<document>

    <properties>
        <title>MessageTool</title>
        <author email="sidler@apache.org">Gabriel Sidler</author>
        <projectfile>xdocs-ja/struts/menu.xml</projectfile>
        <translator email="shinobu@ieee.org">Shinobu Kawai</translator>
        <translator email="nekop@programmers.jp">木村 貴由</translator>
        <original>MessageTool</original>
        </properties>

    <body>

    <section name="MessageTool Reference Documentation" alias="MessageTool リファレンスドキュメント">

        <primary>
        <p>
        The MessageTool is used to render internationalized message strings. Source
        of the strings are the message resource bundles of the Struts framework. The
        following methods operate on these message resources.
        </p>
        </primary>
        <p>
        MessageTool は国際化されたメッセージの表示に使用します。
        文字列は Struts フレームワークのメッセージリソースバンドルから取得されます。
        メッセージリソースを操作する以下のメソッドが利用できます。
        </p>

        <toolinfo>
            <version>@@@version@@@, @@@date@@@</version>
            <clazz>org.apache.velocity.tools.struts.MessageTool</clazz>
            <name>$text</name>
            <author email="sidler@teamup.com">Gabriel Sidler</author>
            <config-example>&lt;tool&gt;
  &lt;key&gt;text&lt;/key&gt;
  &lt;scope&gt;request&lt;/scope&gt;
  &lt;class&gt;org.apache.velocity.tools.struts.MessageTool&lt;/class&gt;
&lt;/tool&gt;</config-example>
        </toolinfo>

        <methods/>

    </section>

    <section name="get()">
        <primary>
        <method name="get()">

            <abstract>
                Looks up and returns the localized message for the specified key.
            </abstract>

            <signature>
                String get(String key)
            </signature>

            <signature>
                String get(String key, String bundle)
            </signature>

            <signature>
                String get(String key, Object args[])
            </signature>

            <signature>
                String get(String key, String bundle, Object args[])
            </signature>

            <signature>
                String get(String key, List args)
            </signature>

            <signature>
                String get(String key, String bundle, List args)
            </signature>

            <parameters>
                <parameter name="key">
                    Message key.
                </parameter>

                <parameter name="bundle">
                    The (non-default) message-resources bundle that holds the message.
                </parameter>

                <parameter name="args">
                    Replacement parameters for this message. Typically
                    an array of Strings or a List of Strings (but any
                    Object with a reasonable <code>toString()</code>
                    method can be used).
                </parameter>
            </parameters>

            <returns>
                The localized message for the specified key. Returns null if no
                message exists for the key passed.
            </returns>

            <see>
                Struts user's guide on
                <a href="http://jakarta.apache.org/struts/userGuide/building_view.html#i18n">
                Internationalized Messages</a>.
            </see>

            <description>
                <p>The user's locale is consulted to determine the language of the
                message. The third, fourth, fifth and sixth signatures take a list
                of up to five replacement parameters. The third and fourth signatures
                are provided for compatibility with existing applications. The fifth and
                sixth signatures are Velocity-friendlier.</p>

<p>Assuming that the message resource files contain the following messages:</p>
<sourcecode>title=Welcome to Velocity for Struts
test=This message has five replacement parameters: {0}, {1}, {2}, {3}, {4}</sourcecode>

<p>then the following Velocity script:</p>
<sourcecode>$text.get("title")
$text.title
$text.get("test", ["bear", "wolf", "tiger"])</sourcecode>

<p>produces this output:</p>
<sourcecode>Welcome to Velocity for Struts
Welcome to Velocity for Struts
This message has five replacement parameters: bear, wolf, tiger, {3}, {4}</sourcecode>
            </description>

        </method>
        </primary>
        <method name="get()">

            <abstract>
                指定されたキーに対応する地域化されたメッセージを検索し返却します。
            </abstract>

            <signature>
                String get(String key)
            </signature>

            <signature>
                String get(String key, String bundle)
            </signature>

            <signature>
                String get(String key, Object args[])
            </signature>

            <signature>
                String get(String key, String bundle, Object args[])
            </signature>

            <signature>
                String get(String key, List args)
            </signature>

            <signature>
                String get(String key, String bundle, List args)
            </signature>

            <parameters>
                <parameter name="key">
                    メッセージのキー。
                </parameter>

                <parameter name="bundle">
                    メッセージを保持する(デフォルトではない)メッセージリソースバンドル。
                </parameter>

                <parameter name="args">
                    メッセージの置換パラメータ。
                    通常は String の配列、もしくは String を格納した List
                    (String以外でも、適切な <code>toString()</code>
                    メソッドが実装されているオブジェクトなら利用可能) 。
                </parameter>
            </parameters>

            <returns>
                指定されたキーに対応する地域化されたメッセージ。
                キーに対応するメッセージが存在しない場合には null を返却します。
            </returns>

            <see>
                Struts ユーザガイドの
                <a href="http://jakarta.apache.org/struts/userGuide/building_view.html#i18n">
                Internationalized Messages</a>。
            </see>

            <description>
                <p>使用するメッセージの言語を決定するため、ユーザのロカールが参照されます。
                3つめ、4つめ、5つめ、6つめのメソッドシグニチャは5つまで置換パラメータを受け取ることが出来ます。
                3つめ、4つめのメソッドシグニチャは、既存のアプリケーションとの互換性を提供します。
                5つめ、6つめのメソッドシグニチャはよりVelocityで使いやすいものです。</p>

<p>メッセージリソースファイルが以下のメッセージを含んでいる場合:</p>
<sourcecode>title=Velocity for Strutsへようこそ
test=このメッセージは5つの置換パラメータがあります: {0}, {1}, {2}, {3}, {4}</sourcecode>

<p>以下の Velocity スクリプトは:</p>
<sourcecode>$text.get("title")
$text.title
$text.get("test", ["bear", "wolf", "tiger"])</sourcecode>

<p>このように出力されます:</p>
<sourcecode>Velocity for Strutsへようこそ
Velocity for Strutsへようこそ
このメッセージは5つの置換パラメータがあります: bear, wolf, tiger, {3}, {4}</sourcecode>
            </description>

        </method>
    </section>

    <section name="exists()">
        <primary>
        <method name="exists()">

            <abstract>
                Checks if a message string for a specified message key exists
                for the user's locale.
            </abstract>

            <signature>
                boolean exists(String key)
            </signature>

            <signature>
                boolean exists(String key, String bundle)
            </signature>

            <parameters>
                <parameter name="key">
                    Message key.
                </parameter>

                <parameter name="bundle">
                    The (non-default) message-resources bundle that holds the message.
                </parameter>
            </parameters>

            <returns>
                <code>true</code> if a message string for the specified message
                key exists for the user's locale. <code>false</code> otherwise.
            </returns>

            <description>
<sourcecode>$text.exists("title")</sourcecode>
            </description>

        </method>
        </primary>
        <method name="exists()">

            <abstract>
                ユーザのロカールで、指定されたキーに対するメッセージが存在するかどうかをチェックします。
            </abstract>

            <signature>
                boolean exists(String key)
            </signature>

            <signature>
                boolean exists(String key, String bundle)
            </signature>

            <parameters>
                <parameter name="key">
                    メッセージのキー。
                </parameter>

                <parameter name="bundle">
                    メッセージを保持する(デフォルトではない)メッセージリソースバンドル。
                </parameter>
            </parameters>

            <returns>
                ユーザのロカールで、メッセージのキーが存在する場合 <code>true</code> 。そうではない場合、 <code>false</code> 。
            </returns>

            <description>
<sourcecode>$text.exists("title")</sourcecode>
            </description>

        </method>
    </section>

    <section name="getLocale()">
        <primary>
        <method name="getLocale()">

            <abstract>
                Returns the user's locale. If a locale is not found, the default
                locale is returned (deprecated - will be removed in VelocityTools 1.2).
            </abstract>

            <signature>
                Locale getLocale()
            </signature>

            <returns>
                An instance of class <code>java.util.Locale</code>.
            </returns>

            <description>
<sourcecode>$text.getLocale()
$text.locale
$text.getLocale().getDisplayLanguage()</sourcecode>

<p>produces:</p>
<sourcecode>en
en
English</sourcecode>

<p>The returned object of class <code>Locale</code> is automatically rendered by Velocity by
calling its <code>toString()</code> method. The third example calls method
<code>getDisplayLanguage()</code> of class <code>Locale</code></p>

            </description>

        </method>
        </primary>
        <method name="getLocale()">

            <abstract>
                ユーザのロカールを返却します。
                ロカールが見つからなかった場合、デフォルトロカールが返却されます。
                (推奨されていません。 - VelocityTools 1.2では削除されます。)
            </abstract>

            <signature>
                Locale getLocale()
            </signature>

            <returns>
                <code>java.util.Locale</code> クラスのインスタンス。
            </returns>

            <description>
<sourcecode>$text.getLocale()
$text.locale
$text.getLocale().getDisplayLanguage()</sourcecode>

<p>は次を生成します:</p>
<sourcecode>ja
ja
日本語</sourcecode>

<p>返却される <code>Locale</code> クラスのオブジェクトは、 Velocity により <code>toString()</code> メソッドが呼び出され、自動的にレンダリングされます。
3つめの例は <code>Locale</code> クラスの <code>getDisplayLanguage()</code> を呼び出しています。</p>

            </description>

        </method>
    </section>


 </body>
</document>

