feat(user-settings): add a per-user media language setting#2983
feat(user-settings): add a per-user media language setting#2983
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds a per-user Media Language setting ( Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant Frontend as Frontend
participant API as API_Server
participant DB as Database
participant TMDB as TMDB
User->>Frontend: change Media Language (mediaLocale)
Frontend->>API: POST /settings/main { mediaLocale }
API->>DB: persist user_settings.mediaLocale
DB-->>API: ack
API-->>Frontend: 200 OK (settings with mediaLocale)
Frontend->>API: GET /movie/:id (no ?language)
API->>DB: read user_settings.mediaLocale
DB-->>API: mediaLocale
API->>TMDB: GET /movie/:id?language=mediaLocale_or_req.locale
TMDB-->>API: localized movie metadata
API-->>Frontend: movie metadata
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/using-seerr/users/editing-users.md`:
- Around line 36-41: Replace the term "Content Language" with the UI-consistent
phrase "Media Language" throughout this doc: update the heading "Content
Language", the explanatory paragraph "Users can choose a separate content
language..." and the fallback sentence "If no content language is selected..."
to use "Media Language" instead so wording matches the settings UI.
In `@server/routes/index.ts`:
- Around line 261-265: The current fallback uses the nullish coalescing operator
which treats empty strings as valid, so replace usages like "const mediaLocale =
req.user?.settings?.mediaLocale ?? req.locale" and language assignments such as
"language: (req.query.language as string) ?? mediaLocale" with a check that
treats empty strings as missing (e.g., use (req.user?.settings?.mediaLocale &&
req.user.settings.mediaLocale.trim()) ? req.user.settings.mediaLocale :
req.locale or a small helper normalizeLocale(value, fallback) that returns
fallback if value is null/undefined/''/only-whitespace), then update all call
sites (including the tmdb.getMovieGenres call and other routes using
mediaLocale, req.query.language, and language: ...) to pass the normalized
locale so TMDB never receives an empty language string.
In `@src/components/UserProfile/UserSettings/UserGeneralSettings/index.tsx`:
- Around line 414-418: The "Default (...)" option currently uses
availableLanguages[currentSettings.locale].display which shows the
display-language override instead of the effective fallback for media; change
that to use the media locale when set and otherwise the effective locale used by
the backend (e.g., availableLanguages[currentSettings.mediaLocale ??
effectiveLocale].display). Update the intl.formatMessage call in the <option>
inside UserGeneralSettings (index.tsx) to reference currentSettings.mediaLocale
?? effectiveLocale and ensure effectiveLocale is obtained from the component
props/context (the same source that represents req.locale/effective user
locale).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3741fa9a-610d-43ac-a820-91634fc2899d
📒 Files selected for processing (15)
docs/using-seerr/users/editing-users.mdseerr-api.ymlserver/entity/UserSettings.tsserver/interfaces/api/userSettingsInterfaces.tsserver/migration/postgres/1777644799789-AddMediaLanguageSetting.tsserver/migration/sqlite/1777644713621-AddMediaLanguageSetting.tsserver/routes/index.tsserver/routes/movie.tsserver/routes/person.tsserver/routes/search.tsserver/routes/tv.tsserver/routes/user/usersettings.tssrc/components/UserProfile/UserSettings/UserGeneralSettings/index.tsxsrc/hooks/useUser.tssrc/i18n/locale/en.json
c2a55af to
31936bf
Compare
Description
This PR introduces a clearer separation between user language preferences by distinguishing the Display Language used for the UI and the Media Language used for media metadata.
To preserve backward compatibility, the content language automatically falls back to the effective locale when it hasn't been explicitly set.
How Has This Been Tested?
UI is correctly using English as display language whereas media related metadata is displayed in French.
Screenshots / Logs (if applicable)
User settings
Result
Checklist:
pnpm buildpnpm i18n:extractSummary by CodeRabbit