-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e934c45
commit 46ae022
Showing
1 changed file
with
3 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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]) | ||
|
@@ -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) | ||
} | ||
} |