Display localized lobby notice text#3514
Conversation
📝 WalkthroughWalkthroughThe PR adds reflective i18n localization support for server notices. ChangesServer Notice Localization
Sequence DiagramsequenceDiagram
participant onNotice
participant getLocalizedNoticeText
participant getOptionalNoticeValue
participant i18n
onNotice->>getLocalizedNoticeText: noticeMessage, fallbackText
getLocalizedNoticeText->>getOptionalNoticeValue: noticeMessage, "getI18nKey"
getOptionalNoticeValue-->>getLocalizedNoticeText: Optional i18nKey
alt i18nKey present
getLocalizedNoticeText->>getOptionalNoticeValue: noticeMessage, "getI18nArgs"
getOptionalNoticeValue-->>getLocalizedNoticeText: Optional i18nArgs
getLocalizedNoticeText->>i18n: getOrDefault(key, args, fallback)
i18n-->>getLocalizedNoticeText: localizedText
else i18nKey absent
getLocalizedNoticeText-->>getLocalizedNoticeText: use fallbackText
end
getLocalizedNoticeText-->>onNotice: finalText
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/java/com/faforever/client/remote/FafServerAccessor.java (1)
283-300:⚠️ Potential issue | 🟠 Major | ⚡ Quick winNull-text guard blocks the new i18n metadata path.
At Line 283, returning early on
noticeMessage.getText() == nullskipsgetLocalizedNoticeText(...), so metadata-only notices won’t render.Proposed fix
- if (noticeMessage.getText() == null) { - return; - } + String localizedText = getLocalizedNoticeText(noticeMessage, noticeMessage.getText()); + if (localizedText == null) { + return; + } @@ - notificationService.addNotification( - new ServerNotification(i18n.get("messageFromServer"), getLocalizedNoticeText(noticeMessage, noticeMessage.getText()), severity, - Collections.singletonList(new DismissAction(i18n)))); + notificationService.addNotification( + new ServerNotification(i18n.get("messageFromServer"), localizedText, severity, + Collections.singletonList(new DismissAction(i18n))));🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/com/faforever/client/remote/FafServerAccessor.java` around lines 283 - 300, Remove the early return that bails out when noticeMessage.getText() == null so metadata-only notices are allowed through; instead let getLocalizedNoticeText(noticeMessage, noticeMessage.getText()) be called even when getText() is null (or replace the guard with a more specific check that only returns when there is neither text nor any metadata), then continue to compute severity and call notificationService.addNotification(new ServerNotification(..., getLocalizedNoticeText(...), ...)) as before (update any null-handling inside getLocalizedNoticeText if needed).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/main/java/com/faforever/client/remote/FafServerAccessor.java`:
- Around line 283-300: Remove the early return that bails out when
noticeMessage.getText() == null so metadata-only notices are allowed through;
instead let getLocalizedNoticeText(noticeMessage, noticeMessage.getText()) be
called even when getText() is null (or replace the guard with a more specific
check that only returns when there is neither text nor any metadata), then
continue to compute severity and call notificationService.addNotification(new
ServerNotification(..., getLocalizedNoticeText(...), ...)) as before (update any
null-handling inside getLocalizedNoticeText if needed).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b21100b5-7759-45d5-920a-a1792834e5b6
📒 Files selected for processing (3)
src/main/java/com/faforever/client/remote/FafServerAccessor.javasrc/main/resources/i18n/messages.propertiessrc/test/java/com/faforever/client/remote/ServerAccessorTest.java
efd9717 to
781142a
Compare
Constraint: FAForever/server#1083 adds optional notice i18n metadata before faf-java-commons is released to this client. Rejected: Bump commons immediately | no published artifact contains the new notice fields yet. Confidence: medium Scope-risk: narrow Directive: Replace reflection with direct NoticeInfo getters after the commons dependency includes i18nKey and i18nArgs. Tested: git diff --check Not-tested: Gradle tests locally; no Java runtime installed in this environment. Co-authored-by: OmX <omx@oh-my-codex.dev>
781142a to
12f92cb
Compare
|
Addressed the null-text edge case from the review in I also ran the focused tests locally with JDK 25:
Result: 2 tests passed. Remote Codacy and CodeRabbit are green again. |
|
The way this is using reflection communicates to me this is a none serious pull request that doesnt understand what it is doing. So I am not going to take the time to review it. |
Summary
login.error.bannedmessage used by Add localizable metadata to ban notices server#1083Context
Companion work for FAForever/server#1083 and FAForever/faf-java-commons#277. This keeps the client backward-compatible with the current commons release while allowing newer notice payloads to render through the client translation bundle once the commons/server pieces land.
Issue: FAForever/server#640
Verification
JAVA_HOME=/Users/yoseph/Codexperiment/.jdks/jdk-25.0.3+9/Contents/Home ./gradlew test— 1518 tests passed, 33 skippedJAVA_HOME=/Users/yoseph/Codexperiment/.jdks/jdk-25.0.3+9/Contents/Home ./gradlew test --tests com.faforever.client.remote.ServerAccessorTest.testLocalizedNoticeTextUsesI18nMetadataWhenPresent --tests com.faforever.client.remote.ServerAccessorTest.testLocalizedNoticeTextSupportsMetadataOnlyNotices— 2 focused tests passedgit diff --check