diff options
Diffstat (limited to 'org.eclipse.jgit.console/src/org')
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; +} |