i18n: Extract common caching code from bundles, J2K existing bundles

This commit is contained in:
Yan Zhulanow
2020-02-17 15:19:42 +09:00
committed by Dmitry Gridin
parent 207ecf757b
commit 3b931514ac
4 changed files with 75 additions and 81 deletions
@@ -13,39 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.idea
package org.jetbrains.kotlin.idea;
import com.intellij.CommonBundle;
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;
public class KotlinBundle {
private static Reference<ResourceBundle> ourBundle;
import com.intellij.CommonBundle
import org.jetbrains.annotations.NonNls
import org.jetbrains.annotations.PropertyKey
import org.jetbrains.kotlin.idea.core.util.KotlinBundleBase
import java.util.*
object KotlinBundle : KotlinBundleBase() {
@NonNls
private static final String BUNDLE = "org.jetbrains.kotlin.idea.KotlinBundle";
private const val BUNDLE = "org.jetbrains.kotlin.idea.KotlinBundle"
private KotlinBundle() {
}
override fun createBundle(): ResourceBundle = ResourceBundle.getBundle(BUNDLE)
@NotNull
public static String message(@NonNls @PropertyKey(resourceBundle = BUNDLE) String key, Object... params) {
return CommonBundle.message(getBundle(), key, params);
@JvmStatic
fun message(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any?): String {
return CommonBundle.message(bundle, key, *params)
}
private static ResourceBundle getBundle() {
ResourceBundle bundle = null;
if (ourBundle != null) bundle = ourBundle.get();
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference<ResourceBundle>(bundle);
}
return bundle;
}
}
}