diff --git a/python/ide/impl/resources/messages/PyCharmCommunityCustomizationBundle.properties b/python/ide/impl/resources/messages/PyCharmCommunityCustomizationBundle.properties index 42e104e98274..cb4cf435a8f7 100644 --- a/python/ide/impl/resources/messages/PyCharmCommunityCustomizationBundle.properties +++ b/python/ide/impl/resources/messages/PyCharmCommunityCustomizationBundle.properties @@ -23,4 +23,10 @@ sdk.detect.condaenv.exception.dialog.title=Failed To Get Conda Environments sdk.create.pipenv.suggestion=Create a pipenv environment using {0} sdk.create.pipenv.permission=File Pipfile contains project dependencies. Would you like to create a pipenv environment using it? -sdk.create.pipenv.exception.dialog.title=Failed To Create Pipenv Environment \ No newline at end of file +sdk.create.pipenv.exception.dialog.title=Failed To Create Pipenv Environment + +sdk.create.poetry.environment=Create a poetry environment using {0} +sdk.progress.text.setting.up.poetry.environment=Setting up poetry environment +sdk.dialog.title.failed.to.create.poetry.environment=Failed To Create Poetry Environment +sdk.dialog.title.setting.up.poetry.environment=Setting Up Poetry Environment +sdk.notification.label.create.poetry.environment.from.pyproject.toml.dependencies=File pyproject.toml contains project dependencies. Would you like to create a poetry environment using it? \ No newline at end of file diff --git a/python/ide/impl/src/com/jetbrains/python/sdk/configuration/PyPoetrySdkConfiguration.kt b/python/ide/impl/src/com/jetbrains/python/sdk/configuration/PyPoetrySdkConfiguration.kt index 205f5655a546..ecfe57252c69 100644 --- a/python/ide/impl/src/com/jetbrains/python/sdk/configuration/PyPoetrySdkConfiguration.kt +++ b/python/ide/impl/src/com/jetbrains/python/sdk/configuration/PyPoetrySdkConfiguration.kt @@ -19,6 +19,7 @@ import com.intellij.openapi.vfs.StandardFileSystems import com.intellij.ui.IdeBorderFactory import com.intellij.ui.components.JBLabel import com.intellij.util.ui.JBUI +import com.jetbrains.python.PyCharmCommunityCustomizationBundle import com.jetbrains.python.sdk.* import com.jetbrains.python.sdk.poetry.* import java.awt.BorderLayout @@ -37,7 +38,7 @@ class PyPoetrySdkConfiguration : PyProjectSdkConfigurationExtension { override fun createAndAddSdkForConfigurator(module: Module): Sdk? = createAndAddSDk(module, false) override fun getIntention(module: Module): @IntentionName String? = - module.pyProjectToml?.let { "Create a poetry environment using ${it.name}" } + module.pyProjectToml?.let { PyCharmCommunityCustomizationBundle.message("sdk.create.poetry.environment", it.name) } override fun createAndAddSdkForInspection(module: Module): Sdk? = createAndAddSDk(module, true) @@ -70,7 +71,7 @@ class PyPoetrySdkConfiguration : PyProjectSdkConfigurationExtension { } private fun createPoetry(module: Module): Sdk? { - ProgressManager.progress("Setting up poetry environment") + ProgressManager.progress(PyCharmCommunityCustomizationBundle.message("sdk.progress.text.setting.up.poetry.environment")) LOGGER.debug("Creating poetry environment") val basePath = module.basePath ?: return null @@ -82,7 +83,8 @@ class PyPoetrySdkConfiguration : PyProjectSdkConfigurationExtension { } catch (e: ExecutionException) { LOGGER.warn("Exception during creating poetry environment", e) - showSdkExecutionException(null, e, "Failed To Create Poetry Environment") + showSdkExecutionException(null, e, + PyCharmCommunityCustomizationBundle.message("sdk.dialog.title.failed.to.create.poetry.environment")) return null } @@ -126,14 +128,14 @@ class PyPoetrySdkConfiguration : PyProjectSdkConfigurationExtension { get() = panel.envData init { - title = "Setting Up Poetry Environment" + title = PyCharmCommunityCustomizationBundle.message("sdk.dialog.title.setting.up.poetry.environment") init() } override fun createCenterPanel(): JComponent { return JPanel(BorderLayout()).apply { val border = IdeBorderFactory.createEmptyBorder(Insets(4, 0, 6, 0)) - val message = "File pyproject.toml contains project dependencies. Would you like to create a poetry environment using it?" + val message = PyCharmCommunityCustomizationBundle.message("sdk.notification.label.create.poetry.environment.from.pyproject.toml.dependencies") add( JBUI.Panels.simplePanel(JBLabel(message)).withBorder(border), diff --git a/python/pluginResources/messages/PyBundle.properties b/python/pluginResources/messages/PyBundle.properties index c92cafe2d92f..fe572225480e 100644 --- a/python/pluginResources/messages/PyBundle.properties +++ b/python/pluginResources/messages/PyBundle.properties @@ -334,6 +334,7 @@ python.sdk.pipenv.pip.file.watcher=Pipfile Watcher python.sdk.new.project.environment=Environment: python.sdk.new.project.environment.type=Environment type: +# Poetry package manager and SDK python.sdk.poetry.executable.not.found=Poetry executable is not found python.sdk.poetry.executable=Poetry executable: python.sdk.poetry.select.executable.title=Select Path to Poetry Executable @@ -352,7 +353,15 @@ python.sdk.poetry.pip.file.notification.locking=Locking poetry.lock python.sdk.poetry.pip.file.notification.locking.without.updating=Locking poetry.lock without updating python.sdk.poetry.pip.file.notification.updating=Updating Poetry environment python.sdk.poetry.pip.file.watcher=pyproject.toml Watcher - +python.sdk.dialog.title.setting.up.poetry.environment=Setting Up Poetry Environment +python.sdk.intention.family.name.install.requirements.from.poetry.lock=Install requirements from poetry.lock +python.sdk.inspection.message.version.outdated.latest=''{0}'' version {1} is outdated (latest: {2}) +python.sdk.dialog.message.cannot.find.script.file.please.run.poetry.install.before.executing.scripts=Cannot find a script file\nPlease run 'poetry install' before executing scripts +python.sdk.dialog.title.poetry.scripts=Poetry Scripts +python.sdk.poetry.action.run.script.text=Run ''{0}'' +python.sdk.inspection.message.poetry.interpreter.associated.with.another.project=Poetry interpreter is associated with another {0}: {1} +python.sdk.inspection.message.poetry.interpreter.not.associated.with.any.project=Poetry interpreter is not associated with any {0} +python.sdk.dialog.message.creating.virtual.environments.based.on.poetry.environments.not.supported=Creating virtual environments based on Poetry environments is not supported python.sdk.file.not.found=File {0} is not found python.sdk.cannot.execute=Cannot execute {0} @@ -1239,4 +1248,4 @@ python.console.command.queue.show.action.text=Show Command Queue python.console.command.queue.show.action.description=Shows a window with the command queue python.console.command.queue.got.it.tooltip.id=python.console.command.queue.show python.console.command.queue.got.it.tooltip.title=Console Command Queue -python.console.command.queue.got.it.tooltip.text=Commands queued in line for execution are listed in the Command Queue popup \ No newline at end of file +python.console.command.queue.got.it.tooltip.text=Commands queued in line for execution are listed in the Command Queue popup diff --git a/python/src/com/jetbrains/python/sdk/poetry/PoetryPackageVersionsInspection.kt b/python/src/com/jetbrains/python/sdk/poetry/PoetryPackageVersionsInspection.kt index 73b341d01adf..eefeb91b3502 100644 --- a/python/src/com/jetbrains/python/sdk/poetry/PoetryPackageVersionsInspection.kt +++ b/python/src/com/jetbrains/python/sdk/poetry/PoetryPackageVersionsInspection.kt @@ -7,6 +7,7 @@ import com.intellij.openapi.module.ModuleUtilCore import com.intellij.psi.PsiElement import com.intellij.psi.PsiElementVisitor import com.intellij.psi.PsiFile +import com.jetbrains.python.PyBundle import com.jetbrains.python.packaging.PyPackageManager import com.jetbrains.python.sdk.* import org.toml.lang.psi.* @@ -44,7 +45,8 @@ class PoetryPackageVersionsInspection : LocalInspectionTool() { val outdatedVersion = (PyPackageManager.getInstance( sdk) as? PyPoetryPackageManager)?.let { it.getOutdatedPackages()[packageName] } if (outdatedVersion is PoetryOutdatedVersion) { - val message = "'${packageName}' version ${outdatedVersion.currentVersion} is outdated (latest: ${outdatedVersion.latestVersion})" + val message = PyBundle.message("python.sdk.inspection.message.version.outdated.latest", + packageName, outdatedVersion.currentVersion, outdatedVersion.latestVersion) holder.registerProblem(keyValue, message, ProblemHighlightType.WARNING) } } diff --git a/python/src/com/jetbrains/python/sdk/poetry/PoetryRunScript.kt b/python/src/com/jetbrains/python/sdk/poetry/PoetryRunScript.kt index 630ea1e3d9d3..a6635d0b552c 100644 --- a/python/src/com/jetbrains/python/sdk/poetry/PoetryRunScript.kt +++ b/python/src/com/jetbrains/python/sdk/poetry/PoetryRunScript.kt @@ -14,6 +14,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.Project import com.intellij.psi.PsiFile import com.jetbrains.extensions.python.toPsi +import com.jetbrains.python.PyBundle import com.jetbrains.python.packaging.PyExecutionException import com.jetbrains.python.run.PythonRunConfigurationProducer import com.jetbrains.python.sdk.pythonSdk @@ -42,10 +43,11 @@ class PoetryRunScript : AnAction() { val project = e.project ?: return val scriptPath = project.pythonSdk?.homeDirectory?.parent?.findChild(tomlKey.text) ?: return val scriptFile = scriptPath.toPsi(project) ?: return ExecutionErrorDialog.show( - PyExecutionException("Cannot find a script file\nPlease run 'poetry install' before executing scripts", "poetry", emptyList()), - "Poetry Plugin", project) + PyExecutionException( + PyBundle.message("python.sdk.dialog.message.cannot.find.script.file.please.run.poetry.install.before.executing.scripts"), "poetry", + emptyList()), + PyBundle.message("python.sdk.dialog.title.poetry.scripts"), project) runScriptFromRunConfiguration(project, scriptFile.containingFile) - } init { diff --git a/python/src/com/jetbrains/python/sdk/poetry/PoetryScriptsLineMarkerContributor.kt b/python/src/com/jetbrains/python/sdk/poetry/PoetryScriptsLineMarkerContributor.kt index 7631dc543c48..d60d7f5d4c65 100644 --- a/python/src/com/jetbrains/python/sdk/poetry/PoetryScriptsLineMarkerContributor.kt +++ b/python/src/com/jetbrains/python/sdk/poetry/PoetryScriptsLineMarkerContributor.kt @@ -5,6 +5,7 @@ import com.intellij.execution.lineMarker.RunLineMarkerContributor import com.intellij.icons.AllIcons.Actions.Execute import com.intellij.openapi.actionSystem.ActionManager import com.intellij.psi.PsiElement +import com.jetbrains.python.PyBundle import com.jetbrains.python.sdk.pythonSdk import org.toml.lang.psi.TomlKey import org.toml.lang.psi.TomlKeyValue @@ -27,7 +28,7 @@ object PoetryScriptsLineMarkerContributor : RunLineMarkerContributor() { val value = keyValue.value as? TomlLiteral ?: return null if (value.textLength < 3) return null val action = ActionManager.getInstance().getAction(PoetryRunScript.actionID) - action.templatePresentation.text = "Run '${keyValue.key.text}'" + action.templatePresentation.text = PyBundle.message("python.sdk.poetry.action.run.script.text", keyValue.key.text) return Info(Execute, { parameter -> "Run '${((parameter as? TomlKey)?.text ?: "script")}'" }, action) } } diff --git a/python/src/com/jetbrains/python/sdk/poetry/PoetrySdkProvider.kt b/python/src/com/jetbrains/python/sdk/poetry/PoetrySdkProvider.kt index 1bd4ce7864f4..6cb7a9b6c5b8 100644 --- a/python/src/com/jetbrains/python/sdk/poetry/PoetrySdkProvider.kt +++ b/python/src/com/jetbrains/python/sdk/poetry/PoetrySdkProvider.kt @@ -6,6 +6,7 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.projectRoots.Sdk import com.intellij.openapi.projectRoots.SdkAdditionalData import com.intellij.openapi.util.UserDataHolder +import com.jetbrains.python.PyBundle import com.jetbrains.python.packaging.ui.PyPackageManagementService import com.jetbrains.python.sdk.PyInterpreterInspectionQuickFixData import com.jetbrains.python.sdk.PySdkProvider @@ -24,15 +25,11 @@ class PoetrySdkProvider : PySdkProvider { isPyCharm: Boolean, associatedModulePath: String?): PyInterpreterInspectionQuickFixData? { if (sdk.isPoetry) { + val projectUnit = if (isPyCharm) "project" else "module" val message = when { - associatedModulePath != null -> when { - isPyCharm -> "Poetry interpreter is associated with another project: $associatedModulePath" - else -> "Poetry interpreter is associated with another module: $associatedModulePath" - } - else -> when { - isPyCharm -> "Poetry interpreter is not associated with any project" - else -> "Poetry interpreter is not associated with any module" - } + associatedModulePath != null -> + PyBundle.message("python.sdk.inspection.message.poetry.interpreter.associated.with.another.project", projectUnit, associatedModulePath) + else -> PyBundle.message("python.sdk.inspection.message.poetry.interpreter.not.associated.with.any.project", projectUnit) } return PyInterpreterInspectionQuickFixData(UsePoetryQuickFix(sdk, module), message) } diff --git a/python/src/com/jetbrains/python/sdk/poetry/PyPoetryPackageManager.kt b/python/src/com/jetbrains/python/sdk/poetry/PyPoetryPackageManager.kt index 7a80e1989467..a1d7f4e00784 100644 --- a/python/src/com/jetbrains/python/sdk/poetry/PyPoetryPackageManager.kt +++ b/python/src/com/jetbrains/python/sdk/poetry/PyPoetryPackageManager.kt @@ -8,6 +8,7 @@ import com.intellij.openapi.projectRoots.Sdk import com.intellij.openapi.roots.OrderRootType import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VirtualFile +import com.jetbrains.python.PyBundle import com.jetbrains.python.packaging.* import com.jetbrains.python.sdk.PythonSdkType import com.jetbrains.python.sdk.associatedModuleDir @@ -91,7 +92,8 @@ class PyPoetryPackageManager(val sdk: Sdk) : PyPackageManager() { } override fun createVirtualEnv(destinationDir: String, useGlobalSite: Boolean): String { - throw ExecutionException("Creating virtual environments based on Poetry environments is not supported") + throw ExecutionException( + PyBundle.message("python.sdk.dialog.message.creating.virtual.environments.based.on.poetry.environments.not.supported")) } override fun getPackages() = packages diff --git a/python/src/com/jetbrains/python/sdk/poetry/poetry.kt b/python/src/com/jetbrains/python/sdk/poetry/poetry.kt index a88a90c1772a..aa34478d4058 100644 --- a/python/src/com/jetbrains/python/sdk/poetry/poetry.kt +++ b/python/src/com/jetbrains/python/sdk/poetry/poetry.kt @@ -175,7 +175,9 @@ fun setupPoetrySdkUnderProgress(project: Project?, installPackages: Boolean, poetryPath: String? = null): Sdk? { val projectPath = newProjectPath ?: module?.basePath ?: project?.basePath ?: return null - val task = object : Task.WithResult(project, "Setting Up Poetry Environment", true) { + val task = object : Task.WithResult( + project, PyBundle.message("python.sdk.dialog.title.setting.up.poetry.environment"), true) { + override fun compute(indicator: ProgressIndicator): String { indicator.isIndeterminate = true val poetry = when (poetryPath) { @@ -391,7 +393,7 @@ class PoetryInstallQuickFix : LocalQuickFix { } } - override fun getFamilyName() = "Install requirements from poetry.lock" + override fun getFamilyName() = PyBundle.message("python.sdk.intention.family.name.install.requirements.from.poetry.lock") override fun applyFix(project: Project, descriptor: ProblemDescriptor) { val element = descriptor.psiElement ?: return @@ -501,7 +503,7 @@ private val LOCK_NOTIFICATION_GROUP = NotificationGroup(PyBundle.message("python private val Module.poetryLock: VirtualFile? get() = baseDir?.findChild(POETRY_LOCK) -fun runPoetryInBackground(module: Module, args: List, description: String) { +fun runPoetryInBackground(module: Module, args: List, @NlsSafe description: String) { val task = object : Task.Backgroundable(module.project, StringUtil.toTitleCase(description), true) { override fun run(indicator: ProgressIndicator) { val sdk = module.pythonSdk ?: return