public class MessageBundleTask
extends org.apache.tools.ant.Task
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)
angular (for angular-localization, see https://github.com/doshprompt/angular-localization)
angular_pretty (for angular-localization prettyprinted, see https://github.com/doshprompt/angular-localization)
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), groovy-enum (Groovy Enum)
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
writeSql = true to write SQL
sqlDialect = Oracle|Postgres, default is Oracle
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"/>
| Modifier and Type | Field and Description |
|---|---|
protected String |
bundles |
protected String |
jsonFile |
protected String |
jsonPath |
protected String |
propertyPath |
protected String |
sourcePath |
| Constructor and Description |
|---|
MessageBundleTask() |
| Modifier and Type | Method and Description |
|---|---|
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 |
getSqlDialect() |
String |
getSqlScriptDir() |
String |
getToCharset() |
String |
getWriteGroovyEnum() |
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() |
boolean |
isWriteSql() |
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 |
setSqlDialect(String sqlDialect) |
void |
setSqlScriptDir(String aSqlScriptDir) |
void |
setToCharset(String toCharset) |
void |
setWriteGroovyEnum(String writeGroovyEnum) |
void |
setWriteInterface(String aWriteInterface) |
void |
setWriteJson(String writeJson) |
void |
setWriteProperties(String aWriteProperties) |
void |
setWriteSql(boolean writeSql) |
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeprotected String bundles
protected String sourcePath
protected String propertyPath
protected String jsonPath
protected String jsonFile
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 boolean isWriteSql()
public void setWriteSql(boolean writeSql)
public String getSqlDialect()
public void setSqlDialect(String sqlDialect)
public String getWriteGroovyEnum()
public void setWriteGroovyEnum(String writeGroovyEnum)
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)
Copyright © 2017. All rights reserved.