Skip to content

Conversation

@cathysarisky
Copy link
Member

@cathysarisky cathysarisky commented Dec 2, 2025

We had some stale code that fired whenever a labs setting changed. Since i18n is now GA, we don't need this check. Further, it actually runs every time any flag is changed, resulting in unneeded language changes (and debug log spam) for totally unrelated changes.


Note

Always use settings.locale for i18n and update on locale changes only; remove labs-based checks and the settings.labs.edited listener.

  • Email i18n handling (core/server/services/email-service/EmailServiceWrapper.js):
    • Initialize i18n with settingsCache.get('locale') || 'en' (remove labs-gated fallback).
    • Remove settings.labs.edited listener and related conditional changeLanguage logic.
    • On settings.locale.edited, always call i18n.changeLanguage with the new value (no labs checks).

Written by Cursor Bugbot for commit 794a73c. This will update automatically on new commits. Configure here.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The EmailServiceWrapper.js change removes the settings.labs.edited event listener and the conditional labs.i18n check, and it initializes/updates i18n directly from settingsCache (falling back to 'en'). Locale updates on settings.locale.edited now always call i18n.changeLanguage with the new value instead of gating the call behind the labs flag.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Key areas to verify:
    • Inspect EmailServiceWrapper.js for correct removal of the settings.labs.edited handler and that no other references to labs.i18n remain in this file.
    • Confirm i18n initialization uses settingsCache and defaults to 'en' as intended.
    • Verify i18n.changeLanguage call on settings.locale.edited is correct and that tests for locale changes still pass.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description is directly related to the changeset, explaining why labs checks are removed and how i18n handling is simplified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and specifically summarizes the main change: reducing unnecessary i18n reinitializations in EmailServiceWrapper by removing stale labs-based logic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on December 3

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eaf6761 and 3aee6c5.

