aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.console/src
diff options
context:
space:
mode:
authorSasa Zivkov <sasa.zivkov@sap.com>2010-05-19 16:59:28 +0200
committerShawn O. Pearce <spearce@spearce.org>2010-05-19 14:37:16 -0700
commitf3d8a8ecad614906a2c4ec0077cdb24129da6c6d (patch)
tree34d041692beff0f392c27869f49b76c0fc2053e6 /org.eclipse.jgit.console/src
parent2e961989e42b1fe7e8bd9eaa7a3d2e88a0d1d001 (diff)
downloadjgit-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.console/src')
-rw-r--r--org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleAuthenticator.java7
-rw-r--r--org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleSshSessionFactory.java6
-rw-r--r--org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleText.java66
3 files changed, 73 insertions, 6 deletions
diff --git a/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleAuthenticator.java b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleAuthenticator.java
index 84fd520f75..3df5e44331 100644
--- a/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleAuthenticator.java
+++ b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleAuthenticator.java
@@ -47,6 +47,7 @@ package org.eclipse.jgit.console;
import java.io.Console;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
+import java.text.MessageFormat;
import org.eclipse.jgit.util.CachedAuthenticator;
@@ -56,7 +57,7 @@ public class ConsoleAuthenticator extends CachedAuthenticator {
public static void install() {
final ConsoleAuthenticator c = new ConsoleAuthenticator();
if (c.cons == null)
- throw new NoClassDefFoundError("No System.console available");
+ throw new NoClassDefFoundError(ConsoleText.get().noSystemConsoleAvailable);
Authenticator.setDefault(c);
}
@@ -65,11 +66,11 @@ public class ConsoleAuthenticator extends CachedAuthenticator {
@Override
protected PasswordAuthentication promptPasswordAuthentication() {
final String realm = formatRealm();
- String username = cons.readLine("Username for %s: ", realm);
+ String username = cons.readLine(MessageFormat.format(ConsoleText.get().usernameFor + " ", realm));
if (username == null || username.isEmpty()) {
return null;
}
- char[] password = cons.readPassword("Password: ");
+ char[] password = cons.readPassword(ConsoleText.get().password + " ");
if (password == null) {
password = new char[0];
}
diff --git a/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleSshSessionFactory.java b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleSshSessionFactory.java
index 7d36dded48..b11078dea8 100644
--- a/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleSshSessionFactory.java
+++ b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleSshSessionFactory.java
@@ -70,7 +70,7 @@ public class ConsoleSshSessionFactory extends SshConfigSessionFactory {
public static void install() {
final ConsoleSshSessionFactory c = new ConsoleSshSessionFactory();
if (c.cons == null)
- throw new NoClassDefFoundError("No System.console available");
+ throw new NoClassDefFoundError(ConsoleText.get().noSystemConsoleAvailable);
SshSessionFactory.setInstance(c);
}
@@ -93,8 +93,8 @@ public class ConsoleSshSessionFactory extends SshConfigSessionFactory {
}
public boolean promptYesNo(final String msg) {
- String r = cons.readLine("%s [y/n]? ", msg);
- return "y".equalsIgnoreCase(r);
+ String r = cons.readLine("%s [%s/%s]? ", msg, ConsoleText.get().answerYes, ConsoleText.get().answerNo);
+ return ConsoleText.get().answerYes.equalsIgnoreCase(r);
}
public boolean promptPassword(final String msg) {
diff --git a/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleText.java b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleText.java
new file mode 100644
index 0000000000..3f1734b01a
--- /dev/null
+++ b/org.eclipse.jgit.console/src/org/eclipse/jgit/console/ConsoleText.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com>
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Distribution License v1.0 which
+ * accompanies this distribution, is reproduced below, and is
+ * available at http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.eclipse.jgit.console;
+
+import org.eclipse.jgit.nls.NLS;
+import org.eclipse.jgit.nls.TranslationBundle;
+
+/**
+ * Translation bundle for JGit console
+ */
+public class ConsoleText extends TranslationBundle {
+
+ /**
+ * @return an instance of this translation bundle
+ */
+ public static ConsoleText get() {
+ return NLS.getBundleFor(ConsoleText.class);
+ }
+
+ /***/ public String answerNo;
+ /***/ public String answerYes;
+ /***/ public String noSystemConsoleAvailable;
+ /***/ public String password;
+ /***/ public String usernameFor;
+}