more dynamic bundles

GitOrigin-RevId: 287684f806e29937f08580dfe89f478f170fb32b
This commit is contained in:
Sergey Ignatov
2019-12-18 19:31:34 +00:00
committed by intellij-monorepo-bot
parent 67d3dd990b
commit da81ff4937
@@ -15,36 +15,24 @@
*/
package com.intellij.openapi.application;
import com.intellij.CommonBundle;
import com.intellij.DynamicBundle;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.PropertyKey;
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import java.util.ResourceBundle;
/**
* Provides access to localized properties of the IntelliJ Platform.
*/
public class ApplicationBundle {
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
return CommonBundle.message(getBundle(), key, params);
}
private static Reference<ResourceBundle> ourBundle;
public class ApplicationBundle extends DynamicBundle {
@NonNls public static final String BUNDLE = "messages.ApplicationBundle";
private static final ApplicationBundle INSTANCE = new ApplicationBundle();
private ApplicationBundle() {
super(BUNDLE);
}
private static ResourceBundle getBundle() {
ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference<>(bundle);
}
return bundle;
@NotNull
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
return INSTANCE.getMessage(key, params);
}
}