diff options
author | Sasa Zivkov <sasa.zivkov@sap.com> | 2010-05-19 16:59:28 +0200 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-05-19 14:37:16 -0700 |
commit | f3d8a8ecad614906a2c4ec0077cdb24129da6c6d (patch) | |
tree | 34d041692beff0f392c27869f49b76c0fc2053e6 /org.eclipse.jgit/src/org/eclipse/jgit/patch | |
parent | 2e961989e42b1fe7e8bd9eaa7a3d2e88a0d1d001 (diff) | |
download | jgit-f3d8a8ecad614906a2c4ec0077cdb24129da6c6d.tar.gz jgit-f3d8a8ecad614906a2c4ec0077cdb24129da6c6d.zip |
Externalize strings from JGit
The strings are externalized into the root resource bundles.
The resource bundles are stored under the new "resources" source
folder to get proper maven build.
Strings from tests are, in general, not externalized. Only in
cases where it was necessary to make the test pass the strings
were externalized. This was typically necessary in cases where
e.getMessage() was used in assert and the exception message was
slightly changed due to reuse of the externalized strings.
Change-Id: Ic0f29c80b9a54fcec8320d8539a3e112852a1f7b
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/patch')
4 files changed, 22 insertions, 18 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/CombinedHunkHeader.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/CombinedHunkHeader.java index 781190539f..042c778510 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/CombinedHunkHeader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/CombinedHunkHeader.java @@ -48,7 +48,9 @@ import static org.eclipse.jgit.util.RawParseUtils.parseBase10; import java.io.IOException; import java.io.OutputStream; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.lib.AbbreviatedObjectId; import org.eclipse.jgit.util.MutableInteger; @@ -183,16 +185,14 @@ public class CombinedHunkHeader extends HunkHeader { final int cmp = o.nContext + o.nDeleted; if (cmp < o.lineCount) { final int missingCnt = o.lineCount - cmp; - script.error(buf, startOffset, "Truncated hunk, at least " - + missingCnt + " lines is missing for ancestor " - + (ancestor + 1)); + script.error(buf, startOffset, MessageFormat.format( + JGitText.get().truncatedHunkLinesMissingForAncestor, missingCnt, (ancestor + 1))); } } if (nContext + nAdded < newLineCount) { final int missingCount = newLineCount - (nContext + nAdded); - script.error(buf, startOffset, "Truncated hunk, at least " - + missingCount + " new lines is missing"); + script.error(buf, startOffset, MessageFormat.format(JGitText.get().truncatedHunkNewLinesMissing, missingCount)); } return c; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java index c35b613a22..25dc72af20 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java @@ -54,10 +54,12 @@ import static org.eclipse.jgit.util.RawParseUtils.parseBase10; import java.io.IOException; import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.diff.EditList; import org.eclipse.jgit.lib.AbbreviatedObjectId; import org.eclipse.jgit.lib.Constants; @@ -241,8 +243,7 @@ public class FileHeader { } if (charsetGuess != null && charsetGuess.length != getParentCount() + 1) - throw new IllegalArgumentException("Expected " - + (getParentCount() + 1) + " character encoding guesses"); + throw new IllegalArgumentException(MessageFormat.format(JGitText.get().expectedCharacterEncodingGuesses, (getParentCount() + 1))); if (trySimpleConversion(charsetGuess)) { Charset cs = charsetGuess != null ? charsetGuess[0] : null; @@ -302,7 +303,7 @@ public class FileHeader { } return r; } catch (IOException ioe) { - throw new RuntimeException("Cannot convert script to text", ioe); + throw new RuntimeException(JGitText.get().cannotConvertScriptToText, ioe); } finally { for (final TemporaryBuffer b : tmp) { if (b != null) @@ -410,7 +411,7 @@ public class FileHeader { void addHunk(final HunkHeader h) { if (h.getFileHeader() != this) - throw new IllegalArgumentException("Hunk belongs to another file"); + throw new IllegalArgumentException(JGitText.get().hunkBelongsToAnotherFile); if (hunks == null) hunks = new ArrayList<HunkHeader>(); hunks.add(h); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/HunkHeader.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/HunkHeader.java index 9d78d0b99f..bfb20b64e9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/HunkHeader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/HunkHeader.java @@ -49,7 +49,9 @@ import static org.eclipse.jgit.util.RawParseUtils.parseBase10; import java.io.IOException; import java.io.OutputStream; +import java.text.MessageFormat; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.diff.Edit; import org.eclipse.jgit.diff.EditList; import org.eclipse.jgit.lib.AbbreviatedObjectId; @@ -278,21 +280,21 @@ public class HunkHeader { if (nContext + old.nDeleted < old.lineCount) { final int missingCount = old.lineCount - (nContext + old.nDeleted); - script.error(buf, startOffset, "Truncated hunk, at least " - + missingCount + " old lines is missing"); + script.error(buf, startOffset, MessageFormat.format( + JGitText.get().truncatedHunkOldLinesMissing, missingCount)); } else if (nContext + old.nAdded < newLineCount) { final int missingCount = newLineCount - (nContext + old.nAdded); - script.error(buf, startOffset, "Truncated hunk, at least " - + missingCount + " new lines is missing"); + script.error(buf, startOffset, MessageFormat.format( + JGitText.get().truncatedHunkNewLinesMissing, missingCount)); } else if (nContext + old.nDeleted > old.lineCount || nContext + old.nAdded > newLineCount) { final String oldcnt = old.lineCount + ":" + newLineCount; final String newcnt = (nContext + old.nDeleted) + ":" + (nContext + old.nAdded); - script.warn(buf, startOffset, "Hunk header " + oldcnt - + " does not match body line count of " + newcnt); + script.warn(buf, startOffset, MessageFormat.format( + JGitText.get().hunkHeaderDoesNotMatchBodyLineCountOf, oldcnt, newcnt)); } return c; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java index eff5303dc5..ce006dadbf 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java @@ -55,6 +55,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.util.TemporaryBuffer; /** A parsed collection of {@link FileHeader}s from a unified diff patch file */ @@ -175,7 +176,7 @@ public class Patch { // have missed a file header previously. The hunk // isn't valid without knowing where it comes from. // - error(buf, c, "Hunk disconnected from file"); + error(buf, c, JGitText.get().hunkDisconnectedFromFile); c = nextLF(buf, c); continue; } @@ -300,7 +301,7 @@ public class Patch { break; default: if (match(buf, c, SIG_FOOTER) < 0) - warn(buf, c, "Unexpected hunk trailer"); + warn(buf, c, JGitText.get().unexpectedHunkTrailer); } } continue; @@ -345,7 +346,7 @@ public class Patch { if (nEnd < 0) { // Not a binary hunk. // - error(fh.buf, c, "Missing forward-image in GIT binary patch"); + error(fh.buf, c, JGitText.get().missingForwardImageInGITBinaryPatch); return c; } c = nEnd; |