33import com .intellij .DynamicBundle ;
44import org .jetbrains .annotations .Nls ;
55import org .jetbrains .annotations .NonNls ;
6- import org .jetbrains .annotations .NotNull ;
76import org .jetbrains .annotations .PropertyKey ;
87
9- import java .util .Locale ;
10- import java .util .ResourceBundle ;
118import java .util .function .Supplier ;
129
13- /**
14- * The SettingsBundle class is a dynamic bundle for managing internationalized messages.
10+ /* The SettingsBundle class is a dynamic bundle for managing internationalized messages.
1511 * It extends the DynamicBundle class.
16- *
17- * @author kuwei
1812 */
1913public final class SettingsBundle extends DynamicBundle {
2014 @ NonNls
21- public static final String BUNDLE = "messages.SettingsBundle" ;
22-
23- private static final ResourceBundle DEFAULT_BUNDLE = ResourceBundle .getBundle (BUNDLE , Locale .ENGLISH );
24-
15+ private static final String BUNDLE = "messages.SettingsBundle" ;
2516 private static final SettingsBundle INSTANCE = new SettingsBundle ();
2617
2718 private SettingsBundle () {
2819 super (BUNDLE );
29- try {
30- ResourceBundle .getBundle (BUNDLE , Locale .getDefault ());
31- } catch (Exception e ) {
32- Locale .setDefault (Locale .ENGLISH );
33- }
3420 }
3521
36- @ NotNull
37- public static @ Nls String message (@ NotNull @ PropertyKey (resourceBundle = BUNDLE ) String key , Object @ NotNull ... params ) {
38- return INSTANCE .messageOrDefault (key , DEFAULT_BUNDLE . getString ( key ) , params );
22+ @ Nls
23+ public static String message (@ PropertyKey (resourceBundle = BUNDLE ) String key , Object ... params ) {
24+ return INSTANCE .getMessage (key , params );
3925 }
4026
41- @ NotNull
42- public static Supplier <@ Nls String > messagePointer (@ NotNull @ PropertyKey (resourceBundle = BUNDLE ) String key , Object @ NotNull ... params ) {
43- var result = INSTANCE .messageOrNull (key , params );
44- if (result == null ) {
45- return () -> DEFAULT_BUNDLE .getString (key );
46- }
47- return () -> result ;
27+ public static Supplier <String > messagePointer (@ PropertyKey (resourceBundle = BUNDLE ) String key , Object ... params ) {
28+ return INSTANCE .getLazyMessage (key , params );
4829 }
4930}
0 commit comments