Localize UI texts from SetupJavaProjectFromSourcesActivity

Relates to IDEA-222368

GitOrigin-RevId: 61f7084c9dc8b43035c241d8805f1b670f870535
This commit is contained in:
Kirill Likhodedov
2020-01-29 16:06:47 +00:00
committed by intellij-monorepo-bot
parent 1dd5523f77
commit c752f42025
4 changed files with 40 additions and 8 deletions
+1
View File
@@ -4,6 +4,7 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
@@ -0,0 +1,7 @@
build.script.found.notification={0} build {1,choice,1#script|1<scripts} found
build.script.found.notification.import=Import
build.script.found.notification.import.all=Import All
build.scripts.from.multiple.providers.found.notification=Build Scripts Found
project.structure.automatically.detected.notification=Project structure has been automatically detected
project.structure.automatically.detected.notification.configure.action=Configure...
task.searching.for.project.sources=Searching for project sources...
@@ -0,0 +1,19 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ide;
import com.intellij.DynamicBundle;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.PropertyKey;
public class JavaUiBundle extends DynamicBundle {
@NonNls private static final String BUNDLE = "messages.JavaUiBundle";
private static final JavaUiBundle INSTANCE = new JavaUiBundle();
private JavaUiBundle() { super(BUNDLE); }
@NotNull
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
return INSTANCE.getMessage(key, params);
}
}
@@ -21,7 +21,6 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ui.configuration.ModulesProvider
import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService
import com.intellij.openapi.startup.StartupActivity
import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vfs.*
import com.intellij.platform.PlatformProjectOpenProcessor
import com.intellij.projectImport.ProjectOpenProcessor
@@ -42,7 +41,8 @@ class SetupJavaProjectFromSourcesActivity : StartupActivity {
// todo get current project structure, and later setup from sources only if it wasn't manually changed by the user
ProgressManager.getInstance().run(object: Task.Backgroundable(project, "Searching for project sources...", true) {
val title = JavaUiBundle.message("task.searching.for.project.sources")
ProgressManager.getInstance().run(object: Task.Backgroundable(project, title, true) {
override fun run(indicator: ProgressIndicator) {
val projectDir = project.baseDir
val importers = searchImporters(projectDir)
@@ -102,17 +102,16 @@ class SetupJavaProjectFromSourcesActivity : StartupActivity {
}
}
// todo wording
val title: String
val content: String
if (providersAndFiles.keySet().size == 1) {
val processor = providersAndFiles.keySet().single()
val files = providersAndFiles[processor]
title = "${processor.name} ${StringUtil.pluralize("Project", files.size)} Found"
title = JavaUiBundle.message("build.script.found.notification", processor.name, files.size)
content = filesToLinks(files, projectDirectory)
}
else {
title = "Build Scripts Found"
title = JavaUiBundle.message("build.scripts.from.multiple.providers.found.notification")
content = providersAndFiles.asMap().entries.joinToString("<br/>") { (provider, files) ->
provider.name + ": " + filesToLinks(files, projectDirectory)
}
@@ -121,7 +120,12 @@ class SetupJavaProjectFromSourcesActivity : StartupActivity {
val notification = NOTIFICATION_GROUP.createNotification(title, content, NotificationType.INFORMATION, showFileInProjectViewListener)
if (providersAndFiles.keySet().all { it.canImportProjectAfterwards() }) {
val actionName = if (providersAndFiles.keySet().size > 1) "Import All" else "Import"
val actionName = if (providersAndFiles.keySet().size > 1) {
JavaUiBundle.message("build.script.found.notification.import.all")
}
else {
JavaUiBundle.message("build.script.found.notification.import")
}
notification.addAction(NotificationAction.createSimpleExpiring(actionName) {
for ((provider, files) in providersAndFiles.asMap()) {
for (file in files) {
@@ -169,9 +173,10 @@ class SetupJavaProjectFromSourcesActivity : StartupActivity {
}
private fun notifyAboutAutomaticProjectStructure(project: Project) {
val message = "<b>Project structure has been automatically detected</b>"
val message = "<b>${JavaUiBundle.message("project.structure.automatically.detected.notification")}</b>"
val notification = NOTIFICATION_GROUP.createNotification("", message, NotificationType.INFORMATION, null)
notification.addAction(NotificationAction.createSimpleExpiring("Configure...") {
notification.addAction(NotificationAction.createSimpleExpiring(
JavaUiBundle.message("project.structure.automatically.detected.notification.configure.action")) {
ProjectSettingsService.getInstance(project).openProjectSettings()
})
notification.notify(project)