mirror of
https://github.com/JetBrains/intellij-platform-plugin-template.git
synced 2026-09-22 11:54:40 +00:00
Add operator function for resource bundle key access in MyBundle
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- Add operator function for resource bundle key access in `MyBundle`
|
||||
|
||||
### Changed
|
||||
|
||||
- Dependencies - upgrade `org.jetbrains.intellij.platform` to `2.16.0`
|
||||
|
||||
@@ -9,6 +9,9 @@ private const val BUNDLE = "messages.MyBundle"
|
||||
|
||||
object MyBundle : DynamicBundle(BUNDLE) {
|
||||
|
||||
operator fun get(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
|
||||
getMessage(key, *params)
|
||||
|
||||
@JvmStatic
|
||||
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
|
||||
getMessage(key, *params)
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.plugins.template.MyBundle
|
||||
class MyProjectService(project: Project) {
|
||||
|
||||
init {
|
||||
thisLogger().info(MyBundle.message("projectService", project.name))
|
||||
thisLogger().info(MyBundle["projectService", project.name])
|
||||
thisLogger().warn("Don't forget to remove all non-needed sample code files with their corresponding registration entries in `plugin.xml`.")
|
||||
}
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ class MyToolWindowFactory : ToolWindowFactory {
|
||||
private val service = toolWindow.project.service<MyProjectService>()
|
||||
|
||||
fun getContent() = JBPanel<JBPanel<*>>().apply {
|
||||
val label = JBLabel(MyBundle.message("randomLabel", "?"))
|
||||
val label = JBLabel(MyBundle["randomLabel", "?"])
|
||||
|
||||
add(label)
|
||||
add(JButton(MyBundle.message("shuffle")).apply {
|
||||
add(JButton(MyBundle["shuffle"]).apply {
|
||||
addActionListener {
|
||||
label.text = MyBundle.message("randomLabel", service.getRandomNumber())
|
||||
label.text = MyBundle["randomLabel", service.getRandomNumber()]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user