From 3156c22deeb82bcabfdfbab398b5c3c38e8116a8 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Wed, 25 Jun 2025 15:33:13 +0200 Subject: [PATCH] Python: localize string GitOrigin-RevId: 63f2e888bff6d4e9ebccf67d43c6d9a927cba900 --- .../messages/PySystemPythonBundle.properties | 1 + .../systemPython/impl/PySystemPythonBundle.kt | 15 +++++++++++++++ .../systemPython/systemPythonServiceImpl.kt | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 python/services/system-python/resources/messages/PySystemPythonBundle.properties create mode 100644 python/services/system-python/src/com/intellij/python/community/services/systemPython/impl/PySystemPythonBundle.kt diff --git a/python/services/system-python/resources/messages/PySystemPythonBundle.properties b/python/services/system-python/resources/messages/PySystemPythonBundle.properties new file mode 100644 index 000000000000..61e9ca7beb31 --- /dev/null +++ b/python/services/system-python/resources/messages/PySystemPythonBundle.properties @@ -0,0 +1 @@ +py.system.python.service.python.is.broken=Python {0} is broken \ No newline at end of file diff --git a/python/services/system-python/src/com/intellij/python/community/services/systemPython/impl/PySystemPythonBundle.kt b/python/services/system-python/src/com/intellij/python/community/services/systemPython/impl/PySystemPythonBundle.kt new file mode 100644 index 000000000000..73da436a64f6 --- /dev/null +++ b/python/services/system-python/src/com/intellij/python/community/services/systemPython/impl/PySystemPythonBundle.kt @@ -0,0 +1,15 @@ +package com.intellij.python.community.services.systemPython.impl + +import com.intellij.DynamicBundle +import org.jetbrains.annotations.Nls +import org.jetbrains.annotations.PropertyKey + +internal object PySystemPythonBundle { + private const val BUNDLE = "messages.PySystemPythonBundle" + + private val INSTANCE = DynamicBundle(PySystemPythonBundle::class.java, BUNDLE) + + fun message(key: @PropertyKey(resourceBundle = BUNDLE) String, vararg params: Any): @Nls String { + return INSTANCE.getMessage(key, *params) + } +} \ No newline at end of file diff --git a/python/services/system-python/src/com/intellij/python/community/services/systemPython/systemPythonServiceImpl.kt b/python/services/system-python/src/com/intellij/python/community/services/systemPython/systemPythonServiceImpl.kt index 207aeb41f9d2..b6262a4fb0ae 100644 --- a/python/services/system-python/src/com/intellij/python/community/services/systemPython/systemPythonServiceImpl.kt +++ b/python/services/system-python/src/com/intellij/python/community/services/systemPython/systemPythonServiceImpl.kt @@ -16,6 +16,7 @@ import com.intellij.python.community.services.shared.UICustomization import com.intellij.python.community.services.systemPython.SystemPythonServiceImpl.MyServiceState import com.intellij.python.community.services.systemPython.impl.Cache import com.intellij.python.community.services.systemPython.impl.CoreSystemPythonProvider +import com.intellij.python.community.services.systemPython.impl.PySystemPythonBundle import com.jetbrains.python.PythonBinary import com.jetbrains.python.Result import com.jetbrains.python.errorProcessing.PyResult @@ -63,7 +64,8 @@ internal class SystemPythonServiceImpl(scope: CoroutineScope) : SystemPythonServ } override suspend fun registerSystemPython(pythonPath: PythonBinary): PyResult { - val pythonWithLangLevel = VanillaPythonWithLanguageLevelImpl.createByPythonBinary(pythonPath).getOr("Python {$pythonPath} is broken") { return it } + val pythonWithLangLevel = VanillaPythonWithLanguageLevelImpl.createByPythonBinary(pythonPath) + .getOr(PySystemPythonBundle.message("py.system.python.service.python.is.broken", pythonPath)) { return it } val systemPython = SystemPython(pythonWithLangLevel, null) state.userProvidedPythons.add(pythonPath.pathString) cache()?.get(pythonPath.getEelDescriptor())?.add(systemPython)