📒 Files selected for processing (1)
  • ghost/core/core/server/services/email-service/EmailServiceWrapper.js (1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: sagzy
Repo: TryGhost/Ghost PR: 24673
File: ghost/i18n/lib/i18n.js:34-35
Timestamp: 2025-11-24T11:12:15.712Z
Learning: In the Ghost i18n package (ghost/i18n/lib/i18n.js), changing existing locale codes requires backwards compatibility handling for users who have already configured those locales. Such changes should be done in a separate PR with migration logic rather than included in feature PRs.
Learnt from: kevinansfield
Repo: TryGhost/Ghost PR: 25118
File: apps/portal/src/actions.js:160-173
Timestamp: 2025-10-09T15:31:06.587Z
Learning: When reviewing PRs that introduce feature-flagged changes (e.g., `labs?.membersSigninOTCAlpha`), avoid suggesting modifications to non-flagged code paths unless they're directly related to the PR's objectives. Keep the scope focused on the feature-flag-specific changes only.
Learnt from: kevinansfield
Repo: TryGhost/Ghost PR: 25118
File: apps/portal/src/App.js:719-719
Timestamp: 2025-10-09T14:16:58.334Z
Learning: In Ghost Portal (apps/portal), avoid suggesting changes to translation strings (wrapped in `t()`) unless directly related to the PR's primary objective, as changing them invalidates existing translations and creates unnecessary churn. If a typo or improvement is found in a translation string, it should be fixed across all instances in a dedicated PR.
Learnt from: kevinansfield
Repo: TryGhost/Ghost PR: 23770
File: apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModalLabs.tsx:435-450
Timestamp: 2025-06-10T11:07:10.800Z
Learning: In Ghost's newsletter customization features, when promoting a feature from alpha to beta status, the feature flag guards are updated to make the feature available under both the `emailCustomization` (beta) and `emailCustomizationAlpha` (alpha) flags. This is done by either removing conditional guards entirely when the component is already behind both flags, or by updating conditionals to check for either flag.
📚 Learning: 2025-10-30T17:13:26.190Z
Learnt from: sam-lord
Repo: TryGhost/Ghost PR: 25303
File: ghost/core/core/server/services/email-service/BatchSendingService.js:19-19
Timestamp: 2025-10-30T17:13:26.190Z
Learning: In ghost/core/core/server/services/email-service/BatchSendingService.js and similar files in the Ghost codebase, prefer using `{...options}` spread syntax without explicit guards like `...(options || {})` when spreading potentially undefined objects, as the maintainer prefers cleaner syntax over defensive patterns when the behavior is safe.

Applied to files:

  • ghost/core/core/server/services/email-service/EmailServiceWrapper.js
📚 Learning: 2025-11-24T11:12:15.712Z
Learnt from: sagzy
Repo: TryGhost/Ghost PR: 24673
File: ghost/i18n/lib/i18n.js:34-35
Timestamp: 2025-11-24T11:12:15.712Z
Learning: In the Ghost i18n package (ghost/i18n/lib/i18n.js), changing existing locale codes requires backwards compatibility handling for users who have already configured those locales. Such changes should be done in a separate PR with migration logic rather than included in feature PRs.

Applied to files:

  • ghost/core/core/server/services/email-service/EmailServiceWrapper.js
📚 Learning: 2025-01-29T15:27:29.391Z
Learnt from: cathysarisky
Repo: TryGhost/Ghost PR: 0
File: :0-0
Timestamp: 2025-01-29T15:27:29.391Z
Learning: When reviewing translation files in ghost/i18n/locales, translators should only modify the translated values and must not change the keys or placeholder styles (e.g., %%{status}%%, {site}, etc.) as they serve specific purposes like Mailgun string replacement.

Applied to files:

  • ghost/core/core/server/services/email-service/EmailServiceWrapper.js
📚 Learning: 2025-05-06T00:47:48.488Z
Learnt from: cathysarisky
Repo: TryGhost/Ghost PR: 0
File: :0-0
Timestamp: 2025-05-06T00:47:48.488Z
Learning: The theme i18n initialization in Ghost only happens during server boot, theme changes, and language changes - not on every page load or `t` helper call. The initialization check in the `t` helper is a safeguard that doesn't execute during normal page rendering once the theme is loaded.

Applied to files:

  • ghost/core/core/server/services/email-service/EmailServiceWrapper.js
📚 Learning: 2025-11-25T14:28:50.351Z
Learnt from: CR
Repo: TryGhost/Ghost PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T14:28:50.351Z
Learning: Centralized i18n translations should be maintained in `ghost/i18n/locales/{locale}/{namespace}.json` files with 60+ supported locales

Applied to files:

  • ghost/core/core/server/services/email-service/EmailServiceWrapper.js
📚 Learning: 2025-11-25T14:28:50.351Z
Learnt from: CR
Repo: TryGhost/Ghost PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T14:28:50.351Z
Learning: Applies to ghost/i18n/locales/en/ghost.json : Add UI translations to `ghost/i18n/locales/en/ghost.json` for Admin UI features

Applied to files:

  • ghost/core/core/server/services/email-service/EmailServiceWrapper.js
🧬 Code graph analysis (1)
ghost/core/core/server/services/email-service/EmailServiceWrapper.js (2)
ghost/core/test/unit/server/services/email-service/email-renderer.test.js (1)
  • i18n (78-78)
ghost/core/test/unit/server/services/email-service/email-helpers.test.js (1)
  • i18n (6-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Legacy tests (Node 22.18.0, mysql8)
  • GitHub Check: Acceptance tests (Node 22.18.0, sqlite3)
  • GitHub Check: Acceptance tests (Node 22.18.0, mysql8)
  • GitHub Check: Unit tests (Node 22.18.0)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Build & Push
🔇 Additional comments (1)
ghost/core/core/server/services/email-service/EmailServiceWrapper.js (1)

65-68: LGTM! Simplified locale change handler.

The event handler now directly updates the i18n language whenever the locale setting changes, without conditionally checking the labs flag. This aligns with the PR objective of removing stale i18n feature flag logic now that i18n is GA.

@cathysarisky cathysarisky changed the title EmailServiceWrapper reduce i18n re-inits 🐛Reduce i18n reinitializations in EmailServiceWrapper Dec 2, 2025
@cathysarisky cathysarisky merged commit 52b845b into TryGhost:main Dec 10, 2025
41 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants