diff --git a/plugins/git4idea/src/git4idea/i18n/GitBundle.properties b/plugins/git4idea/src/git4idea/i18n/GitBundle.properties index 36c26418331b..42fc959a86b1 100644 --- a/plugins/git4idea/src/git4idea/i18n/GitBundle.properties +++ b/plugins/git4idea/src/git4idea/i18n/GitBundle.properties @@ -360,15 +360,6 @@ ssh.keyboard.interactive.username=Username: ssh.new.host.key=Connecting to a new host {0}:{1} that has the key {2} (type {3}).\nDo you want to add this host to known hosts database? ssh.password.message=Please enter password for user {0} ssh.password.title=SSH Password Login -sshmain.failed.to.verify.key=Failed to verify key: {0} -sshmain.forwarding.failed=Forwarding {0} failed: {1} -sshmain.invald.host.key=Invald host key {0} {1} -sshmain.invalid.amount.of.arguments=Invalid amount of arguments: {0} -sshmain.invalidpassphrase=Invalid passphrase for the key {0} -sshmain.keyboard.interactive.failed=Keyboard interactive authentication failed. -sshmain.password.failed=Invalid user or password. -sshmain.pk.authenitication.failed=Authentication using key {0} failed. -sshmain.too.mush.passphrase.guesses=Invalid passphrase for the key {0}({1} attempts) stash.action.name=Stash stash.button=Create Stash stash.keep.index.tooltip=If this checkbox is selected, indexed changes are kept in the index. diff --git a/plugins/git4idea/src/org/jetbrains/git4idea/ssh/GitSSHService.java b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/GitSSHService.java index db8584376b4d..28c2e7f22db4 100644 --- a/plugins/git4idea/src/org/jetbrains/git4idea/ssh/GitSSHService.java +++ b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/GitSSHService.java @@ -22,7 +22,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.io.FileUtil; import com.trilead.ssh2.KnownHosts; import git4idea.commands.ScriptGenerator; -import git4idea.i18n.GitBundle; import gnu.trove.THashMap; import org.apache.commons.codec.DecoderException; import org.apache.xmlrpc.XmlRpcClientLite; @@ -120,7 +119,7 @@ public class GitSSHService implements ApplicationComponent { generator.addInternal(Integer.toString(myXmlRpcServer.getPortNumber())); generator.addClasses(XmlRpcClientLite.class, DecoderException.class); generator.addClasses(KnownHosts.class, FileUtil.class); - generator.addResource(GitBundle.class, "/git4idea/i18n/GitBundle.properties"); + generator.addResource(SSHMainBundle.class, "/org/jetbrains/git4idea/ssh/SSHMainBundle.properties"); myScriptPath = generator.generate(); } return myScriptPath; diff --git a/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMain.java b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMain.java index 8eb04a347743..9f235735a802 100644 --- a/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMain.java +++ b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMain.java @@ -19,7 +19,6 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.util.ArrayUtil; import com.trilead.ssh2.*; import com.trilead.ssh2.crypto.PEMDecoder; -import git4idea.i18n.GitBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -243,7 +242,7 @@ public class SSHMain { return; } else { - myLastError = GitBundle.getString("sshmain.keyboard.interactive.failed"); + myLastError = SSHMainBundle.getString("sshmain.keyboard.interactive.failed"); } if (interactiveSupport.myPromptCount == 0 || interactiveSupport.myCancelled) { // the interactive callback has never been asked or it was cancelled, exit the loop @@ -270,7 +269,7 @@ public class SSHMain { return; } else { - myLastError = GitBundle.getString("sshmain.password.failed"); + myLastError = SSHMainBundle.getString("sshmain.password.failed"); } } } @@ -317,14 +316,14 @@ public class SSHMain { } catch (IOException e) { // decoding failed - myLastError = GitBundle.message("sshmain.invalidpassphrase", keyPath); + myLastError = SSHMainBundle.message("sshmain.invalidpassphrase", keyPath); continue; } break; } } if (i == 0) { - myLastError = GitBundle.message("sshmain.too.mush.passphrase.guesses", keyPath, myHost.getNumberOfPasswordPrompts()); + myLastError = SSHMainBundle.message("sshmain.too.mush.passphrase.guesses", keyPath, myHost.getNumberOfPasswordPrompts()); return false; } } @@ -336,7 +335,7 @@ public class SSHMain { else { if (passphrase != null) { // mark as failed authentication only if passphrase were asked - myLastError = GitBundle.message("sshmain.pk.authenitication.failed", keyPath); + myLastError = SSHMainBundle.message("sshmain.pk.authenitication.failed", keyPath); } else { myLastError = ""; @@ -407,7 +406,7 @@ public class SSHMain { } } catch (IOException e) { - System.err.println(GitBundle.message("sshmain.forwarding.failed", name, e.getMessage())); + System.err.println(SSHMainBundle.message("sshmain.forwarding.failed", name, e.getMessage())); e.printStackTrace(); myExitCode = 1; if (releaseSemaphore) { @@ -452,7 +451,7 @@ public class SSHMain { */ private static SSHMain parseArguments(String[] args) throws IOException { if (args.length != 3 && args.length != 5) { - System.err.println(GitBundle.message("sshmain.invalid.amount.of.arguments", Arrays.asList(args))); + System.err.println(SSHMainBundle.message("sshmain.invalid.amount.of.arguments", Arrays.asList(args))); System.exit(1); } int i = 0; @@ -564,12 +563,12 @@ public class SSHMain { return true; } else { - System.err.println(GitBundle.message("sshmain.invald.host.key", serverHostKeyAlgorithm, fingerprint)); + System.err.println(SSHMainBundle.message("sshmain.invald.host.key", serverHostKeyAlgorithm, fingerprint)); return false; } } catch (Throwable t) { - System.err.println(GitBundle.message("sshmain.failed.to.verify.key", t.getMessage())); + System.err.println(SSHMainBundle.message("sshmain.failed.to.verify.key", t.getMessage())); t.printStackTrace(); return false; } diff --git a/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMainBundle.java b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMainBundle.java new file mode 100644 index 000000000000..0a5122fc9b9c --- /dev/null +++ b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMainBundle.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.git4idea.ssh; + +import com.intellij.CommonBundle; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.PropertyKey; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.util.ResourceBundle; + +/** + * The bundle for SSH messages + */ +public class SSHMainBundle { + private static Reference ourBundle; + + @NonNls + private static final String BUNDLE = "org.jetbrains.git4idea.ssh.SSHMainBundle"; + + private SSHMainBundle() { + } + + public static String message(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) { + return CommonBundle.message(getBundle(), key, params); + } + + private static ResourceBundle getBundle() { + ResourceBundle bundle = null; + if (ourBundle != null) bundle = ourBundle.get(); + if (bundle == null) { + bundle = ResourceBundle.getBundle(BUNDLE); + ourBundle = new SoftReference(bundle); + } + return bundle; + } + + public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { + return getBundle().getString(key); + } + +} diff --git a/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMainBundle.properties b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMainBundle.properties new file mode 100644 index 000000000000..c252f546ed9e --- /dev/null +++ b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMainBundle.properties @@ -0,0 +1,9 @@ +sshmain.failed.to.verify.key=Failed to verify key: {0} +sshmain.forwarding.failed=Forwarding {0} failed: {1} +sshmain.invald.host.key=Invald host key {0} {1} +sshmain.invalid.amount.of.arguments=Invalid amount of arguments: {0} +sshmain.invalidpassphrase=Invalid passphrase for the key {0} +sshmain.keyboard.interactive.failed=Keyboard interactive authentication failed. +sshmain.password.failed=Invalid user or password. +sshmain.pk.authenitication.failed=Authentication using key {0} failed. +sshmain.too.mush.passphrase.guesses=Invalid passphrase for the key {0}({1} attempts)