Skip to content

Commit

Permalink
fix: bundle params
Browse files Browse the repository at this point in the history
  • Loading branch information
BFergerson committed Oct 12, 2022
1 parent e934c45 commit 46ae022
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions common/src/main/kotlin/spp/jetbrains/PluginBundle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package spp.jetbrains

import com.intellij.AbstractBundle
import com.intellij.BundleBase
import com.intellij.ide.plugins.PluginManager
import com.intellij.openapi.extensions.PluginId
import org.jetbrains.annotations.NonNls
Expand All @@ -27,7 +28,7 @@ import java.util.*
private const val BUNDLE = "messages.PluginBundle"

/**
* todo: description.
* Provides access to the plugin's localized messages.
*
* @since 0.2.0
* @author [Brandon Fergerson](mailto:[email protected])
Expand All @@ -43,18 +44,8 @@ object PluginBundle : AbstractBundle(BUNDLE) {
}
}

//todo: shouldn't need to manually load bundle.
val LOCALE_BUNDLE: ResourceBundle by lazy {
ResourceBundle.getBundle(BUNDLE, LOCALE, PluginBundle::class.java.classLoader)
}

@Suppress("SpreadOperator")
@JvmStatic
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String {
return try {
LOCALE_BUNDLE.getString(key) ?: getMessage(key, *params)
} catch (ignore: MissingResourceException) {
key // no translation found
}
return BundleBase.messageOrDefault(resourceBundle, key, key, *params)
}
}

0 comments on commit 46ae022

Please sign in to comment.