From 0a86b03eb413271d736ae44529811a3e162a8ee1 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 18 Aug 2016 15:58:43 +0900 Subject: [PATCH] LfsRepository{NotFound,ReadOnly}: Externalize message strings Instead of hard-coding the message strings, define them in a properties file. This will allow them to be translated. Change-Id: I77556881579e66b2c13d187759c7efdddfee87ae Signed-off-by: David Pursehouse --- .../org/eclipse/jgit/lfs/internal/LfsText.properties | 4 +++- .../org/eclipse/jgit/lfs/errors/LfsRepositoryNotFound.java | 6 +++++- .../org/eclipse/jgit/lfs/errors/LfsRepositoryReadOnly.java | 6 +++++- .../src/org/eclipse/jgit/lfs/internal/LfsText.java | 2 ++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/org.eclipse.jgit.lfs/resources/org/eclipse/jgit/lfs/internal/LfsText.properties b/org.eclipse.jgit.lfs/resources/org/eclipse/jgit/lfs/internal/LfsText.properties index 700e2d50d0..1c1bbed0e2 100644 --- a/org.eclipse.jgit.lfs/resources/org/eclipse/jgit/lfs/internal/LfsText.properties +++ b/org.eclipse.jgit.lfs/resources/org/eclipse/jgit/lfs/internal/LfsText.properties @@ -1,4 +1,6 @@ incorrectLONG_OBJECT_ID_LENGTH=Incorrect LONG_OBJECT_ID_LENGTH. invalidLongId=Invalid id: {0} invalidLongIdLength=Invalid id length {0}; should be {1} -requiredHashFunctionNotAvailable=Required hash function {0} not available. \ No newline at end of file +requiredHashFunctionNotAvailable=Required hash function {0} not available. +repositoryNotFound=Repository {0} not found +repositoryReadOnly=Repository {0} is read-only \ No newline at end of file diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/LfsRepositoryNotFound.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/LfsRepositoryNotFound.java index 021a100e63..bf94f515dd 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/LfsRepositoryNotFound.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/LfsRepositoryNotFound.java @@ -43,6 +43,10 @@ package org.eclipse.jgit.lfs.errors; +import java.text.MessageFormat; + +import org.eclipse.jgit.lfs.internal.LfsText; + /** * Thrown when the repository does not exist for the user. * @@ -56,6 +60,6 @@ public class LfsRepositoryNotFound extends LfsException { * */ public LfsRepositoryNotFound(String name) { - super("repository " + name + " not found"); //$NON-NLS-1$ //$NON-NLS-2$ + super(MessageFormat.format(LfsText.get().repositoryNotFound, name)); } } diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/LfsRepositoryReadOnly.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/LfsRepositoryReadOnly.java index 9de334d703..cab7e19b72 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/LfsRepositoryReadOnly.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/errors/LfsRepositoryReadOnly.java @@ -43,6 +43,10 @@ package org.eclipse.jgit.lfs.errors; +import java.text.MessageFormat; + +import org.eclipse.jgit.lfs.internal.LfsText; + /** * Thrown when the user has read, but not write access. Only applicable when the * operation in the request is "upload". @@ -56,6 +60,6 @@ public class LfsRepositoryReadOnly extends LfsException { * @param name */ public LfsRepositoryReadOnly(String name) { - super("repository " + name + "is read-only"); //$NON-NLS-1$ //$NON-NLS-2$ + super(MessageFormat.format(LfsText.get().repositoryReadOnly, name)); } } diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsText.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsText.java index eaffcc9047..ae4be6a947 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsText.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsText.java @@ -62,4 +62,6 @@ public class LfsText extends TranslationBundle { /***/ public String invalidLongId; /***/ public String invalidLongIdLength; /***/ public String requiredHashFunctionNotAvailable; + /***/ public String repositoryNotFound; + /***/ public String repositoryReadOnly; } -- 2.39.5