ASF Bugzilla – Attachment 6974 Details for
Bug 17297
[PATCH] The translate task does not translate tokens that are placed too close together
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
CVS patch file
translate.patch (text/plain), 5.91 KB, created by
Tom Eugelink
on 2003-06-25 16:18:54 UTC
(
hide
)
Description:
CVS patch file
Filename:
MIME Type:
Creator:
Tom Eugelink
Created:
2003-06-25 16:18:54 UTC
Size:
5.91 KB
patch
obsolete
>Index: src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java >=================================================================== >RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java,v >retrieving revision 1.20 >diff -u -r1.20 Translate.java >--- src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java 10 Feb 2003 14:14:05 -0000 1.20 >+++ src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java 25 Jun 2003 16:14:56 -0000 >@@ -510,49 +510,65 @@ > int stLength = startToken.length(); > int etLength = endToken.length(); > while ((line = in.readLine()) != null) { >- int startIndex = -1; >- int endIndex = -1; >-outer: while (true) { >- startIndex = line.indexOf(startToken, endIndex + etLength); >- if (startIndex < 0 || >- startIndex + stLength >= line.length()) { >- break; >- } >- endIndex = line.indexOf(endToken, startIndex + stLength); >- if (endIndex < 0) { >- break; >- } >- String matches = line.substring(startIndex + stLength, >- endIndex); >- //If there is a white space or = or :, then >- //it isn't to be treated as a valid key. >- for (int k = 0; k < matches.length(); k++) { >- char c = matches.charAt(k); >- if (c == ':' || >- c == '=' || >- Character.isSpaceChar(c)) { >- endIndex = endIndex - 1; >- continue outer; >- } >- } >- String replace = null; >- replace = (String) resourceMap.get(matches); >- //If the key hasn't been loaded into resourceMap, >- //use the key itself as the value also. >- if (replace == null) { >- log("Warning: The key: " + matches >- + " hasn't been defined.", >- Project.MSG_DEBUG); >- replace = matches; >- } >- line = line.substring(0, startIndex) >- + replace >- + line.substring(endIndex + etLength); >- endIndex = startIndex + replace.length() + etLength; >- if (endIndex + etLength >= line.length()) { >- break; >- } >- } >+ // 2003-02-21 new replace algorithme by tbee (tbee@tbee.org) >+ // because it wasn't able to replace something like "@aaa;@bbb;" >+ >+ // is there a startToken >+ // and there is still stuff following the startToken >+ int startIndex = line.indexOf(startToken); >+ while ( startIndex >= 0 && (startIndex+startToken.length()) <= line.length() ) >+ { >+ // the new value, this needs to be here >+ // because it is required to calculate the next position to search from >+ // at the end of the loop >+ String replace = null; >+ >+ // we found a starttoken, is there an endtoken following? >+ // start at token+tokenlength because start and end token may be indentical >+ int endIndex = line.indexOf(endToken, startIndex + startToken.length()); >+ if (endIndex < 0) startIndex += 1; >+ else >+ { >+ // grab the token >+ String token = line.substring(startIndex + startToken.length(), endIndex); >+ >+ // If there is a white space or = or :, then >+ // it isn't to be treated as a valid key. >+ boolean validToken = true; >+ for (int k = 0; k < token.length() && validToken; k++) >+ { >+ char c = token.charAt(k); >+ if ( c == ':' >+ || c == '=' >+ || Character.isSpaceChar(c) >+ ) >+ { >+ validToken = false; >+ } >+ } >+ if (!validToken) startIndex += 1; >+ else >+ { >+ // find the replace string >+ if (resourceMap.containsKey(token)) replace = (String)resourceMap.get(token); >+ else replace = token; >+ >+ >+ // generate the new line >+ line = line.substring(0, startIndex) >+ + replace >+ + line.substring(endIndex + endToken.length()); >+ >+ // set start position for next search >+ startIndex += replace.length(); >+ } >+ } >+ >+ // find next starttoken >+ startIndex = line.indexOf(startToken, startIndex); >+ } >+ >+ > out.write(line); > out.newLine(); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 17297
:
4971
| 6974