|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
de.viaboxx.nlstools.tasks.MessageBundleTask
public class MessageBundleTask
Description: Generates the interface with message constants and property files (resource bundles) from the descriptions in a xml file.
writeProperties = true (default=false)
(=.properties), false, xml (=.xml)
writeJson = true (default=false)
(=compressed .js file), false, pretty (formatted .js file)
writeInterface = true (default=false)
(keys + bundle name), false, small_enum, small (bundle name only), Flex (ActionScript class), smallFlex (bundle name only)
enum (keys + bundle name + enum of all keys), small_enum (bundle name + enum of all keys)
This utility can generate:
Properties: .properties, .xml
JSON: .js
SQL-Script: .sql
Interface: .java
Configuration:
bundles = the XML (or Excel)-bundles input file(s), separated by ;
sourcePath = to write .java interface to
propertyPath = to write .properties/.xml to
toCharset = (optional, default: null) the charset, e.g. UTF-8, to write properties files
jsonPath = to write .js to
jsonFile = null or the hard-coded json file name
sqlScriptDir = to write .sql to
flexLayout=true: output format is "de_DE/path/bundle.properties" (Adobe Flex directory format)
flexLayout=false: output format is "path/bundle_de_DE.properties" (default, java style)
preserveNewlines=true: newlines will *not* be escaped when writing properties files
preserveNewlines=false: (default) newlines will be escaped when writing properties files
allowedLocales: ';'-separated list of locales that should be written, all other locales will NOT be written, if empty, all locales are written.
overwrite = (default false)
deleteOldFiles = (default true)
merged (has effect when writing .properties files for json files)
merged = (default true) - true: also include properties from parent-bundles
(to keep the properties small, set merged=false - requires fallback at runtime of your app)
- false: only own properties, parent properties not included in output
(if you want the java.util.ResourceBundle to look'em up)
debugMode = (default false) ignores translations and sets the key as label
exampleLocale = a locale, e.g. 'en' (default: the first available locale) optional. to force the flex/java interface to use this locale's text in their example comment
Example:
<taskdef name="msgbundle" classname="de.viaboxx.nlstools.tasks.MessageBundleTask"> <classpath refid="maven.test.classpath"/> </taskdef> <msgbundle overwrite="true" bundles="src/main/bundles/Customer.xml;../utilities/base/src/main/bundles/Common.xml" writeProperties="true" writeJson="true" jsonPath="src\main\webapp\js" jsonFile="i18n" propertyPath="src\main\webapp\WEB-INF\classes"/>
| Field Summary | |
|---|---|
protected String |
bundles
|
protected String |
jsonFile
|
protected String |
jsonPath
|
protected String |
propertyPath
|
protected String |
sourcePath
|
| Fields inherited from class org.apache.tools.ant.Task |
|---|
target, taskName, taskType, wrapper |
| Fields inherited from class org.apache.tools.ant.ProjectComponent |
|---|
description, location, project |
| Constructor Summary | |
|---|---|
MessageBundleTask()
|
|
| Method Summary | |
|---|---|
void |
execute()
|
String |
getBundles()
the path+name of the xml files (; separated) |
String |
getExampleLocale()
|
String |
getJsonFile()
|
String |
getJsonPath()
|
String |
getPropertyPath()
the root path to store the property files |
String |
getSqlScriptDir()
|
String |
getToCharset()
|
String |
getWriteInterface()
true, false, small, Flex, smallFlex when the interface file shall be generated |
String |
getWriteJson()
|
String |
getWriteProperties()
|
boolean |
isDebugMode()
true when the label shall be the same as the key |
boolean |
isFlexLayout()
|
boolean |
isMerged()
|
boolean |
isOverwrite()
true when the files shall be generated, even if they are up-to-date |
boolean |
isPreserveNewlines()
|
protected MBBundles |
loadBundles()
read/parse XML file |
void |
setAllowedLocales(String allowedLocales)
|
void |
setBundles(String aConfigFile)
|
void |
setDebugMode(boolean debugMode)
|
void |
setDeleteOldFiles(boolean aDeleteOldFiles)
if true, delete old .properties files before generating new ones. |
void |
setExampleLocale(String exampleLocale)
|
void |
setFlexLayout(boolean flexLayout)
|
void |
setJsonFile(String jsonFile)
|
void |
setJsonPath(String jsonPath)
|
void |
setMerged(boolean merged)
|
void |
setOverwrite(boolean aOverwrite)
|
void |
setPreserveNewlines(boolean preserveNewlines)
|
void |
setPropertyPath(String aPropertyPath)
|
void |
setSourcePath(String aSourcePath)
|
void |
setSqlScriptDir(String aSqlScriptDir)
|
void |
setToCharset(String toCharset)
|
void |
setWriteInterface(String aWriteInterface)
|
void |
setWriteJson(String writeJson)
|
void |
setWriteProperties(String aWriteProperties)
|
| Methods inherited from class org.apache.tools.ant.Task |
|---|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType |
| Methods inherited from class org.apache.tools.ant.ProjectComponent |
|---|
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected String bundles
protected String sourcePath
protected String propertyPath
protected String jsonPath
protected String jsonFile
| Constructor Detail |
|---|
public MessageBundleTask()
| Method Detail |
|---|
public String getToCharset()
public void setToCharset(String toCharset)
public String getJsonPath()
public void setJsonPath(String jsonPath)
public boolean isFlexLayout()
public void setFlexLayout(boolean flexLayout)
public boolean isMerged()
public void setMerged(boolean merged)
public void setDeleteOldFiles(boolean aDeleteOldFiles)
aDeleteOldFiles - - (default = true)public String getWriteProperties()
public void setWriteProperties(String aWriteProperties)
public String getWriteJson()
public void setWriteJson(String writeJson)
public String getWriteInterface()
public void setWriteInterface(String aWriteInterface)
public boolean isOverwrite()
public void setOverwrite(boolean aOverwrite)
public boolean isDebugMode()
public void setDebugMode(boolean debugMode)
public String getBundles()
public void setBundles(String aConfigFile)
public void setSourcePath(String aSourcePath)
public String getPropertyPath()
public void setPropertyPath(String aPropertyPath)
public void execute()
throws org.apache.tools.ant.BuildException
execute in class org.apache.tools.ant.Taskorg.apache.tools.ant.BuildExceptionpublic String getJsonFile()
public void setJsonFile(String jsonFile)
protected MBBundles loadBundles()
throws Exception
Exceptionpublic String getSqlScriptDir()
public void setSqlScriptDir(String aSqlScriptDir)
public boolean isPreserveNewlines()
public void setPreserveNewlines(boolean preserveNewlines)
public void setAllowedLocales(String allowedLocales)
public String getExampleLocale()
public void setExampleLocale(String exampleLocale)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||