i18n: Add bundle for idea-gradle-native

This commit is contained in:
Yan Zhulanow
2020-02-19 21:54:57 +09:00
committed by Dmitry Gridin
parent 4e634b2b01
commit 40bdc099e3
6 changed files with 100 additions and 89 deletions
@@ -0,0 +1,18 @@
native.gradle.name=Native | Gradle
native.gradle.name.short=Native
native.gradle.description=Gradle-based Kotlin project for native binaries
error.incompatible.libraries.title=Incompatible Kotlin/Native libraries
error.incompatible.libraries=There {0,choice,1#is a library|2#are {0} libraries} libraries from the Kotlin/Native {1} distribution attached to the project: {2}
error.incompatible.libraries.newer=These libraries were compiled with a newer Kotlin/Native compiler and can't be read in IDE.
error.incompatible.libraries.older=These libraries were compiled with an older Kotlin/Native compiler and can't be read in IDE.
error.incompatible.libraries.recipe=Please edit Gradle buildfile(s) to use Kotlin Gradle plugin version {0}. Then re-import the project in IDE.
error.incompatible.3p.libraries.newer=There {0,choice,1#is a third-party library|2#are {0} third-party libraries} attached to the project that {0,choice,1#was|2#were} compiled with a newer Kotlin/Native compiler and can't be read in IDE:
error.incompatible.3p.libraries.older=There {0,choice,1#is a third-party library|2#are {0} third-party libraries} attached to the project that {0,choice,1#was|2#were} compiled with an older Kotlin/Native compiler and can't be read in IDE:
error.incompatible.3p.libraries.recipe=Please edit Gradle buildfile(s) and specify library a version compatible with Kotlin/Native {0}. Then re-import the project in IDE.
error.incompatible.user.libraries.newer=There {0,choice,1#is a library|2#are {0} third-party libraries} attached to the project that {0,choice,1#was|2#were} compiled with a newer Kotlin/Native compiler and can't be read in IDE:
error.incompatible.user.libraries.older=There {0,choice,1#is a library|2#are {0} third-party libraries} attached to the project that {0,choice,1#was|2#were} compiled with an older Kotlin/Native compiler and can't be read in IDE:
error.incompatible.user.libraries.recipe=Please edit Gradle buildfile(s) to use Kotlin Gradle plugin version {0}. Then rebuild the project and re-import it in IDE.
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ide.konan
import com.intellij.CommonBundle
import org.jetbrains.annotations.NonNls
import org.jetbrains.annotations.PropertyKey
import org.jetbrains.kotlin.idea.core.util.KotlinBundleBase
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinDebuggerEvaluationBundle
import java.util.*
object KotlinGradleNativeBundle : KotlinBundleBase() {
@NonNls
private const val BUNDLE = "org.jetbrains.kotlin.ide.konan.KotlinGradleNativeBundle"
override fun createBundle(): ResourceBundle = ResourceBundle.getBundle(BUNDLE)
@JvmStatic
fun message(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any?): String {
return CommonBundle.message(KotlinDebuggerEvaluationBundle.bundle, key, *params)
}
}
@@ -124,37 +124,30 @@ class KotlinNativeABICompatibilityChecker(private val project: Project) : Projec
val libraries =
librariesByGroups.getValue(key).sortedWith(compareBy(LIBRARY_NAME_COMPARATOR) { (libraryName, _) -> libraryName })
val compilerVersionText = if (isOldMetadata) "an older" else "a newer"
val message = when (libraryGroup) {
is LibraryGroup.FromDistribution -> {
val libraryNamesInOneLine =
libraries.joinToString(limit = MAX_LIBRARY_NAMES_IN_ONE_LINE) { (libraryName, _) -> libraryName }
"""
|There are ${libraries.size} libraries from the Kotlin/Native ${libraryGroup.kotlinVersion} distribution attached to the project: $libraryNamesInOneLine
|
|These libraries were compiled with $compilerVersionText Kotlin/Native compiler and can't be read in IDE. Please edit Gradle buildfile(s) to use Kotlin Gradle plugin version ${bundledRuntimeVersion()}. Then re-import the project in IDE.
""".trimMargin()
val libraryNamesInOneLine = libraries
.joinToString(limit = MAX_LIBRARY_NAMES_IN_ONE_LINE) { (libraryName, _) -> libraryName }
val text = KotlinGradleNativeBundle.message(
"error.incompatible.libraries",
libraries.size, libraryGroup.kotlinVersion, libraryNamesInOneLine
)
val explanation = when (isOldMetadata) {
true -> KotlinGradleNativeBundle.message("error.incompatible.libraries.older")
false -> KotlinGradleNativeBundle.message("error.incompatible.libraries.newer")
}
val recipe = KotlinGradleNativeBundle.message("error.incompatible.libraries.recipe", bundledRuntimeVersion())
"$text\n\n$explanation\n$recipe"
}
is LibraryGroup.ThirdParty -> {
if (libraries.size == 1) {
"""
|There is a third-party library attached to the project that was compiled with $compilerVersionText Kotlin/Native compiler and can't be read in IDE: ${libraries.single()
.first}
|
|Please edit Gradle buildfile(s) and specify library version compatible with Kotlin/Native ${bundledRuntimeVersion()}. Then re-import the project in IDE.
""".trimMargin()
} else {
val librariesLineByLine = libraries.joinToString(separator = "\n") { (libraryName, _) -> libraryName }
"""
|There are ${libraries.size} third-party libraries attached to the project that were compiled with $compilerVersionText Kotlin/Native compiler and can't be read in IDE:
|$librariesLineByLine
|
|Please edit Gradle buildfile(s) and specify library versions compatible with Kotlin/Native ${bundledRuntimeVersion()}. Then re-import the project in IDE.
""".trimMargin()
val text = when (isOldMetadata) {
true -> KotlinGradleNativeBundle.message("error.incompatible.3p.libraries.older", libraries.size)
false -> KotlinGradleNativeBundle.message("error.incompatible.3p.libraries.newer", libraries.size)
}
val librariesLineByLine = libraries.joinToString(separator = "\n") { (libraryName, _) -> libraryName }
val recipe = KotlinGradleNativeBundle.message("error.incompatible.3p.libraries.recipe", bundledRuntimeVersion())
"$text\n$librariesLineByLine\n\n$recipe"
}
is LibraryGroup.User -> {
val projectRoot = project.guessProjectDir()?.canonicalPath
@@ -172,23 +165,13 @@ class KotlinNativeABICompatibilityChecker(private val project: Project) : Projec
return "\"$libraryName\" at $relativeRoot"
}
if (libraries.size == 1) {
"""
|There is a library attached to the project that was compiled with $compilerVersionText Kotlin/Native compiler and can't be read in IDE:
|${getLibraryTextToPrint(libraries.single())}
|
|Please edit Gradle buildfile(s) to use Kotlin Gradle plugin version ${bundledRuntimeVersion()}. Then rebuild the project and re-import it in IDE.
""".trimMargin()
} else {
val librariesLineByLine = libraries.joinToString(separator = "\n", transform = ::getLibraryTextToPrint)
"""
|There are ${libraries.size} libraries attached to the project that were compiled with $compilerVersionText Kotlin/Native compiler and can't be read in IDE:
|$librariesLineByLine
|
|Please edit Gradle buildfile(s) to use Kotlin Gradle plugin version ${bundledRuntimeVersion()}. Then rebuild the project and re-import it in IDE.
""".trimMargin()
val text = when (isOldMetadata) {
true -> KotlinGradleNativeBundle.message("error.incompatible.user.libraries.older", libraries.size)
false -> KotlinGradleNativeBundle.message("error.incompatible.user.libraries.newer", libraries.size)
}
val librariesLineByLine = libraries.joinToString(separator = "\n", transform = ::getLibraryTextToPrint)
val recipe = KotlinGradleNativeBundle.message("error.incompatible.user.libraries.recipe", bundledRuntimeVersion())
"$text\n$librariesLineByLine\n\n$recipe"
}
}
@@ -236,7 +219,7 @@ class KotlinNativeABICompatibilityChecker(private val project: Project) : Projec
private const val MAX_LIBRARY_NAMES_IN_ONE_LINE = 5
private const val NOTIFICATION_TITLE = "Incompatible Kotlin/Native libraries"
private const val NOTIFICATION_GROUP_ID = NOTIFICATION_TITLE
private val NOTIFICATION_TITLE = KotlinGradleNativeBundle.message("error.incompatible.libraries.title")
private val NOTIFICATION_GROUP_ID = NOTIFICATION_TITLE
}
}
@@ -125,37 +125,30 @@ class KotlinNativeABICompatibilityChecker(private val project: Project) : Projec
val libraries =
librariesByGroups.getValue(key).sortedWith(compareBy(LIBRARY_NAME_COMPARATOR) { (libraryName, _) -> libraryName })
val compilerVersionText = if (isOldMetadata) "an older" else "a newer"
val message = when (libraryGroup) {
is LibraryGroup.FromDistribution -> {
val libraryNamesInOneLine =
libraries.joinToString(limit = MAX_LIBRARY_NAMES_IN_ONE_LINE) { (libraryName, _) -> libraryName }
"""
|There are ${libraries.size} libraries from the Kotlin/Native ${libraryGroup.kotlinVersion} distribution attached to the project: $libraryNamesInOneLine
|
|These libraries were compiled with $compilerVersionText Kotlin/Native compiler and can't be read in IDE. Please edit Gradle buildfile(s) to use Kotlin Gradle plugin version ${bundledRuntimeVersion()}. Then re-import the project in IDE.
""".trimMargin()
val libraryNamesInOneLine = libraries
.joinToString(limit = MAX_LIBRARY_NAMES_IN_ONE_LINE) { (libraryName, _) -> libraryName }
val text = KotlinGradleNativeBundle.message(
"error.incompatible.libraries",
libraries.size, libraryGroup.kotlinVersion, libraryNamesInOneLine
)
val explanation = when (isOldMetadata) {
true -> KotlinGradleNativeBundle.message("error.incompatible.libraries.older")
false -> KotlinGradleNativeBundle.message("error.incompatible.libraries.newer")
}
val recipe = KotlinGradleNativeBundle.message("error.incompatible.libraries.recipe", bundledRuntimeVersion())
"$text\n\n$explanation\n$recipe"
}
is LibraryGroup.ThirdParty -> {
if (libraries.size == 1) {
"""
|There is a third-party library attached to the project that was compiled with $compilerVersionText Kotlin/Native compiler and can't be read in IDE: ${libraries.single()
.first}
|
|Please edit Gradle buildfile(s) and specify library version compatible with Kotlin/Native ${bundledRuntimeVersion()}. Then re-import the project in IDE.
""".trimMargin()
} else {
val librariesLineByLine = libraries.joinToString(separator = "\n") { (libraryName, _) -> libraryName }
"""
|There are ${libraries.size} third-party libraries attached to the project that were compiled with $compilerVersionText Kotlin/Native compiler and can't be read in IDE:
|$librariesLineByLine
|
|Please edit Gradle buildfile(s) and specify library versions compatible with Kotlin/Native ${bundledRuntimeVersion()}. Then re-import the project in IDE.
""".trimMargin()
val text = when (isOldMetadata) {
true -> KotlinGradleNativeBundle.message("error.incompatible.3p.libraries.older", libraries.size)
false -> KotlinGradleNativeBundle.message("error.incompatible.3p.libraries.newer", libraries.size)
}
val librariesLineByLine = libraries.joinToString(separator = "\n") { (libraryName, _) -> libraryName }
val recipe = KotlinGradleNativeBundle.message("error.incompatible.3p.libraries.recipe", bundledRuntimeVersion())
"$text\n$librariesLineByLine\n\n$recipe"
}
is LibraryGroup.User -> {
val projectRoot = project.guessProjectDir()?.canonicalPath
@@ -173,23 +166,13 @@ class KotlinNativeABICompatibilityChecker(private val project: Project) : Projec
return "\"$libraryName\" at $relativeRoot"
}
if (libraries.size == 1) {
"""
|There is a library attached to the project that was compiled with $compilerVersionText Kotlin/Native compiler and can't be read in IDE:
|${getLibraryTextToPrint(libraries.single())}
|
|Please edit Gradle buildfile(s) to use Kotlin Gradle plugin version ${bundledRuntimeVersion()}. Then rebuild the project and re-import it in IDE.
""".trimMargin()
} else {
val librariesLineByLine = libraries.joinToString(separator = "\n", transform = ::getLibraryTextToPrint)
"""
|There are ${libraries.size} libraries attached to the project that were compiled with $compilerVersionText Kotlin/Native compiler and can't be read in IDE:
|$librariesLineByLine
|
|Please edit Gradle buildfile(s) to use Kotlin Gradle plugin version ${bundledRuntimeVersion()}. Then rebuild the project and re-import it in IDE.
""".trimMargin()
val text = when (isOldMetadata) {
true -> KotlinGradleNativeBundle.message("error.incompatible.user.libraries.older", libraries.size)
false -> KotlinGradleNativeBundle.message("error.incompatible.user.libraries.newer", libraries.size)
}
val librariesLineByLine = libraries.joinToString(separator = "\n", transform = ::getLibraryTextToPrint)
val recipe = KotlinGradleNativeBundle.message("error.incompatible.user.libraries.recipe", bundledRuntimeVersion())
"$text\n$librariesLineByLine\n\n$recipe"
}
}
@@ -237,7 +220,7 @@ class KotlinNativeABICompatibilityChecker(private val project: Project) : Projec
private const val MAX_LIBRARY_NAMES_IN_ONE_LINE = 5
private const val NOTIFICATION_TITLE = "Incompatible Kotlin/Native libraries"
private const val NOTIFICATION_GROUP_ID = NOTIFICATION_TITLE
private val NOTIFICATION_TITLE = KotlinGradleNativeBundle.message("error.incompatible.libraries.title")
private val NOTIFICATION_GROUP_ID = NOTIFICATION_TITLE
}
}
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.ide.konan.gradle
import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.kotlin.ide.konan.KotlinGradleNativeBundle
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.configuration.KotlinGradleAbstractMultiplatformModuleBuilder
import org.jetbrains.kotlin.konan.target.presetName
@@ -26,9 +27,9 @@ class KotlinGradleNativeMultiplatformModuleBuilder : KotlinGradleAbstractMultipl
override fun getBuilderId() = "kotlin.gradle.multiplatform.native"
override fun getPresentableName() = "Native | Gradle"
override fun getPresentableName() = KotlinGradleNativeBundle.message("native.gradle.name")
override fun getDescription() = "Gradle-based Kotlin project for native binaries"
override fun getDescription() = KotlinGradleNativeBundle.message("native.gradle.description")
override val notImportedCommonSourceSets = true
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.ide.konan.gradle
import org.jetbrains.kotlin.ide.konan.KotlinGradleNativeBundle
import org.jetbrains.kotlin.ide.konan.hasKotlinNativeRuntimeInScope
import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinStatus
import org.jetbrains.kotlin.idea.configuration.KotlinWithGradleConfigurator
@@ -37,6 +38,6 @@ open class KotlinNativeGradleConfigurator : KotlinWithGradleConfigurator() {
companion object {
const val NAME = "KotlinNative"
const val PRESENTABLE_TEXT = "Native"
val PRESENTABLE_TEXT = KotlinGradleNativeBundle.message("native.gradle.name.short")
}
}