From 1572249affec83b1d63498881483ef0fe2712885 Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Tue, 27 May 2025 11:02:36 +0200 Subject: [PATCH 1/2] Fix settings not opening with non-default locale --- .../bundles/SettingsBundle.java | 33 ++++--------------- .../settings/SettingsComponent.java | 2 +- ...n.properties => SettingsBundle.properties} | 2 +- .../messages/SettingsBundle_zh_CN.properties | 2 ++ 4 files changed, 11 insertions(+), 28 deletions(-) rename src/main/resources/messages/{SettingsBundle_en.properties => SettingsBundle.properties} (97%) diff --git a/src/main/java/org/overengineer/inlineproblems/bundles/SettingsBundle.java b/src/main/java/org/overengineer/inlineproblems/bundles/SettingsBundle.java index 639731e..df339d4 100644 --- a/src/main/java/org/overengineer/inlineproblems/bundles/SettingsBundle.java +++ b/src/main/java/org/overengineer/inlineproblems/bundles/SettingsBundle.java @@ -3,47 +3,28 @@ import com.intellij.DynamicBundle; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.PropertyKey; -import java.util.Locale; -import java.util.ResourceBundle; import java.util.function.Supplier; -/** - * The SettingsBundle class is a dynamic bundle for managing internationalized messages. +/* The SettingsBundle class is a dynamic bundle for managing internationalized messages. * It extends the DynamicBundle class. - * - * @author kuwei */ public final class SettingsBundle extends DynamicBundle { @NonNls - public static final String BUNDLE = "messages.SettingsBundle"; - - private static final ResourceBundle DEFAULT_BUNDLE = ResourceBundle.getBundle(BUNDLE, Locale.ENGLISH); - + private static final String BUNDLE = "messages.SettingsBundle"; private static final SettingsBundle INSTANCE = new SettingsBundle(); private SettingsBundle() { super(BUNDLE); - try { - ResourceBundle.getBundle(BUNDLE, Locale.getDefault()); - } catch (Exception e) { - Locale.setDefault(Locale.ENGLISH); - } } - @NotNull - public static @Nls String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) { - return INSTANCE.messageOrDefault(key, DEFAULT_BUNDLE.getString(key), params); + @Nls + public static String message(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) { + return INSTANCE.getMessage(key, params); } - @NotNull - public static Supplier<@Nls String> messagePointer(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) { - var result = INSTANCE.messageOrNull(key, params); - if (result == null) { - return () -> DEFAULT_BUNDLE.getString(key); - } - return () -> result; + public static Supplier messagePointer(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) { + return INSTANCE.getLazyMessage(key, params); } } \ No newline at end of file diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java index 28fc66a..89f6079 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java @@ -185,7 +185,7 @@ public SettingsComponent() { .addLabeledComponent(new JLabel(SettingsBundle.message("settings.problemFilterListLabel")), problemFilterList) .addTooltip(SettingsBundle.message("settings.problemFilterListTooltip")) .addLabeledComponent(new JLabel(SettingsBundle.message("settings.fileExtensionBlacklistLabel")), fileExtensionBlacklist) - .addTooltip(SettingsBundle.message("settings.fileExtensionBlaclistTooltip")) + .addTooltip(SettingsBundle.message("settings.fileExtensionBlacklistTooltip")) .addSeparator() .addComponent(new JBLabel(SettingsBundle.message("settings.submenu.colors"))) .addComponent(showErrors) diff --git a/src/main/resources/messages/SettingsBundle_en.properties b/src/main/resources/messages/SettingsBundle.properties similarity index 97% rename from src/main/resources/messages/SettingsBundle_en.properties rename to src/main/resources/messages/SettingsBundle.properties index 550905a..08e3c7a 100644 --- a/src/main/resources/messages/SettingsBundle_en.properties +++ b/src/main/resources/messages/SettingsBundle.properties @@ -29,7 +29,7 @@ settings.inlaySizeDeltaTooltip=Used to have smaller font size for the inlays, sh settings.problemFilterListLabel=Problem filter list settings.problemFilterListTooltip=Semicolon separated list of problem text beginnings that will not be handled settings.fileExtensionBlacklistLabel=File extension blacklist -settings.fileExtensionBlaclistTooltip=Semicolon separated list of file extensions to ignore (like ".java;.md") +settings.fileExtensionBlacklistTooltip=Semicolon separated list of file extensions to ignore (like ".java;.md") settings.submenu.colors=Colors settings.errorTextColor=Error text color: settings.errorLabelBorderColor=Error label border color: diff --git a/src/main/resources/messages/SettingsBundle_zh_CN.properties b/src/main/resources/messages/SettingsBundle_zh_CN.properties index 14c6a8d..1a9a5ce 100644 --- a/src/main/resources/messages/SettingsBundle_zh_CN.properties +++ b/src/main/resources/messages/SettingsBundle_zh_CN.properties @@ -28,6 +28,8 @@ settings.inlaySizeDelta=\u5b57\u4f53\u5927\u5c0f\u5dee\u5f02 settings.inlaySizeDeltaTooltip=\u7528\u4e8e\u4e3a\u6807\u7b7e\u8bbe\u7f6e\u8f83\u5c0f\u7684\u5b57\u4f53\uff0c\u5fc5\u987b\u5c0f\u4e8e\u7f16\u8f91\u5668\u5b57\u4f53\u5927\u5c0f settings.problemFilterListLabel=\u95ee\u9898\u8fc7\u6ee4\u5217\u8868 settings.problemFilterListTooltip=\u4e0d\u5904\u7406\u7684\u95ee\u9898\u6587\u672c\u5f00\u5934\u7684\u7528\u5206\u53f7\u5206\u9694\u7684\u5217\u8868 +settings.fileExtensionBlacklistLabel=File extension blacklist +settings.fileExtensionBlacklistTooltip=Semicolon separated list of file extensions to ignore (like ".java;.md") settings.submenu.colors=\u989C\u8272 settings.errorTextColor=\u9519\u8BEF\u6587\u672C\u989C\u8272\uFF1A settings.errorLabelBorderColor=\u9519\u8BEF\u6807\u7B7E\u8FB9\u6846\u989C\u8272\uFF1A From 47e621b58557b8db9bb600dba28d884324754c40 Mon Sep 17 00:00:00 2001 From: 0verEngineer Date: Tue, 27 May 2025 11:04:06 +0200 Subject: [PATCH 2/2] - Add changelog - Bump version --- CHANGELOG.md | 4 ++++ gradle.properties | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77c4a1a..b6e8089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ ## [Unreleased] +## [0.5.8] +### Fixed +- Fixed settings not opening with non default locales + ## [0.5.7] ### Changed - Added feature to enable and disable all problems with a keybind (thanks to khopland) diff --git a/gradle.properties b/gradle.properties index 4eddd9b..3a4ebf5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ pluginGroup = org.OverEngineer pluginName = InlineProblems pluginRepositoryUrl = https://github.com/OverEngineer/InlineProblems # SemVer format -> https://semver.org -pluginVersion = 0.5.7 +pluginVersion = 0.5.8 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 212.5