GradleScriptNotifications: extract and fix i18n strings

This commit is contained in:
Sergey Rostov
2020-06-11 17:02:51 +03:00
parent 632e88459e
commit 9096d21fcd
5 changed files with 39 additions and 38 deletions
@@ -1,5 +1,28 @@
action.text.standalone=Add as standalone script
action.label.text.load.script.configuration=Load related Gradle project
notification.outsideAnything.text=Code insight unavailable (related Gradle project not linked)
notification.outsideAnything.linkAction=Link Gradle project
notification.wasNotImportedAfterCreation.text=Code insight unavailable (Gradle project not imported)
action.label.import.project=Import Project
action.text.load.script.configurations=Load Script Configurations
action.description.load.script.configurations=Gradle Kotlin DSL script configuration has been changed. Load changes to get script code insight without loading the external Gradle project.
action.label.enable.auto.import=Enable Auto-Import
notification.notEvaluatedInLastImport.text=Code insight unavailable (configuration for this script wasn't received during last import)
notification.notEvaluatedInLastImport.addAsStandaloneAction=Add as standalone script
notification.notEvaluatedInLastImport.info=<div width=400>\
<p>The Gradle project that evaluates this script needs to be imported to get it analyzed by the IDE.\
Try reimport linked Gradle project or link a new Gradle project that evaluates this script.</p>\
<br/>\
<p>Alternatively, you can mark this script as standalone and its configuration will be loaded separately.</p>\
<br/> \
<p><b>NOTE:</b> Each standalone script requires separate Gradle configuration phase to be executed on update. \
This can be expensive for large Gradle projects.</p>\
</div>
notification.standalone.text=Standalone script
notification.standalone.disableScriptAction=Disable script
notification.standalone.info=<div width=400>\
<p>Configuration for this script will be loaded separately from Gradle project Sync. \
<br/>\
<p>This can be expensive for large Gradle projects.</p>\
</div>
action.text.install=Install
action.text.show.kotlin.gradle.dsl.logs.in=Show Kotlin Gradle DSL Logs in {0}
build.0.project=Build {0}
@@ -38,12 +61,10 @@ text.couldn.t.configure.kotlin.gradle.plugin.automatically=Couldn't configure ko
text.default.kotlin.gradle.script=Default Kotlin Gradle Script
text.gradle.dsl.logs.cannot.be.found.automatically.see.how.to.find.logs=Gradle DSL Logs cannot be found automatically.<br/>See how to find logs <a href="{0}">here</a>.
text.see.manual.installation.instructions=See manual installation instructions <a href="https://kotlinlang.org/docs/reference/using-gradle.html">here</a>.
text.the.associated.gradle.project.isn.t.imported=Cannot find related Gradle project. Kotlin DSL Code insight unavailable.
text.was.modified={0} was modified
title.configure.kotlin.gradle.plugin=Configure Kotlin-Gradle Plugin
title.kotlin.build.script=Gradle Kotlin DSL Scripts errors
title.update.language.version=Update Language Version
tool.tip.text.the.external.gradle.project.needs.to.be.imported.to.get.this.script.analyzed=The external Gradle project needs to be imported to get this script analyzed. <br/>Load related Gradle project to add it to the list of imported Gradle Projects.
display.name.kotlin.multiplatform=Kotlin/Multiplatform
display.name.kotlin.jvm=Kotlin/JVM
display.name.kotlin.js.for.node.js=Kotlin/JS for Node.js
@@ -52,9 +73,3 @@ comman.name.configure.kotlin=Configure Kotlin
command.name.configure.0=Configure {0}
notification.title.script.configuration.has.been.changed=Script configurations has been changed.
notification.text.script.configuration.has.been.changed=Gradle Project needs to be imported to load changes.
script.configurations.will.be.available.after.import=Gradle Kotlin DSL script configuration is missing. Import project to get script code insight.
script.configurations.will.be.available.after.load.changes=Gradle Kotlin DSL script configuration is missing. Load Script Configurations to get script code insight.
action.label.import.project=Import Project
action.label.enable.auto.import=Enable Auto-Import
action.text.load.script.configurations=Load Script Configurations
action.description.load.script.configurations=Gradle Kotlin DSL script configuration has been changed. Load changes to get script code insight without loading the external Gradle project.
@@ -33,7 +33,6 @@ fun runPartialGradleImport(project: Project) {
}
}
fun getMissingConfigurationNotificationText() = KotlinIdeaGradleBundle.message("script.configurations.will.be.available.after.import")
fun getMissingConfigurationActionText() = KotlinIdeaGradleBundle.message("action.label.import.project")
fun autoReloadScriptConfigurations(project: Project): Boolean {
@@ -29,48 +29,37 @@ class MissingGradleScriptConfigurationNotificationProvider(private val project:
val scriptUnderRoot = rootsManager.findScriptBuildRoot(file) ?: return null
return when (scriptUnderRoot.notificationKind) {
dontCare -> null
outsideAnyting -> EditorNotificationPanel().apply {
text("Code insight unavailable (related Gradle project not linked)")
// todo: Code insight unavailable (cannot find related Gradle project)
createActionLabel("Link related Gradle project") {
outsideAnything -> EditorNotificationPanel().apply {
text(KotlinIdeaGradleBundle.message("notification.outsideAnything.text"))
createActionLabel(KotlinIdeaGradleBundle.message("notification.outsideAnything.linkAction")) {
runPartialGradleImport(project)
}
}
wasNotImportedAfterCreation -> EditorNotificationPanel().apply {
text("Code insight unavailable (Gradle project Sync required)")
text(KotlinIdeaGradleBundle.message("notification.wasNotImportedAfterCreation.text"))
createActionLabel(getMissingConfigurationActionText()) {
runPartialGradleImport(project)
}
}
notEvaluatedInLastImport -> EditorNotificationPanel().apply {
text(KotlinIdeaGradleBundle.message("text.the.associated.gradle.project.isn.t.imported"))
text(KotlinIdeaGradleBundle.message(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.text")))
createActionLabel(KotlinIdeaGradleBundle.message("action.text.standalone")) {
createActionLabel(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.info")) {
rootsManager.updateStandaloneScripts {
addStandaloneScript(file.path)
}
}
contextHelp(
KotlinIdeaGradleBundle.message("tool.tip.text.the.external.gradle.project.needs.to.be.imported.to.get.this.script.analyzed")
)
contextHelp(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.addAsStandaloneAction"))
}
standalone -> EditorNotificationPanel().apply {
text("Standalone script")
createActionLabel("Disable script") {
text(KotlinIdeaGradleBundle.message("notification.standalone.text"))
createActionLabel(KotlinIdeaGradleBundle.message("notification.standalone.disableScriptAction")) {
rootsManager.updateStandaloneScripts {
removeStandaloneScript(file.path)
}
}
contextHelp(
"""
<div width=400>\
<p>Configuration for this script will be loaded separately from Gradle project Sync. \
<br/>
<p>This can be expensive for large Gradle projects.</p>\
</div>
"""
)
contextHelp(KotlinIdeaGradleBundle.message("notification.standalone.info"))
}
}
}
@@ -53,9 +53,10 @@ abstract class GradleBuildRootsLocator {
return findScriptBuildRoot(filePath, searchNearestLegacy = false)?.root as? GradleBuildRoot
}
@Suppress("EnumEntryName")
enum class NotificationKind {
dontCare, // one of: imported, inside linked legacy gradle build
outsideAnyting, // suggest link related gradle build or just say that there is no one
outsideAnything, // suggest link related gradle build or just say that there is no one
wasNotImportedAfterCreation, // project not yet imported after this file was created
notEvaluatedInLastImport, // all other scripts, suggest to sync or mark as standalone
standalone
@@ -78,7 +79,7 @@ abstract class GradleBuildRootsLocator {
get() = when {
isImported -> NotificationKind.dontCare
standalone -> NotificationKind.standalone
nearest == null -> NotificationKind.outsideAnyting
nearest == null -> NotificationKind.outsideAnything
nearest.importing -> NotificationKind.dontCare
else -> when (nearest) {
is Legacy -> NotificationKind.dontCare
@@ -137,10 +137,7 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
val mergedData = if (sync.failed && oldRoot is Imported) merge(oldRoot.data, newData) else newData
val lastModifiedFilesReset = LastModifiedFiles()
val newRoot = tryCreateImportedRoot(
sync.workingDir,
lastModifiedFilesReset
) { mergedData } ?: return
val newRoot = tryCreateImportedRoot(sync.workingDir, lastModifiedFilesReset) { mergedData } ?: return
GradleBuildRootDataSerializer.write(newRoot.dir ?: return, mergedData)
newRoot.saveLastModifiedFiles()