From d4491af96f65508f559b7b0220b580bfeb6189d1 Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Mon, 6 Apr 2020 23:15:37 +0700 Subject: [PATCH] i18n: update bundles #KT-37483 --- .../messages/KotlinBundle.properties | 10 ++++++++- .../idea/actions/NewKotlinFileAction.kt | 22 ++++++------------- .../outdatedBundledCompilerNotification.kt | 6 ++--- .../cutPaste/MoveDeclarationsProcessor.kt | 3 ++- .../extractionEngine/ExtractionEngine.kt | 4 +++- .../idea/refactoring/kotlinRefactoringUtil.kt | 10 ++++----- .../refactoring/kotlinRefactoringUtil.kt.192 | 10 ++++----- .../PackageDirectoryMismatchInspection.kt | 8 +++++-- .../ui/MoveKotlinTopLevelDeclarationsModel.kt | 2 +- .../KotlinScriptDefinitionsModel.kt | 18 ++++++++++----- 10 files changed, 53 insertions(+), 40 deletions(-) diff --git a/idea/resources/messages/KotlinBundle.properties b/idea/resources/messages/KotlinBundle.properties index 172cc14cb33..a1ad3885d0c 100644 --- a/idea/resources/messages/KotlinBundle.properties +++ b/idea/resources/messages/KotlinBundle.properties @@ -2186,4 +2186,12 @@ intention.convert.lambda.line=Convert to {0,choice,0#single|1#multi}-line lambda intention.trailing.comma.custom.text={0,choice,0#Enable|1#Disable} a trailing comma by default in the formatter intention.trailing.comma.text=Enable/disable a trailing comma in the formatter fix.remove.argument.text=Remove argument -fix.remove.redundant.star.text=Remove redundant * \ No newline at end of file +fix.remove.redundant.star.text=Remove redundant * +refactoring.extract.to.separate.file.text=Extract to separate file +action.usage.update.text=Usage update +progress.title.analyze.extraction.data=Analyze extraction data... +fix.move.file.to.package.dir.name.text=source root +move.refactoring.error.text.cannot.perform.refactoring.since.the.following.files.already.exist=Cannot perform refactoring since the following files already exist:\n\n +kotlin.script.definitions.model.name.is.enabled=Is Enabled +kotlin.script.definitions.model.name.pattern.extension=Pattern/Extension +kotlin.script.definitions.model.name.name=Name \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/NewKotlinFileAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/NewKotlinFileAction.kt index 71ac463899a..3c2e65abbc8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/NewKotlinFileAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/NewKotlinFileAction.kt @@ -116,9 +116,8 @@ class NewKotlinFileAction : CreateFileFromTemplateAction( builder.setValidator(NameValidator) } - override fun getActionName(directory: PsiDirectory, newName: String, templateName: String): String { - return KotlinBundle.message("action.new.file.text") - } + override fun getActionName(directory: PsiDirectory, newName: String, templateName: String): String = + KotlinBundle.message("action.new.file.text") override fun isAvailable(dataContext: DataContext): Boolean { if (super.isAvailable(dataContext)) { @@ -127,16 +126,13 @@ class NewKotlinFileAction : CreateFileFromTemplateAction( val projectFileIndex = ProjectRootManager.getInstance(project).fileIndex return ideView.directories.any { projectFileIndex.isInSourceContent(it.virtualFile) } } + return false } - override fun hashCode(): Int { - return 0 - } + override fun hashCode(): Int = 0 - override fun equals(other: Any?): Boolean { - return other is NewKotlinFileAction - } + override fun equals(other: Any?): Boolean = other is NewKotlinFileAction override fun startInWriteAction() = false @@ -158,13 +154,9 @@ class NewKotlinFileAction : CreateFileFromTemplateAction( return null } - override fun checkInput(inputString: String): Boolean { - return true - } + override fun checkInput(inputString: String): Boolean = true - override fun canClose(inputString: String): Boolean { - return getErrorText(inputString) == null - } + override fun canClose(inputString: String): Boolean = getErrorText(inputString) == null } @get:TestOnly diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/outdatedBundledCompilerNotification.kt b/idea/src/org/jetbrains/kotlin/idea/configuration/outdatedBundledCompilerNotification.kt index 01501bc13a2..48272dd2c55 100644 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/outdatedBundledCompilerNotification.kt +++ b/idea/src/org/jetbrains/kotlin/idea/configuration/outdatedBundledCompilerNotification.kt @@ -52,14 +52,14 @@ fun notifyOutdatedBundledCompilerIfNecessary(project: Project) { NotificationType.WARNING, NotificationListener { notification, event -> if (event.eventType == HyperlinkEvent.EventType.ACTIVATED) { - when { - "update" == event.description -> { + when (event.description) { + "update" -> { val action = ActionManager.getInstance().getAction(ConfigurePluginUpdatesAction.ACTION_ID) val dataContext = DataManager.getInstance().dataContextFromFocus.result val actionEvent = AnActionEvent.createFromAnAction(action, null, ActionPlaces.ACTION_SEARCH, dataContext) action.actionPerformed(actionEvent) } - "ignore" == event.description -> { + "ignore" -> { if (!project.isDisposed) { PropertiesComponent.getInstance(project).setValue(SUPPRESSED_OUTDATED_COMPILER_PROPERTY_NAME, pluginVersion) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsProcessor.kt index 3e7bfe69fcc..f366ae85d02 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsProcessor.kt @@ -13,6 +13,7 @@ import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiManager import com.intellij.refactoring.RefactoringBundle +import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor import org.jetbrains.kotlin.idea.codeInsight.shorten.runRefactoringAndKeepDelayedRequests import org.jetbrains.kotlin.idea.core.util.range @@ -87,7 +88,7 @@ class MoveDeclarationsProcessor( fun performRefactoring() { psiDocumentManager.commitAllDocuments() - val commandName = "Usage update" + val commandName = KotlinBundle.message("action.usage.update.text") val commandGroupId = Any() // we need to group both commands for undo // temporary revert imports to the state before they have been changed diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionEngine.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionEngine.kt index d58847c6ded..8e78fcbf303 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionEngine.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionEngine.kt @@ -60,7 +60,9 @@ class ExtractionEngine( val project = extractionData.project val adjustExtractionData = helper.adjustExtractionData(extractionData) - val analysisResult = ProgressIndicatorUtils.underModalProgress(project, "Analyze extraction data...") { + val analysisResult = ProgressIndicatorUtils.underModalProgress(project, + KotlinBundle.message("progress.title.analyze.extraction.data") + ) { adjustExtractionData.performAnalysis() } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt index d3811e4ba6d..82218c42801 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt @@ -375,10 +375,10 @@ fun chooseContainerElement( private fun PsiElement.renderDeclaration(): String? { if (this is KtFunctionLiteral || isFunctionalExpression()) return renderText() - val descriptor = when { - this is KtFile -> name - this is KtElement -> analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this] - this is PsiMember -> getJavaMemberDescriptor() + val descriptor = when (this) { + is KtFile -> name + is KtElement -> analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this] + is PsiMember -> getJavaMemberDescriptor() else -> null } ?: return null val name = renderName() @@ -391,7 +391,7 @@ fun chooseContainerElement( } private fun PsiElement.renderText(): String = when (this) { - is SeparateFileWrapper -> "Extract to separate file" + is SeparateFileWrapper -> KotlinBundle.message("refactoring.extract.to.separate.file.text") is PsiPackageBase -> qualifiedName else -> { val text = text ?: "" diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt.192 b/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt.192 index 598356dc397..a3e1cd1b2e9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt.192 +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt.192 @@ -376,10 +376,10 @@ fun chooseContainerElement( private fun PsiElement.renderDeclaration(): String? { if (this is KtFunctionLiteral || isFunctionalExpression()) return renderText() - val descriptor = when { - this is KtFile -> name - this is KtElement -> analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this] - this is PsiMember -> getJavaMemberDescriptor() + val descriptor = when (this) { + is KtFile -> name + is KtElement -> analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this] + is PsiMember -> getJavaMemberDescriptor() else -> null } ?: return null val name = renderName() @@ -392,7 +392,7 @@ fun chooseContainerElement( } private fun PsiElement.renderText(): String = when (this) { - is SeparateFileWrapper -> "Extract to separate file" + is SeparateFileWrapper -> KotlinBundle.message("refactoring.extract.to.separate.file.text") is PsiPackageBase -> qualifiedName else -> { val text = text ?: "" diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/PackageDirectoryMismatchInspection.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/PackageDirectoryMismatchInspection.kt index 1bcac6cb3b2..4ecd2e563e8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/PackageDirectoryMismatchInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/PackageDirectoryMismatchInspection.kt @@ -40,12 +40,16 @@ class PackageDirectoryMismatchInspection : AbstractKotlinInspection() { val fixes = mutableListOf() val qualifiedName = directive.qualifiedName - val dirName = if (qualifiedName.isEmpty()) "source root" else "'${qualifiedName.replace('.', '/')}'" + val dirName = if (qualifiedName.isEmpty()) + KotlinBundle.message("fix.move.file.to.package.dir.name.text") + else + "'${qualifiedName.replace('.', '/')}'" + fixes += MoveFileToPackageFix(dirName) val fqNameByDirectory = file.getFqNameByDirectory() when { fqNameByDirectory.isRoot -> - fixes += ChangePackageFix("source root", fqNameByDirectory) + fixes += ChangePackageFix(KotlinBundle.message("fix.move.file.to.package.dir.name.text"), fqNameByDirectory) fqNameByDirectory.hasIdentifiersOnly() -> fixes += ChangePackageFix("'${fqNameByDirectory.asString()}'", fqNameByDirectory) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinTopLevelDeclarationsModel.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinTopLevelDeclarationsModel.kt index a7133aabd91..22cea62278e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinTopLevelDeclarationsModel.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinTopLevelDeclarationsModel.kt @@ -114,7 +114,7 @@ internal class MoveKotlinTopLevelDeclarationsModel( } else { val filePathsToReport = filesExistingInTargetDir.joinToString( separator = "\n", - prefix = "Cannot perform refactoring since the following files already exist:\n\n" + prefix = KotlinBundle.message("move.refactoring.error.text.cannot.perform.refactoring.since.the.following.files.already.exist") ) { it.virtualFile.path } throw ConfigurationException(filePathsToReport) } diff --git a/idea/src/org/jetbrains/kotlin/idea/script/configuration/KotlinScriptDefinitionsModel.kt b/idea/src/org/jetbrains/kotlin/idea/script/configuration/KotlinScriptDefinitionsModel.kt index f6d5bd6bee0..ce63738a253 100644 --- a/idea/src/org/jetbrains/kotlin/idea/script/configuration/KotlinScriptDefinitionsModel.kt +++ b/idea/src/org/jetbrains/kotlin/idea/script/configuration/KotlinScriptDefinitionsModel.kt @@ -9,6 +9,7 @@ import com.intellij.ui.BooleanTableCellEditor import com.intellij.ui.BooleanTableCellRenderer import com.intellij.util.ui.ColumnInfo import com.intellij.util.ui.ListTableModel +import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.core.script.StandardIdeScriptDefinition import org.jetbrains.kotlin.idea.core.script.settings.KotlinScriptingSettings import org.jetbrains.kotlin.scripting.definitions.ScriptDefinition @@ -32,11 +33,15 @@ class KotlinScriptDefinitionsModel private constructor(definitions: MutableList< items = definitions.mapTo(arrayListOf()) { KotlinScriptDefinitionsModelDescriptor(it, settings.isScriptDefinitionEnabled(it)) } } - private class ScriptDefinitionName : ColumnInfo("Name") { + private class ScriptDefinitionName : ColumnInfo( + KotlinBundle.message("kotlin.script.definitions.model.name.name") + ) { override fun valueOf(item: KotlinScriptDefinitionsModelDescriptor) = item.definition.name } - private class ScriptDefinitionPattern : ColumnInfo("Pattern/Extension") { + private class ScriptDefinitionPattern : ColumnInfo( + KotlinBundle.message("kotlin.script.definitions.model.name.pattern.extension") + ) { override fun valueOf(item: KotlinScriptDefinitionsModelDescriptor): String { val definition = item.definition return definition.asLegacyOrNull()?.scriptFilePattern?.pattern @@ -45,7 +50,9 @@ class KotlinScriptDefinitionsModel private constructor(definitions: MutableList< } } - private class ScriptDefinitionIsEnabled : ColumnInfo("Is Enabled") { + private class ScriptDefinitionIsEnabled : ColumnInfo( + KotlinBundle.message("kotlin.script.definitions.model.name.is.enabled") + ) { override fun valueOf(item: KotlinScriptDefinitionsModelDescriptor): Boolean = item.isEnabled override fun setValue(item: KotlinScriptDefinitionsModelDescriptor, value: Boolean) { item.isEnabled = value @@ -58,13 +65,12 @@ class KotlinScriptDefinitionsModel private constructor(definitions: MutableList< } companion object { - fun createModel(definitions: List, settings: KotlinScriptingSettings): KotlinScriptDefinitionsModel { - return KotlinScriptDefinitionsModel(definitions.mapTo(arrayListOf()) { + fun createModel(definitions: List, settings: KotlinScriptingSettings): KotlinScriptDefinitionsModel = + KotlinScriptDefinitionsModel(definitions.mapTo(arrayListOf()) { KotlinScriptDefinitionsModelDescriptor( it, settings.isScriptDefinitionEnabled(it) ) }) - } } } \ No newline at end of file