Log Overlay: load whitelist keywords from i18n#161
Conversation
Switches the hardcoded EN/FR whitelist to an i18n-driven one so other locales can override it via their strings_<locale>.properties. - LogOverlay.java loads halizeur.log_overlay.whitelist via I18nAPI - Falls back to a default English whitelist when the key is missing - Adds the key in strings_en.properties and strings_fr.properties Suggested by @do-gamer in the post-merge review of Darkbot-Plugins#159.
Reviewer's GuideRefactors the log overlay whitelist from a hardcoded EN/FR array to a locale-aware, i18n-configured comma-separated string, parsed at startup with a safe default, and updates EN/FR resource bundles to define the whitelist per locale. Sequence diagram for loading whitelist from i18n in LogOverlay constructorsequenceDiagram
actor PluginLoader
participant PluginAPI
participant LogOverlay
participant I18nAPI
PluginLoader->>PluginAPI: createLogOverlay()
PluginAPI->>LogOverlay: new LogOverlay(api)
activate LogOverlay
LogOverlay->>PluginAPI: requireAPI(EventBrokerAPI)
PluginAPI-->>LogOverlay: EventBrokerAPI instance
LogOverlay->>PluginAPI: requireAPI(I18nAPI)
PluginAPI-->>LogOverlay: I18nAPI instance
LogOverlay->>I18nAPI: getOrDefault(halizeur.log_overlay.whitelist, DEFAULT_WHITELIST)
I18nAPI-->>LogOverlay: csvKeywords
LogOverlay->>LogOverlay: whitelist = parseKeywords(csvKeywords)
deactivate LogOverlay
Class diagram for updated LogOverlay whitelist handlingclassDiagram
class PluginAPI {
+requireAPI(apiClass)
}
class I18nAPI {
+getOrDefault(key, defaultValue) String
}
class LogOverlay {
-static long DISPLAY_MS
-static String DEFAULT_WHITELIST
-Deque~Entry~ entries
-List~String~ whitelist
-LogOverlayConfig config
+LogOverlay(PluginAPI api)
-static List~String~ parseKeywords(String csv)
-boolean isAllowed(String msg)
}
PluginAPI --> LogOverlay : constructs
LogOverlay ..> I18nAPI : uses
LogOverlay ..> PluginAPI : requires APIs
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/main/java/dev/shared/halizeur/log_overlay/LogOverlay.java" line_range="78" />
<code_context>
+ List<String> out = new ArrayList<>();
+ if (csv == null) return out;
+ for (String s : csv.split(",")) {
+ String t = s.trim().toLowerCase();
+ if (!t.isEmpty()) out.add(t);
+ }
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Use a locale-independent lowercasing to avoid subtle issues on non-English locales.
`toLowerCase()` without an explicit locale can mis-handle some characters (e.g., in Turkish). Since these are technical identifiers, please use `toLowerCase(Locale.ROOT)` so behavior is consistent across all user locales.
Suggested implementation:
```java
import java.util.List;
import java.util.Locale;
```
```java
String t = s.trim().toLowerCase(Locale.ROOT);
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@Halizeur As suggestion you may try to add |
Per do-gamer review: replace the comma-separated halizeur.log_overlay.whitelist i18n key with a Categories sub-config of 6 toggles (gains, currencies, resources, boosters, errors, combat). Each category bundles FR + EN keywords so the filter works on both locales without per-translator upkeep. Default: 5 categories on, combat off.
|
Actually need to use The Bigpoint templates which use the API (English) https://darkorbit-22.bpsecure.com/spacemap/templates/en/flashres.xml Example: |
Per do-gamer review: drop the hardcoded FR + EN keyword list and match
messages via GameResourcesAPI.getTranslationMatcher() on the official
Bigpoint flashres keys instead. Categories Gains, Boosters, Errors and
Combat are now driven by translation matchers; Currencies / Resources
stay on substring matching since their names appear inside the %!
placeholder of the gain templates (resource names are resolved via
findTranslation("ore_*") so they still adapt to the active locale).
|
| @@ -26,6 +30,11 @@ | |||
| * Source: {@link GameLogAPI.LogMessageEvent} emitted by DarkBot for each | |||
| * new system message. Each line disappears after DISPLAY_MS ms so the | |||
| * canvas does not get cluttered. | |||
| * | |||
| * Filter: per category, the overlay matches messages against translation | |||
| * patterns from {@link GameResourcesAPI} (the official Bigpoint flashres | |||
| * keys), so the filter works on every game locale without per-language | |||
| * keyword maintenance. | |||
| /** Currency names. DarkOrbit keeps these mostly untranslated across | ||
| * locales, so a static list works as a substring filter against any | ||
| * raw log message. Lower-cased at init time for case-insensitive | ||
| * comparison. */ |



Switches the hardcoded EN/FR whitelist to an i18n-driven one so other locales can override it via their strings_.properties.
Suggested by @do-gamer in the post-merge review of #159.
Summary by Sourcery
Load log overlay whitelist keywords from i18n with a locale-specific fallback.
Enhancements: