From 22c94026c68e84dbc1930254509d8a95f22ea1ce Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Tue, 10 Mar 2020 15:13:33 +0700 Subject: [PATCH] i18n: add bundle for idea-completion --- .../KotlinIdeaCompletionBundle.properties | 6 ++++++ .../idea/completion/BasicCompletionSession.kt | 9 +++++++-- .../completion/BasicLookupElementFactory.kt | 8 ++++---- ...ExcludeFromCompletionLookupActionProvider.kt | 4 ++-- .../completion/KotlinIdeaCompletionBundle.kt | 17 +++++++++++++++++ .../idea/completion/LambdaSignatureTemplates.kt | 4 ++-- 6 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 idea/idea-completion/resources/messages/KotlinIdeaCompletionBundle.properties create mode 100644 idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinIdeaCompletionBundle.kt diff --git a/idea/idea-completion/resources/messages/KotlinIdeaCompletionBundle.properties b/idea/idea-completion/resources/messages/KotlinIdeaCompletionBundle.properties new file mode 100644 index 00000000000..7597eff4cee --- /dev/null +++ b/idea/idea-completion/resources/messages/KotlinIdeaCompletionBundle.properties @@ -0,0 +1,6 @@ +exclude.0.from.completion=Exclude '{0}' from completion +insert.lambda.template=Insert lambda template +presentation.tail.for.0=\ for {0} +presentation.tail.for.0.in.1=\ for {0} in {1} +presentation.tail.from.0=\ (from {0}) +presentation.tail.in.0=in {0} \ No newline at end of file diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt index fb4a3555628..fac91eccd80 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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. */ @@ -482,7 +482,12 @@ class BasicCompletionSession( override fun renderElement(presentation: LookupElementPresentation?) { super.renderElement(presentation) - presentation?.appendTailText(" for $name in $packageName", true) + presentation?.appendTailText( + KotlinIdeaCompletionBundle.message( + "presentation.tail.for.0.in.1", + name, + packageName + ), true) } } }) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt index 68a40845b96..5a1d7d67b0b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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. */ @@ -294,12 +294,12 @@ class BasicLookupElementFactory( is SyntheticJavaPropertyDescriptor -> { var from = descriptor.getMethod.name.asString() + "()" descriptor.setMethod?.let { from += "/" + it.name.asString() + "()" } - appendTailText(" (from $from)") + appendTailText(KotlinIdeaCompletionBundle.message("presentation.tail.from.0", from)) return } else -> { val receiverPresentation = SHORT_NAMES_RENDERER.renderType(extensionReceiver.type) - appendTailText(" for $receiverPresentation") + appendTailText(KotlinIdeaCompletionBundle.message("presentation.tail.for.0", receiverPresentation)) } } } @@ -323,7 +323,7 @@ class BasicLookupElementFactory( is PackageFragmentDescriptor -> container.fqName.toString() else -> return null } - return "in $containerPresentation" + return KotlinIdeaCompletionBundle.message("presentation.tail.in.0", containerPresentation) } else -> { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt index 83ff315826a..01bb5327376 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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.idea.completion @@ -34,7 +34,7 @@ class KotlinExcludeFromCompletionLookupActionProvider : LookupActionProvider { private class ExcludeFromCompletionAction( private val project: Project, private val exclude: String - ) : LookupElementAction(null, "Exclude '$exclude' from completion") { + ) : LookupElementAction(null, KotlinIdeaCompletionBundle.message("exclude.0.from.completion", exclude)) { override fun performLookupAction(): Result { AddImportAction.excludeFromImport(project, exclude) return Result.HIDE_LOOKUP diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinIdeaCompletionBundle.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinIdeaCompletionBundle.kt new file mode 100644 index 00000000000..dfd1331d6b4 --- /dev/null +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinIdeaCompletionBundle.kt @@ -0,0 +1,17 @@ +/* + * 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.idea.completion + +import org.jetbrains.annotations.NonNls +import org.jetbrains.annotations.PropertyKey +import org.jetbrains.kotlin.util.AbstractKotlinBundle + +@NonNls +private const val BUNDLE = "messages.KotlinIdeaCompletionBundle" + +object KotlinIdeaCompletionBundle : AbstractKotlinBundle(BUNDLE) { + @JvmStatic + fun message(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String = getMessage(key, *params) +} \ No newline at end of file diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LambdaSignatureTemplates.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LambdaSignatureTemplates.kt index 8fb41cd8b11..553f4d9446b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LambdaSignatureTemplates.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LambdaSignatureTemplates.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * 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. */ @@ -43,7 +43,7 @@ object LambdaSignatureTemplates { ) { // we start template later to not interfere with insertion of tail type val commandProcessor = CommandProcessor.getInstance() - val commandName = commandProcessor.currentCommandName ?: "Insert lambda template" + val commandName = commandProcessor.currentCommandName ?: KotlinIdeaCompletionBundle.message("insert.lambda.template") val commandGroupId = commandProcessor.currentCommandGroupId val rangeMarker = context.document.createRangeMarker(placeholderRange)