diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java b/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java index 7ba1a084c..1d947d967 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java @@ -74,12 +74,47 @@ import org.apache.tools.ant.util.FileUtils; /** * Translates text embedded in files using Resource Bundle files. + * Since ant 1.6 preserves line endings * * @author Magesh Umasankar, Don Brown * @author Tom Eugelink */ public class Translate extends MatchingTask { - + /** + * search a bundle matching the specified language, the country and the variant + */ + private static final int BUNDLE_SPECIFIED_LANGUAGE_COUNTRY_VARIANT = 0; + /** + * search a bundle matching the specified language, and the country + */ + private static final int BUNDLE_SPECIFIED_LANGUAGE_COUNTRY = 1; + /** + * search a bundle matching the specified language only + */ + private static final int BUNDLE_SPECIFIED_LANGUAGE = 2; + /** + * search a bundle matching nothing special + */ + private static final int BUNDLE_NOMATCH = 3; + /** + * search a bundle matching the language, the country and the variant + * of the current locale of the computer + */ + private static final int BUNDLE_DEFAULT_LANGUAGE_COUNTRY_VARIANT = 4; + /** + * search a bundle matching the language, and the country + * of the current locale of the computer + */ + private static final int BUNDLE_DEFAULT_LANGUAGE_COUNTRY = 5; + /** + * search a bundle matching the language only + * of the current locale of the computer + */ + private static final int BUNDLE_DEFAULT_LANGUAGE = 6; + /** + * number of possibilities for the search + */ + private static final int BUNDLE_MAX_ALTERNATIVES = BUNDLE_DEFAULT_LANGUAGE + 1; /** * Family name of resource bundle */ @@ -154,7 +189,7 @@ public class Translate extends MatchingTask { /** * Last Modified Timestamp of resource bundle file being used. */ - private long[] bundleLastModified = new long[7]; + private long[] bundleLastModified = new long[BUNDLE_MAX_ALTERNATIVES]; /** * Last Modified Timestamp of source file being used. @@ -173,6 +208,7 @@ public class Translate extends MatchingTask { /** * Sets Family name of resource bundle; required. + * @param bundle family name of resource bundle */ public void setBundle(String bundle) { this.bundle = bundle; @@ -180,6 +216,7 @@ public class Translate extends MatchingTask { /** * Sets locale specific language of resource bundle; optional. + * @param bundleLanguage langage of the bundle */ public void setBundleLanguage(String bundleLanguage) { this.bundleLanguage = bundleLanguage; @@ -187,6 +224,7 @@ public class Translate extends MatchingTask { /** * Sets locale specific country of resource bundle; optional. + * @param bundleCountry country of the bundle */ public void setBundleCountry(String bundleCountry) { this.bundleCountry = bundleCountry; @@ -194,6 +232,7 @@ public class Translate extends MatchingTask { /** * Sets locale specific variant of resource bundle; optional. + * @param bundleVariant locale variant of resource bundle */ public void setBundleVariant(String bundleVariant) { this.bundleVariant = bundleVariant; @@ -201,6 +240,7 @@ public class Translate extends MatchingTask { /** * Sets Destination directory; required. + * @param toDir destination directory */ public void setToDir(File toDir) { this.toDir = toDir; @@ -208,6 +248,7 @@ public class Translate extends MatchingTask { /** * Sets starting token to identify keys; required. + * @param startToken starting token to identify keys */ public void setStartToken(String startToken) { this.startToken = startToken; @@ -215,6 +256,7 @@ public class Translate extends MatchingTask { /** * Sets ending token to identify keys; required. + * @param endToken ending token to identify keys */ public void setEndToken(String endToken) { this.endToken = endToken; @@ -223,6 +265,7 @@ public class Translate extends MatchingTask { /** * Sets source file encoding scheme; optional, * defaults to encoding of local system. + * @param srcEncoding source file encoding */ public void setSrcEncoding(String srcEncoding) { this.srcEncoding = srcEncoding; @@ -231,6 +274,7 @@ public class Translate extends MatchingTask { /** * Sets destination file encoding scheme; optional. Defaults to source file * encoding + * @param destEncoding destination file encoding scheme */ public void setDestEncoding(String destEncoding) { this.destEncoding = destEncoding; @@ -239,6 +283,7 @@ public class Translate extends MatchingTask { /** * Sets Resource Bundle file encoding scheme; optional. Defaults to source file * encoding + * @param bundleEncoding bundle file encoding scheme */ public void setBundleEncoding(String bundleEncoding) { this.bundleEncoding = bundleEncoding; @@ -249,6 +294,7 @@ public class Translate extends MatchingTask { * whether it is newer than the source file as well as the * resource bundle file. * Defaults to false. + * @param forceOverwrite whether or not to overwrite existing files */ public void setForceOverwrite(boolean forceOverwrite) { this.forceOverwrite = forceOverwrite; @@ -256,6 +302,7 @@ public class Translate extends MatchingTask { /** * Adds a set of files to translate as a nested fileset element. + * @param set the fileset to be added */ public void addFileset(FileSet set) { filesets.addElement(set); @@ -263,6 +310,12 @@ public class Translate extends MatchingTask { /** * Check attributes values, load resource map and translate + * @throws BuildException if the required attributes are not set + * Required :