mazz.i18n.ant
Class I18NMessageAntTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.apache.tools.ant.taskdefs.Echo
              extended by mazz.i18n.ant.I18NMessageAntTask

@I18NResourceBundle(baseName="i18n-anttask-messages",
                    defaultLocale="en")
public class I18NMessageAntTask
extends org.apache.tools.ant.taskdefs.Echo

An ANT task to retrieve an i18n message. A typical usage of this ANT task is as follows:

<taskdef name="i18n-msg" classpathref="i18nlog-jar.classpath" classname="mazz.i18n.ant.I18NMessageAntTask" /> <i18n-msg message="my.bundle.key" <!-- the message key that identifies the message in the bundle --> bundle="my-messages" <!-- where the messages are found; if not specified, 'messages' is the default --> locale="de" <!-- explicitly defines what message translation to retrieve; defaults to the VM default locale --> property="prop.name"> <!-- if defined, the message is stored in this property; otherwise it is echoed --> <arg value="first arg" /> <!-- replaces {0} in the message --> <arg value="second arg" /> <!-- replaces {1} in the message --> <i18n-msg>
The classpathref must also point to the resource bundle files that contain the i18n messages. Note that this task extends the echo task, so all attributes for that task are also allowed. The only difference is the message attribute is not the message itself, but rather the resource bundle message key.

Version:
$Revision: 1.2 $
Author:
John Mazzitelli

Nested Class Summary
 class I18NMessageAntTask.Arg
          The inner <arg> element that defines the replacement strings for the localized message placeholders (for example: {0}, {1}).
 
Nested classes/interfaces inherited from class org.apache.tools.ant.taskdefs.Echo
org.apache.tools.ant.taskdefs.Echo.EchoLevel
 
Field Summary
 
Fields inherited from class org.apache.tools.ant.taskdefs.Echo
append, file, logLevel, message
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
I18NMessageAntTask()
           
 
Method Summary
 I18NMessageAntTask.Arg createArg()
          Creates a new argument that is used to define the values of the localized message placeholders (such as {0}).
 void execute()
           
 void setBundle(Msg.BundleBaseName bundle)
          Sets the base bundle name which identifies the resource bundle where the message can be found.
 void setLocale(java.util.Locale locale)
          Sets the locale of the message to be retrieved.
 void setProperty(java.lang.String property)
          Sets the name of the property whose value will be set to the localized message string.
 
Methods inherited from class org.apache.tools.ant.taskdefs.Echo
addText, setAppend, setFile, setLevel, setMessage
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

I18NMessageAntTask

public I18NMessageAntTask()
Method Detail

setBundle

public void setBundle(Msg.BundleBaseName bundle)
Sets the base bundle name which identifies the resource bundle where the message can be found.

Parameters:
bundle -

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale of the message to be retrieved. If not defined, this will default to the VM's default locale.

Parameters:
locale -

setProperty

public void setProperty(java.lang.String property)
Sets the name of the property whose value will be set to the localized message string. If this is not defined, the message is simply echoed.

Parameters:
property -

createArg

public I18NMessageAntTask.Arg createArg()
Creates a new argument that is used to define the values of the localized message placeholders (such as {0}).

Returns:
new arg

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Overrides:
execute in class org.apache.tools.ant.taskdefs.Echo
Throws:
org.apache.tools.ant.BuildException
See Also:
Task.execute()


Copyright © 2006 John J. Mazzitelli All Rights Reserved. Licensed under LGPL