git: fix i18n warnings
[idea/community.git] / plugins / git4idea / src / git4idea / checkin / GitCheckinEnvironment.java
index 4bb72d90cb3a767271d70897cf44caa3d36c58f7..de6f74cec9c86f4bece0c641431ab748af03c78e 100644 (file)
@@ -10,6 +10,7 @@ import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.application.TransactionGuard;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.diff.DiffBundle;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
 import com.intellij.openapi.project.Project;
@@ -60,7 +61,6 @@ import git4idea.repo.GitRepository;
 import git4idea.repo.GitRepositoryManager;
 import git4idea.util.GitFileUtils;
 import gnu.trove.THashSet;
-import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -314,7 +314,7 @@ public class GitCheckinEnvironment implements CheckinEnvironment, AmendCommitAwa
 
       List<FilePath> unmergedFiles = GitChangeUtils.getUnmergedFiles(repository);
       if (!unmergedFiles.isEmpty()) {
-        throw new VcsException("Committing is not possible because you have unmerged files.");
+        throw new VcsException(GitBundle.message("error.commit.cant.commit.with.unmerged.paths"));
       }
 
       // Check what is staged besides our changes
@@ -376,7 +376,7 @@ public class GitCheckinEnvironment implements CheckinEnvironment, AmendCommitAwa
                                                                       @NotNull Collection<? extends CommitChange> changes) throws VcsException {
     Set<String> changelistIds = map2SetNotNull(changes, change -> change.changelistId);
     if (changelistIds.isEmpty()) return Pair.create(EmptyRunnable.INSTANCE, emptyList());
-    if (changelistIds.size() != 1) throw new VcsException("Can't commit changes from multiple changelists at once");
+    if (changelistIds.size() != 1) throw new VcsException(GitBundle.message("error.commit.cant.commit.multiple.changelists"));
     String changelistId = changelistIds.iterator().next();
 
     Pair<List<PartialCommitHelper>, List<CommitChange>> result = computeAfterLSTManagerUpdate(repository.getProject(), () -> {
@@ -404,7 +404,7 @@ public class GitCheckinEnvironment implements CheckinEnvironment, AmendCommitAwa
       return Pair.create(helpers, partialChanges);
     });
 
-    if (result == null) throw new VcsException("Can't collect partial changes to commit");
+    if (result == null) throw new VcsException(GitBundle.message("error.commit.cant.collect.partial.changes"));
     List<PartialCommitHelper> helpers = result.first;
     List<CommitChange> partialChanges = result.second;
 
@@ -426,7 +426,7 @@ public class GitCheckinEnvironment implements CheckinEnvironment, AmendCommitAwa
       FilePath path = Objects.requireNonNull(change.afterPath);
       PartialCommitHelper helper = helpers.get(i);
       VirtualFile file = change.virtualFile;
-      if (file == null) throw new VcsException("Can't find file: " + path.getPath());
+      if (file == null) throw new VcsException(DiffBundle.message("cannot.find.file.error", path.getPresentableUrl()));
 
       GitIndexUtil.StagedFile stagedFile = getStagedFile(repository, change);
       boolean isExecutable = stagedFile != null && stagedFile.isExecutable();
@@ -846,8 +846,9 @@ public class GitCheckinEnvironment implements CheckinEnvironment, AmendCommitAwa
       Ref<Boolean> mergeAll = new Ref<>();
       try {
         ApplicationManager.getApplication().invokeAndWait(() -> {
-          String message = GitBundle.message("commit.partial.merge.message", partialOperation.getName());
-          SelectFilePathsDialog dialog = new SelectFilePathsDialog(project, files, message, null, "Commit All Files",
+          String message = GitBundle.message("commit.partial.merge.message", partialOperation.getIndex());
+          SelectFilePathsDialog dialog = new SelectFilePathsDialog(project, files, message, null,
+                                                                   GitBundle.message("button.commit.all.files"),
                                                                    CommonBundle.getCancelButtonText(), false);
           dialog.setTitle(GitBundle.getString("commit.partial.merge.title"));
           dialog.show();
@@ -919,10 +920,10 @@ public class GitCheckinEnvironment implements CheckinEnvironment, AmendCommitAwa
    */
   private static PartialOperation isMergeCommit(final VcsException ex) {
     String message = ex.getMessage();
-    if (message.contains("cannot do a partial commit during a merge")) {
+    if (message.contains("cannot do a partial commit during a merge")) { //NON-NLS
       return PartialOperation.MERGE;
     }
-    if (message.contains("cannot do a partial commit during a cherry-pick")) {
+    if (message.contains("cannot do a partial commit during a cherry-pick")) { //NON-NLS
       return PartialOperation.CHERRY_PICK;
     }
     return PartialOperation.NONE;
@@ -994,7 +995,7 @@ public class GitCheckinEnvironment implements CheckinEnvironment, AmendCommitAwa
       messageFile = createCommitMessageFile(project, root, message);
     }
     catch (IOException ex) {
-      throw new VcsException("Creation of commit message file failed", ex);
+      throw new VcsException(GitBundle.message("error.commit.cant.create.message.file"), ex);
     }
 
     try {
@@ -1089,19 +1090,18 @@ public class GitCheckinEnvironment implements CheckinEnvironment, AmendCommitAwa
   }
 
   private enum PartialOperation {
-    NONE("none"),
-    MERGE("merge"),
-    CHERRY_PICK("cherry-pick");
+    NONE(0),
+    MERGE(1),
+    CHERRY_PICK(2);
 
-    private final @Nls String myName;
+    private final int myIndex; // See 'commit.partial.merge.message' bundle string
 
-    PartialOperation(@Nls String name) {
-      myName = name;
+    PartialOperation(int messageIndex) {
+      myIndex = messageIndex;
     }
 
-    @Nls
-    String getName() {
-      return myName;
+    int getIndex() {
+      return myIndex;
     }
   }
 
@@ -1219,6 +1219,7 @@ public class GitCheckinEnvironment implements CheckinEnvironment, AmendCommitAwa
       return !CASE_SENSITIVE_FILE_PATH_HASHING_STRATEGY.equals(beforePath, afterPath);
     }
 
+    @NonNls
     @Override
     public String toString() {
       return String.format("%s -> %s", beforePath, afterPath);